$ python scripts/check_contract.py
PASS: offline skeleton structure, local refs and Python syntax; application NOT tested.

exit=0
$ python tests/smoke.py --base-url http://127.0.0.1:8080
PASS: lab3 public API scenario; infrastructure and grading evidence remain separate.

exit=0
$ python -m unittest discover -s student-tests -p test_api.py -v
test_bearer_rules (test_api.AuthTest.test_bearer_rules) ... ok
test_concurrent_registration_of_same_username (test_api.AuthTest.test_concurrent_registration_of_same_username) ... ok
test_logout_revokes_in_database_and_cache (test_api.AuthTest.test_logout_revokes_in_database_and_cache) ... ok
test_password_is_not_exposed_or_stored_plain (test_api.AuthTest.test_password_is_not_exposed_or_stored_plain) ... ok
test_register_validation (test_api.AuthTest.test_register_validation) ... ok
test_session_shape_entropy_and_logout (test_api.AuthTest.test_session_shape_entropy_and_logout) ... ok
test_token_only_stored_as_hash (test_api.AuthTest.test_token_only_stored_as_hash) ... ok
test_wrong_password_and_unknown_user_are_indistinguishable (test_api.AuthTest.test_wrong_password_and_unknown_user_are_indistinguishable) ... ok
test_chat_creation_is_atomic (test_api.DataTest.test_chat_creation_is_atomic) ... ok
test_foreign_chat_empty_message_bad_json (test_api.DataTest.test_foreign_chat_empty_message_bad_json) ... ok
test_multi_page_history_and_cursor_binding (test_api.DataTest.test_multi_page_history_and_cursor_binding) ... ok
test_parallel_writes_from_many_clients (test_api.DataTest.test_parallel_writes_from_many_clients) ... ok

----------------------------------------------------------------------
Ran 12 tests in 2.437s

OK

exit=0
$ python -m unittest discover -s student-tests -p test_idempotency.py -v
test_concurrent_same_key_creates_exactly_one_message_across_replicas (test_idempotency.IdempotencyTest.test_concurrent_same_key_creates_exactly_one_message_across_replicas) ... ok
test_different_body_same_key_is_409 (test_idempotency.IdempotencyTest.test_different_body_same_key_is_409) ... ok
test_expired_key_is_reusable_after_ttl (test_idempotency.IdempotencyTest.test_expired_key_is_reusable_after_ttl) ... ok
test_key_validation (test_idempotency.IdempotencyTest.test_key_validation) ... ok
test_replay_rechecks_session_and_membership (test_idempotency.IdempotencyTest.test_replay_rechecks_session_and_membership) ... ok
test_replay_returns_same_message_and_creates_no_duplicate (test_idempotency.IdempotencyTest.test_replay_returns_same_message_and_creates_no_duplicate) ... ok
test_scope_is_user_and_chat (test_idempotency.IdempotencyTest.test_scope_is_user_and_chat) ... ok
test_semantically_equal_body_is_replayed (test_idempotency.IdempotencyTest.test_semantically_equal_body_is_replayed) ... ok
test_session_is_shared_between_replicas_without_relogin (test_idempotency.IdempotencyTest.test_session_is_shared_between_replicas_without_relogin) ... ok

----------------------------------------------------------------------
Ran 9 tests in 2.503s

OK

exit=0
$ python -m unittest discover -s student-tests -p test_topology.py -v
test_api_runs_as_non_root (test_topology.TopologyTest.test_api_runs_as_non_root) ... ok
test_at_least_two_api_replicas_without_published_ports (test_topology.TopologyTest.test_at_least_two_api_replicas_without_published_ports) ... ok
test_no_fixed_container_names (test_topology.TopologyTest.test_no_fixed_container_names) ... ok
test_only_lb_is_published_and_only_on_localhost (test_topology.TopologyTest.test_only_lb_is_published_and_only_on_localhost) ... ok
test_resource_limits_are_set (test_topology.TopologyTest.test_resource_limits_are_set) ... ok
test_stop_grace_period_covers_drain (test_topology.TopologyTest.test_stop_grace_period_covers_drain) ... ok

----------------------------------------------------------------------
Ran 6 tests in 1.344s

OK

exit=0
$ python tests/resilience.py --mode persistence --action-script scripts/restart.cmd --base-url http://127.0.0.1:8080
Executing explicit persistence hook; hook output suppressed to avoid leaking secrets.
PASS: persistence preserved confirmed data and existing session. Hook scope needs operator evidence.

exit=0
$ python tests/resilience.py --mode failover --action-script scripts/stop-one.cmd --base-url http://127.0.0.1:8080
Executing explicit failover hook; hook output suppressed to avoid leaking secrets.
{"observed_instances_before": 2, "successful_writes": 118, "failed_attempts": 0, "first_recovery_seconds": 2.438}
PASS: failover preserved confirmed data and existing session. Hook scope needs operator evidence.

exit=0
$ docker compose --env-file .env start api
 Container mtusi-lab3-postgres-1 Waiting 
 Container mtusi-lab3-postgres-1 Healthy 
 Container mtusi-lab3-migrate-1 Starting 
 Container mtusi-lab3-migrate-1 Started 
 Container mtusi-lab3-migrate-1 Waiting 
 Container mtusi-lab3-valkey-1 Waiting 
 Container mtusi-lab3-valkey-1 Healthy 
 Container mtusi-lab3-migrate-1 Exited 
 Container mtusi-lab3-api-9 Starting 
 Container mtusi-lab3-api-9 Started 

exit=0
$ python student-tests/test_expiry.py
..
----------------------------------------------------------------------
Ran 2 tests in 23.234s

OK

exit=0
$ python student-tests/test_dependencies.py
..
----------------------------------------------------------------------
Ran 2 tests in 8.236s

OK

exit=0
$ python tests/smoke.py --base-url http://127.0.0.1:8080
PASS: lab3 public API scenario; infrastructure and grading evidence remain separate.

exit=0
PASS: full OpenAPI 3.1 and JSON Schema validation; application NOT tested.
