test(photon): stub token validation in setup tests to avoid network

Maintainer follow-up: _cmd_setup now validates existing tokens (#72763
salvage); the pre-existing setup tests monkeypatch a stored token, so
without stubbing check_photon_token_valid they'd hit the real dashboard
API and hang.
This commit is contained in:
Teknium 2026-07-28 11:39:10 -07:00
parent 1887c4e820
commit 893c99bca1

View file

@ -73,6 +73,8 @@ def test_env_enablement_home_channel_defaults_name(monkeypatch: pytest.MonkeyPat
def test_setup_hint_uses_gateway_service_command(monkeypatch: pytest.MonkeyPatch, capsys) -> None:
monkeypatch.setattr(cli.photon_auth, "load_photon_token", lambda: "token")
# Token validation (added for #72763) would otherwise hit the network.
monkeypatch.setattr(cli.photon_auth, "check_photon_token_valid", lambda token: True)
# The dashboard id *is* the Spectrum project id (ids unified), so setup no
# longer enables Spectrum or fetches a separate spectrumProjectId — it
# reuses this id directly.
@ -128,6 +130,8 @@ def test_setup_reuses_valid_existing_secret(
return "new_secret"
monkeypatch.setattr(cli.photon_auth, "load_photon_token", lambda: "token")
# Token validation (added for #72763) would otherwise hit the network.
monkeypatch.setattr(cli.photon_auth, "check_photon_token_valid", lambda token: True)
monkeypatch.setattr(cli.photon_auth, "load_dashboard_project_id", lambda: "dashboard")
monkeypatch.setattr(
cli.photon_auth,
@ -173,6 +177,8 @@ def test_setup_regenerates_when_existing_secret_invalid(
) -> None:
"""When existing credentials are invalid, setup must regenerate."""
monkeypatch.setattr(cli.photon_auth, "load_photon_token", lambda: "token")
# Token validation (added for #72763) would otherwise hit the network.
monkeypatch.setattr(cli.photon_auth, "check_photon_token_valid", lambda token: True)
monkeypatch.setattr(cli.photon_auth, "load_dashboard_project_id", lambda: "dashboard")
monkeypatch.setattr(
cli.photon_auth,