Merge pull request #6690 from john-westcott-iv/modify_tower_cred_type_for_token

Modifying tower credential type to include an oauth otken

Reviewed-by: https://github.com/apps/softwarefactory-project-zuul
This commit is contained in:
softwarefactory-project-zuul[bot] 2020-06-24 16:55:25 +00:00 committed by GitHub
commit 2e37ffdb15
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 3 deletions

View File

@ -1103,26 +1103,36 @@ ManagedCredentialType(
}, {
'id': 'username',
'label': ugettext_noop('Username'),
'type': 'string'
'type': 'string',
'help_text': ugettext_noop('The Ansible Tower user to authenticate as.'
'This should not be set if an OAuth token is being used.')
}, {
'id': 'password',
'label': ugettext_noop('Password'),
'type': 'string',
'secret': True,
}, {
'id': 'oauth_token',
'label': ugettext_noop('OAuth Token'),
'type': 'string',
'secret': True,
'help_text': ugettext_noop('An OAuth token to use to authenticate to Tower with.'
'This should not be set if username/password are being used.')
}, {
'id': 'verify_ssl',
'label': ugettext_noop('Verify SSL'),
'type': 'boolean',
'secret': False
}],
'required': ['host', 'username', 'password'],
'required': ['host'],
},
injectors={
'env': {
'TOWER_HOST': '{{host}}',
'TOWER_USERNAME': '{{username}}',
'TOWER_PASSWORD': '{{password}}',
'TOWER_VERIFY_SSL': '{{verify_ssl}}'
'TOWER_VERIFY_SSL': '{{verify_ssl}}',
'TOWER_OAUTH_TOKEN': '{{oauth_token}}'
}
},
)

View File

@ -3,5 +3,6 @@
"TOWER_HOST": "https://foo.invalid",
"TOWER_PASSWORD": "fooo",
"TOWER_USERNAME": "fooo",
"TOWER_OAUTH_TOKEN": "",
"TOWER_VERIFY_SSL": "False"
}

View File

@ -124,6 +124,9 @@ def fake_credential_factory():
for var in var_specs.keys():
inputs[var] = generate_fake_var(var_specs[var])
if source == 'tower':
inputs.pop('oauth_token') # mutually exclusive with user/pass
return Credential.objects.create(
credential_type=ct,
inputs=inputs