Gitlab validation must allow unspecified endpoint
Gitlab config validator currently requires the gitlab endpoint to be specified, even though we support leaving it unspecified for non-enterprise installs. Fix the validator to allow this case.
This commit is contained in:
		
							parent
							
								
									b375f10da8
								
							
						
					
					
						commit
						a6486b7823
					
				
					 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', [ | ||||
|   ({}), | ||||
|   ({'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] | ||||
| 
 | ||||
|  |  | |||
|  | @ -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') | ||||
|  |  | |||
		Reference in a new issue