The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
test(gateway): cover native-HTTP ticket expiry with a patched clock, not a 31 s sleep
Tekniume4795d672315
diff --git a/tests/gateway/test_native_http_auth.py b/tests/gateway/test_native_http_auth.pyindex a4b13f22639..571ed413a77 100644--- a/tests/gateway/test_native_http_auth.py+++ b/tests/gateway/test_native_http_auth.py@@ -141,9 +141,9 @@ def test_native_http_grants_are_single_use_and_bound_to_daemon(tmp_path):query_ticket = ticket(home, descriptor)assert client.get('/api/config', params={'ticket': query_ticket}).status_code == 401assert client.get('/api/config', headers={'Cookie': 'X-Hermes-Gateway-Ticket=' + query_ticket}).status_code == 401- expired = ticket(home, descriptor)- time.sleep(31) # health: allow HX013 -- the real 30 s production ticket TTL must elapse (no patched clock or shortened grant)- assert client.get('/api/config', headers=headers(expired)).status_code == 401+ # Expiry is TicketStore.redeem's ``expires <= monotonic()`` rule, which the native-HTTP gate+ # maps to 401 like every other redeem refusal: covered at the exact 30 s boundary with a+ # patched clock in test_runtime_bootstrap, not by a 31 s wall-clock wait in the default lane.stale = ticket(home, descriptor)old_instance = descriptor['instance_id']assert 'ticket' not in json.dumps(control(home, 'identify')).lower()@@ -153,7 +153,7 @@ def test_native_http_grants_are_single_use_and_bound_to_daemon(tmp_path):assert client.get('/api/config', headers=headers(stale)).status_code == 401assert client.get('/api/config', headers=headers(ticket(home, descriptor))).status_code == 200print(json.dumps({'native_http': 'ordinary daemon config and profiles HTTP passed',- 'replay_expiry_restart_purpose_origin_profile': 'rejected'}))+ 'replay_restart_purpose_origin_profile': 'rejected'}))@pytest.mark.asynciodiff --git a/tests/gateway/test_runtime_bootstrap.py b/tests/gateway/test_runtime_bootstrap.pyindex bac7fa412c5..a13d9793a5d 100644--- a/tests/gateway/test_runtime_bootstrap.py+++ b/tests/gateway/test_runtime_bootstrap.py@@ -64,9 +64,12 @@ def test_ticket_atomic_single_use_profile_purpose_expiry_and_capacity(monkeypatcgrants = list(pool.map(consume, range(8)))assert sum(g is not None for g in grants) == 1expired = store.mint(profile_id='a', subject='uid:1', purpose='interactive')+ native = store.mint(profile_id='a', subject='uid:1', purpose='native-http')clock[0] = 30with pytest.raises(PermissionError):store.redeem(expired, profile_id='a', purpose='interactive')+ with pytest.raises(PermissionError, match='expired'): # the native-HTTP gate's redeem (profile_id=None)+ store.redeem(native, profile_id=None, purpose='native-http')exposure = store.mint(profile_id='a', subject='uid:1', purpose='exposure')assert store.redeem(exposure, profile_id='a', purpose='exposure')['capabilities'] == frozenset({'transport:delegate'})for _ in range(store.MAX_ENTRIES):