fix: 临时绕开证书过期问题
This commit is contained in:
1 parent
aed076046a
commit
ebd27ccfa7
3 files changed
+76
-4
No files matched your search
@@ -135,6 +135,33 @@ def test_casdoor_config_repr_does_not_expose_secret(app):
|
||||
assert 'top-secret-value' not in repr(config)
|
||||
|
||||
|
||||
def test_casdoor_server_endpoints_follow_base_url_when_issuer_uses_expired_https():
|
||||
"""公网 HTTPS 证书不可用时,换票和 userinfo 改走 CASDOOR_BASE_URL,浏览器授权地址保持原域名。"""
|
||||
http = FakeHttp()
|
||||
http.get = lambda url, **kwargs: FakeResponse({
|
||||
'issuer': 'https://auth.example.com',
|
||||
'authorization_endpoint': 'https://auth.example.com/login/oauth/authorize',
|
||||
'token_endpoint': 'https://auth.example.com/api/login/oauth/access_token',
|
||||
'userinfo_endpoint': 'https://auth.example.com/api/userinfo',
|
||||
'jwks_uri': 'https://auth.example.com/.well-known/jwks',
|
||||
}) if url.endswith('/.well-known/openid-configuration') else FakeResponse({})
|
||||
client = CasdoorClient(CasdoorConfig(
|
||||
base_url='http://192.168.100.230:8870',
|
||||
client_id='peer-client',
|
||||
client_secret='peer-secret',
|
||||
issuer='https://auth.example.com',
|
||||
), http_session=http)
|
||||
metadata = client.oidc_metadata()
|
||||
# 后端换票不能再访问过期证书上的 HTTPS 域名。
|
||||
assert metadata['token_endpoint'] == 'http://192.168.100.230:8870/api/login/oauth/access_token'
|
||||
assert metadata['userinfo_endpoint'] == 'http://192.168.100.230:8870/api/userinfo'
|
||||
assert metadata['jwks_uri'] == 'http://192.168.100.230:8870/.well-known/jwks'
|
||||
# 浏览器授权仍使用 discovery 原地址。
|
||||
assert metadata['authorization_endpoint'] == 'https://auth.example.com/login/oauth/authorize'
|
||||
client.password_login('alice', 'user-password')
|
||||
assert http.posts[0][0] == 'http://192.168.100.230:8870/api/login/oauth/access_token'
|
||||
|
||||
|
||||
def test_casdoor_password_client_request_is_framework_independent():
|
||||
"""公共客户端按配置发送 password grant,不依赖 HXOPS User 或数据库。"""
|
||||
http = FakeHttp()
|
||||
|
||||
Reference in new issue
Block a user