feat(dsh): harden health decisions and issue transport
This commit is contained in:
1 parent
736b582bc1
commit
eee4e6bde9
18 files changed
+592
-11
No files matched your search
@@ -0,0 +1,42 @@
|
||||
import json
|
||||
from pathlib import Path
|
||||
|
||||
from dx_productivity.dsh.health import HealthStore
|
||||
|
||||
|
||||
class _Service:
|
||||
_workers = set()
|
||||
|
||||
|
||||
def test_health_snapshot_reports_unconfigured_provider_and_local_stores(tmp_path, monkeypatch):
|
||||
monkeypatch.delenv('DSH_API_BASE', raising=False)
|
||||
value = HealthStore(tmp_path).snapshot(_Service())
|
||||
checks = {row['name']: row for row in value['checks']}
|
||||
assert value['status'] == 'degraded'
|
||||
assert checks['provider']['status'] == 'degraded'
|
||||
assert checks['provider']['code'] == 'provider_unconfigured'
|
||||
assert checks['stores']['status'] == 'ok'
|
||||
|
||||
|
||||
def test_health_snapshot_marks_active_worker_and_static_issue_token(tmp_path, monkeypatch):
|
||||
class Busy(_Service):
|
||||
_workers = {object()}
|
||||
|
||||
provider = tmp_path / 'dsh' / 'provider.json'
|
||||
provider.parent.mkdir(parents=True)
|
||||
provider.write_text(json.dumps({'base_url': 'https://example.test/v1', 'default_model': 'm'}), encoding='utf8')
|
||||
monkeypatch.setattr('dx_productivity.dsh.health.load_bootstrap', lambda: {'token': 'secret', 'username': 'u', 'scopes': ['write:issue'], 'server': 'https://git.test', 'repository': 'o/r'})
|
||||
value = HealthStore(tmp_path).snapshot(Busy())
|
||||
checks = {row['name']: row for row in value['checks']}
|
||||
assert checks['execution']['status'] == 'degraded'
|
||||
assert checks['execution']['code'] == 'worker_active'
|
||||
assert checks['issue_credentials']['code'] == 'credential_rotation_required'
|
||||
assert 'secret' not in json.dumps(value)
|
||||
|
||||
|
||||
def test_health_snapshot_reports_stale_ticket_cache(tmp_path):
|
||||
cache = tmp_path / 'dsh' / 'ticket-cache'
|
||||
cache.mkdir(parents=True)
|
||||
value = HealthStore(tmp_path).snapshot(_Service())
|
||||
checks = {row['name']: row for row in value['checks']}
|
||||
assert checks['tickets']['status'] == 'ok'
|
||||
Reference in new issue
Block a user