test_oidc_config.py 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. import ssl
  2. from gpustack.config.config import get_openid_configuration
  3. class _FakeResponse:
  4. def raise_for_status(self):
  5. return None
  6. def json(self):
  7. return {"issuer": "https://issuer.example.com"}
  8. def test_get_openid_configuration_uses_system_trust_store(monkeypatch):
  9. captured = {}
  10. class _FakeClient:
  11. def __init__(self, **kwargs):
  12. captured.update(kwargs)
  13. def __enter__(self):
  14. return self
  15. def __exit__(self, exc_type, exc, tb):
  16. return None
  17. def get(self, url):
  18. captured["url"] = url
  19. return _FakeResponse()
  20. monkeypatch.setattr("gpustack.config.config.httpx.Client", _FakeClient)
  21. monkeypatch.setattr(
  22. "gpustack.config.config.use_proxy_env_for_url", lambda url: False
  23. )
  24. result = get_openid_configuration("https://issuer.example.com")
  25. assert result == {"issuer": "https://issuer.example.com"}
  26. assert (
  27. captured["url"] == "https://issuer.example.com/.well-known/openid-configuration"
  28. )
  29. assert captured["timeout"] == 10
  30. assert captured["trust_env"] is False
  31. assert isinstance(captured["verify"], ssl.SSLContext)