mirror of
https://github.com/ansible/awx.git
synced 2026-05-19 14:57:39 -02:30
Fixes in testing and parameter processing
This commit is contained in:
@@ -143,7 +143,16 @@ def main():
|
|||||||
)
|
)
|
||||||
|
|
||||||
# Create a module for ourselves
|
# Create a module for ourselves
|
||||||
module = TowerModule(argument_spec=argument_spec)
|
module = TowerModule(
|
||||||
|
argument_spec=argument_spec,
|
||||||
|
mutually_exclusive=[
|
||||||
|
('existing_token', 'existing_token_id'),
|
||||||
|
],
|
||||||
|
# If we are state absent make sure one of existing_token or existing_token_id are present
|
||||||
|
required_if=[
|
||||||
|
[ 'state', 'absent', ('existing_token', 'existing_token_id'), True,],
|
||||||
|
],
|
||||||
|
)
|
||||||
|
|
||||||
# Extract our parameters
|
# Extract our parameters
|
||||||
description = module.params.get('description')
|
description = module.params.get('description')
|
||||||
@@ -155,8 +164,6 @@ def main():
|
|||||||
|
|
||||||
if state == 'absent':
|
if state == 'absent':
|
||||||
if not existing_token:
|
if not existing_token:
|
||||||
if not existing_token_id:
|
|
||||||
module.fail_json(msg='When deleting a token you specify either the parameter existing_token or existing_token_id')
|
|
||||||
existing_token = module.get_one('tokens', **{
|
existing_token = module.get_one('tokens', **{
|
||||||
'data': {
|
'data': {
|
||||||
'id': existing_token_id,
|
'id': existing_token_id,
|
||||||
|
|||||||
@@ -22,7 +22,8 @@ def test_create_token(run_module, admin_user):
|
|||||||
}
|
}
|
||||||
|
|
||||||
result = run_module('tower_token', module_args, admin_user)
|
result = run_module('tower_token', module_args, admin_user)
|
||||||
assert result, result.get('changed')
|
assert result.get('changed'), result
|
||||||
|
|
||||||
tokens = OAuth2AccessToken.objects.filter(description='barfoo')
|
tokens = OAuth2AccessToken.objects.filter(description='barfoo')
|
||||||
assert len(tokens) == 1, tokens[0].description == 'barfoo'
|
assert len(tokens) == 1, 'Rokens with description of barfoo != 0: {0}'.format(len(tokens))
|
||||||
|
assert tokens[0].scope == 'read', 'Token was not given read access'
|
||||||
|
|||||||
@@ -36,7 +36,22 @@
|
|||||||
- assert:
|
- assert:
|
||||||
that:
|
that:
|
||||||
- results is failed
|
- results is failed
|
||||||
- '"When deleting a token you specify either the parameter existing_token or existing_token_id" == results.msg'
|
# We don't assert a message here because it handled by ansible
|
||||||
|
|
||||||
|
- name: Try to delete a token with both existing_token or existing_token_id
|
||||||
|
tower_token:
|
||||||
|
existing_token:
|
||||||
|
id: 1234
|
||||||
|
existing_token_id: 1234
|
||||||
|
state: absent
|
||||||
|
register: results
|
||||||
|
ignore_errors: True
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- results is failed
|
||||||
|
# We don't assert a message here because it handled by ansible
|
||||||
|
|
||||||
|
|
||||||
- block:
|
- block:
|
||||||
- name: Create a Token
|
- name: Create a Token
|
||||||
|
|||||||
Reference in New Issue
Block a user