mirror of
https://github.com/quay/quay.git
synced 2026-01-26 06:21:37 +03:00
sso: Add test for RHSSO OAuth service (PROJQUAY-2056) (#1317)
- Add test for RHSSOOAuthService class
This commit is contained in:
@@ -28,7 +28,7 @@ class OAuthLoginManager(object):
|
||||
if custom_service.login_enabled(config):
|
||||
self.services.append(custom_service)
|
||||
else:
|
||||
prefix = key.rstrip("_LOGIN_CONFIG").lower()
|
||||
prefix = key[: -len("_LOGIN_CONFIG")].lower()
|
||||
if prefix in PREFIX_BLACKLIST:
|
||||
raise Exception("Cannot use reserved config name %s" % key)
|
||||
if prefix == "rhsso":
|
||||
|
||||
@@ -32,7 +32,9 @@ class RHSSOOAuthService(OIDCLoginService):
|
||||
)
|
||||
logger.debug("Got result from export compliance service: " + result.json())
|
||||
if result.status_code != 200:
|
||||
raise OAuthLoginException(str(result.json()["errors"]))
|
||||
raise OAuthLoginException(str(result.json()))
|
||||
if result.json()["result"] != "OK":
|
||||
raise OAuthLoginException(str(result.json()["description"]))
|
||||
except Exception as e:
|
||||
raise OAuthLoginException(str(e))
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ from oauth.loginmanager import OAuthLoginManager
|
||||
from oauth.services.github import GithubOAuthService
|
||||
from oauth.services.google import GoogleOAuthService
|
||||
from oauth.oidc import OIDCLoginService
|
||||
from oauth.services.rhsso import RHSSOOAuthService
|
||||
|
||||
|
||||
def test_login_manager_github():
|
||||
@@ -66,3 +67,11 @@ def test_multiple_oidc():
|
||||
assert len(loginmanager.services) == 2
|
||||
assert isinstance(loginmanager.services[0], OIDCLoginService)
|
||||
assert isinstance(loginmanager.services[1], OIDCLoginService)
|
||||
|
||||
|
||||
def test_rhsso():
|
||||
config = {"RHSSO_LOGIN_CONFIG": {}}
|
||||
|
||||
loginmanager = OAuthLoginManager(config)
|
||||
assert len(loginmanager.services) == 1
|
||||
assert isinstance(loginmanager.services[0], RHSSOOAuthService)
|
||||
|
||||
Reference in New Issue
Block a user