Merge pull request #2494 from coreos-inc/fix-gitlab-validation

Gitlab validation must allow unspecified endpoint
This commit is contained in:
josephschorr 2017-03-30 12:59:21 -04:00 committed by GitHub
commit 193b6cc94d
2 changed files with 4 additions and 8 deletions

View file

@ -8,7 +8,6 @@ from util.config.validators.validate_gitlab_trigger import GitLabTriggerValidato
@pytest.mark.parametrize('unvalidated_config', [
({}),
({'GITLAB_TRIGGER_CONFIG': {}}),
({'GITLAB_TRIGGER_CONFIG': {'GITLAB_ENDPOINT': 'foo'}}),
({'GITLAB_TRIGGER_CONFIG': {'GITLAB_ENDPOINT': 'http://someendpoint', 'CLIENT_ID': 'foo'}}),
({'GITLAB_TRIGGER_CONFIG': {'GITLAB_ENDPOINT': 'http://someendpoint', 'CLIENT_SECRET': 'foo'}}),
@ -19,7 +18,7 @@ def test_validate_invalid_gitlab_trigger_config(unvalidated_config):
with pytest.raises(ConfigValidationException):
validator.validate(unvalidated_config, None, None)
def test_validate_gitlab_trigger():
def test_validate_gitlab_enterprise_trigger():
url_hit = [False]
@urlmatch(netloc=r'somegitlab', path='/oauth/token')
@ -38,4 +37,3 @@ def test_validate_gitlab_trigger():
}, None, None)
assert url_hit[0]

View file

@ -13,11 +13,9 @@ class GitLabTriggerValidator(BaseValidator):
raise ConfigValidationException('Missing GitLab client id and client secret')
endpoint = github_config.get('GITLAB_ENDPOINT')
if not endpoint:
raise ConfigValidationException('Missing GitLab Endpoint')
if endpoint.find('http://') != 0 and endpoint.find('https://') != 0:
raise ConfigValidationException('GitLab Endpoint must start with http:// or https://')
if endpoint:
if endpoint.find('http://') != 0 and endpoint.find('https://') != 0:
raise ConfigValidationException('GitLab Endpoint must start with http:// or https://')
if not github_config.get('CLIENT_ID'):
raise ConfigValidationException('Missing Client ID')