Merge pull request #2494 from coreos-inc/fix-gitlab-validation
Gitlab validation must allow unspecified endpoint
This commit is contained in:
commit
193b6cc94d
2 changed files with 4 additions and 8 deletions
|
@ -8,7 +8,6 @@ from util.config.validators.validate_gitlab_trigger import GitLabTriggerValidato
|
||||||
|
|
||||||
@pytest.mark.parametrize('unvalidated_config', [
|
@pytest.mark.parametrize('unvalidated_config', [
|
||||||
({}),
|
({}),
|
||||||
({'GITLAB_TRIGGER_CONFIG': {}}),
|
|
||||||
({'GITLAB_TRIGGER_CONFIG': {'GITLAB_ENDPOINT': 'foo'}}),
|
({'GITLAB_TRIGGER_CONFIG': {'GITLAB_ENDPOINT': 'foo'}}),
|
||||||
({'GITLAB_TRIGGER_CONFIG': {'GITLAB_ENDPOINT': 'http://someendpoint', 'CLIENT_ID': 'foo'}}),
|
({'GITLAB_TRIGGER_CONFIG': {'GITLAB_ENDPOINT': 'http://someendpoint', 'CLIENT_ID': 'foo'}}),
|
||||||
({'GITLAB_TRIGGER_CONFIG': {'GITLAB_ENDPOINT': 'http://someendpoint', 'CLIENT_SECRET': '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):
|
with pytest.raises(ConfigValidationException):
|
||||||
validator.validate(unvalidated_config, None, None)
|
validator.validate(unvalidated_config, None, None)
|
||||||
|
|
||||||
def test_validate_gitlab_trigger():
|
def test_validate_gitlab_enterprise_trigger():
|
||||||
url_hit = [False]
|
url_hit = [False]
|
||||||
|
|
||||||
@urlmatch(netloc=r'somegitlab', path='/oauth/token')
|
@urlmatch(netloc=r'somegitlab', path='/oauth/token')
|
||||||
|
@ -38,4 +37,3 @@ def test_validate_gitlab_trigger():
|
||||||
}, None, None)
|
}, None, None)
|
||||||
|
|
||||||
assert url_hit[0]
|
assert url_hit[0]
|
||||||
|
|
||||||
|
|
|
@ -13,9 +13,7 @@ class GitLabTriggerValidator(BaseValidator):
|
||||||
raise ConfigValidationException('Missing GitLab client id and client secret')
|
raise ConfigValidationException('Missing GitLab client id and client secret')
|
||||||
|
|
||||||
endpoint = github_config.get('GITLAB_ENDPOINT')
|
endpoint = github_config.get('GITLAB_ENDPOINT')
|
||||||
if not endpoint:
|
if endpoint:
|
||||||
raise ConfigValidationException('Missing GitLab Endpoint')
|
|
||||||
|
|
||||||
if endpoint.find('http://') != 0 and endpoint.find('https://') != 0:
|
if endpoint.find('http://') != 0 and endpoint.find('https://') != 0:
|
||||||
raise ConfigValidationException('GitLab Endpoint must start with http:// or https://')
|
raise ConfigValidationException('GitLab Endpoint must start with http:// or https://')
|
||||||
|
|
||||||
|
|
Reference in a new issue