mirror of
https://github.com/ansible/awx.git
synced 2026-01-24 07:51:23 -03:30
Fixes in testing and parameter processing
This commit is contained in:
parent
1f17e02fe9
commit
3b60529488
@ -143,7 +143,16 @@ def main():
|
||||
)
|
||||
|
||||
# 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
|
||||
description = module.params.get('description')
|
||||
@ -155,8 +164,6 @@ def main():
|
||||
|
||||
if state == 'absent':
|
||||
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', **{
|
||||
'data': {
|
||||
'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)
|
||||
assert result, result.get('changed')
|
||||
assert result.get('changed'), result
|
||||
|
||||
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:
|
||||
that:
|
||||
- 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:
|
||||
- name: Create a Token
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user