initial import for Open Source 🎉
This commit is contained in:
parent
1898c361f3
commit
9c0dd3b722
2048 changed files with 218743 additions and 0 deletions
62
oauth/test/test_loginmanager.py
Normal file
62
oauth/test/test_loginmanager.py
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
from oauth.loginmanager import OAuthLoginManager
|
||||
from oauth.services.github import GithubOAuthService
|
||||
from oauth.services.google import GoogleOAuthService
|
||||
from oauth.oidc import OIDCLoginService
|
||||
|
||||
def test_login_manager_github():
|
||||
config = {
|
||||
'FEATURE_GITHUB_LOGIN': True,
|
||||
'GITHUB_LOGIN_CONFIG': {},
|
||||
}
|
||||
|
||||
loginmanager = OAuthLoginManager(config)
|
||||
assert len(loginmanager.services) == 1
|
||||
assert isinstance(loginmanager.services[0], GithubOAuthService)
|
||||
|
||||
def test_github_disabled():
|
||||
config = {
|
||||
'GITHUB_LOGIN_CONFIG': {},
|
||||
}
|
||||
|
||||
loginmanager = OAuthLoginManager(config)
|
||||
assert len(loginmanager.services) == 0
|
||||
|
||||
def test_login_manager_google():
|
||||
config = {
|
||||
'FEATURE_GOOGLE_LOGIN': True,
|
||||
'GOOGLE_LOGIN_CONFIG': {},
|
||||
}
|
||||
|
||||
loginmanager = OAuthLoginManager(config)
|
||||
assert len(loginmanager.services) == 1
|
||||
assert isinstance(loginmanager.services[0], GoogleOAuthService)
|
||||
|
||||
def test_google_disabled():
|
||||
config = {
|
||||
'GOOGLE_LOGIN_CONFIG': {},
|
||||
}
|
||||
|
||||
loginmanager = OAuthLoginManager(config)
|
||||
assert len(loginmanager.services) == 0
|
||||
|
||||
def test_oidc():
|
||||
config = {
|
||||
'SOMECOOL_LOGIN_CONFIG': {},
|
||||
'HTTPCLIENT': None,
|
||||
}
|
||||
|
||||
loginmanager = OAuthLoginManager(config)
|
||||
assert len(loginmanager.services) == 1
|
||||
assert isinstance(loginmanager.services[0], OIDCLoginService)
|
||||
|
||||
def test_multiple_oidc():
|
||||
config = {
|
||||
'SOMECOOL_LOGIN_CONFIG': {},
|
||||
'ANOTHER_LOGIN_CONFIG': {},
|
||||
'HTTPCLIENT': None,
|
||||
}
|
||||
|
||||
loginmanager = OAuthLoginManager(config)
|
||||
assert len(loginmanager.services) == 2
|
||||
assert isinstance(loginmanager.services[0], OIDCLoginService)
|
||||
assert isinstance(loginmanager.services[1], OIDCLoginService)
|
||||
Reference in a new issue