Fix missed tests and revert conftest change (breaks docker build)
This commit is contained in:
parent
cf6033b423
commit
f5dbc350f8
5 changed files with 20 additions and 19 deletions
|
@ -20,3 +20,4 @@ coverage
|
|||
.cache
|
||||
.npm-debug.log
|
||||
test/__pycache__
|
||||
__pycache__
|
||||
|
|
12
conftest.py
12
conftest.py
|
@ -1,12 +0,0 @@
|
|||
import pytest
|
||||
|
||||
import requests
|
||||
|
||||
@pytest.fixture()
|
||||
def http_client():
|
||||
sess = requests.Session()
|
||||
adapter = requests.adapters.HTTPAdapter(pool_connections=100,
|
||||
pool_maxsize=100)
|
||||
sess.mount('http://', adapter)
|
||||
sess.mount('https://', adapter)
|
||||
return sess
|
|
@ -6,6 +6,7 @@ import urlparse
|
|||
|
||||
import jwt
|
||||
import pytest
|
||||
import requests
|
||||
|
||||
from httmock import urlmatch, HTTMock
|
||||
from Crypto.PublicKey import RSA
|
||||
|
@ -13,6 +14,15 @@ from jwkest.jwk import RSAKey
|
|||
|
||||
from oauth.oidc import OIDCLoginService, OAuthLoginException
|
||||
|
||||
@pytest.fixture()
|
||||
def http_client():
|
||||
sess = requests.Session()
|
||||
adapter = requests.adapters.HTTPAdapter(pool_connections=100,
|
||||
pool_maxsize=100)
|
||||
sess.mount('http://', adapter)
|
||||
sess.mount('https://', adapter)
|
||||
return sess
|
||||
|
||||
@pytest.fixture(params=[True, False])
|
||||
def app_config(http_client, request):
|
||||
return {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import unittest
|
||||
|
||||
from util.config.oauth import GithubOAuthConfig
|
||||
from oauth.services.github import GithubOAuthService
|
||||
|
||||
class TestGithub(unittest.TestCase):
|
||||
def test_basic_enterprise_config(self):
|
||||
|
@ -12,7 +12,7 @@ class TestGithub(unittest.TestCase):
|
|||
}
|
||||
}
|
||||
|
||||
github_trigger = GithubOAuthConfig(config, 'GITHUB_TRIGGER_CONFIG')
|
||||
github_trigger = GithubOAuthService(config, 'GITHUB_TRIGGER_CONFIG')
|
||||
self.assertTrue(github_trigger.is_enterprise())
|
||||
self.assertEquals('https://github.somedomain.com/login/oauth/authorize?', github_trigger.authorize_endpoint())
|
||||
self.assertEquals('https://github.somedomain.com/login/oauth/access_token', github_trigger.token_endpoint())
|
||||
|
@ -33,7 +33,7 @@ class TestGithub(unittest.TestCase):
|
|||
}
|
||||
}
|
||||
|
||||
github_trigger = GithubOAuthConfig(config, 'GITHUB_TRIGGER_CONFIG')
|
||||
github_trigger = GithubOAuthService(config, 'GITHUB_TRIGGER_CONFIG')
|
||||
self.assertTrue(github_trigger.is_enterprise())
|
||||
self.assertEquals('https://github.somedomain.com/login/oauth/authorize?', github_trigger.authorize_endpoint())
|
||||
self.assertEquals('https://github.somedomain.com/login/oauth/access_token', github_trigger.token_endpoint())
|
||||
|
|
|
@ -22,7 +22,9 @@ from data.users.externaljwt import ExternalJWTAuthN
|
|||
from data.users.externalldap import LDAPConnection, LDAPUsers
|
||||
from data.users.keystone import get_keystone_users
|
||||
from storage import get_storage_driver
|
||||
from util.config.oauth import GoogleOAuthConfig, GithubOAuthConfig, GitLabOAuthConfig
|
||||
from oauth.services.github import GithubOAuthService
|
||||
from oauth.services.google import GoogleOAuthService
|
||||
from oauth.services.gitlab import GitLabOAuthService
|
||||
from util.secscan.api import SecurityScannerAPI
|
||||
from util.registry.torrent import torrent_jwt
|
||||
from util.security.signing import SIGNING_ENGINES
|
||||
|
@ -159,7 +161,7 @@ def _validate_gitlab(config, user_obj, _):
|
|||
raise ConfigValidationException('Missing Client Secret')
|
||||
|
||||
client = app.config['HTTPCLIENT']
|
||||
oauth = GitLabOAuthConfig(config, 'GITLAB_TRIGGER_CONFIG')
|
||||
oauth = GitLabOAuthService(config, 'GITLAB_TRIGGER_CONFIG')
|
||||
result = oauth.validate_client_id_and_secret(client, app.config)
|
||||
if not result:
|
||||
raise ConfigValidationException('Invalid client id or client secret')
|
||||
|
@ -193,7 +195,7 @@ def _validate_github_with_key(config_key, config):
|
|||
'organization')
|
||||
|
||||
client = app.config['HTTPCLIENT']
|
||||
oauth = GithubOAuthConfig(config, config_key)
|
||||
oauth = GithubOAuthService(config, config_key)
|
||||
result = oauth.validate_client_id_and_secret(client, app.config)
|
||||
if not result:
|
||||
raise ConfigValidationException('Invalid client id or client secret')
|
||||
|
@ -239,7 +241,7 @@ def _validate_google_login(config, user_obj, _):
|
|||
raise ConfigValidationException('Missing Client Secret')
|
||||
|
||||
client = app.config['HTTPCLIENT']
|
||||
oauth = GoogleOAuthConfig(config, 'GOOGLE_LOGIN_CONFIG')
|
||||
oauth = GoogleOAuthService(config, 'GOOGLE_LOGIN_CONFIG')
|
||||
result = oauth.validate_client_id_and_secret(client, app.config)
|
||||
if not result:
|
||||
raise ConfigValidationException('Invalid client id or client secret')
|
||||
|
|
Reference in a new issue