forked from luopingyi/xc_agent_platform_demo
fix missing/invalid_token: bake xc_token file + XC_TOKEN_FILE first; dual ENV; token_probe diagnostics (63 tests)
This commit is contained in:
@@ -76,10 +76,19 @@ class TestLiveCycle(unittest.TestCase):
|
||||
self.assertNotIn('do not log', self.logs.getvalue())
|
||||
|
||||
def test_missing_token_real_reader(self):
|
||||
with patch.dict(os.environ, {'XC_TOKEN': ''}):
|
||||
with patch.dict(os.environ, {'STRATEGY_ID': 'sid'}, clear=True):
|
||||
run_cycle([candidate('a')], self.client)
|
||||
self.client.submit.assert_not_called()
|
||||
self.assertIn('missing/invalid_token', self.logs.getvalue())
|
||||
self.assertIn('[live] token_probe EXTERNAL_SERVICE_TOKEN=absent XC_TOKEN_FILE=absent XC_TOKEN=absent MODELHUB_XC_TOKEN=absent', self.logs.getvalue())
|
||||
self.assertNotIn('[live] token source=', self.logs.getvalue())
|
||||
|
||||
def test_rejected_token_probe_does_not_leak(self):
|
||||
with patch.dict(os.environ, {'XC_TOKEN': '<private-secret-fragment>'}):
|
||||
self.cycle()
|
||||
self.client.submit.assert_not_called()
|
||||
self.assertIn('XC_TOKEN=rejected', self.logs.getvalue())
|
||||
self.assertNotIn('private-secret', self.logs.getvalue())
|
||||
|
||||
def test_worker_waits_and_stops(self):
|
||||
from src.server import _live_worker
|
||||
|
||||
Reference in New Issue
Block a user