mirror of
https://github.com/ansible/awx.git
synced 2026-05-07 09:27:36 -02:30
Merge pull request #6468 from ryanpetrello/fix-6464
add a boolean `authorize` field for the Network Credential Type
This commit is contained in:
@@ -701,6 +701,10 @@ def net(cls):
|
|||||||
'label': 'Private Key Passphrase',
|
'label': 'Private Key Passphrase',
|
||||||
'type': 'string',
|
'type': 'string',
|
||||||
'secret': True,
|
'secret': True,
|
||||||
|
}, {
|
||||||
|
'id': 'authorize',
|
||||||
|
'label': 'Authorize',
|
||||||
|
'type': 'boolean',
|
||||||
}, {
|
}, {
|
||||||
'id': 'authorize_password',
|
'id': 'authorize_password',
|
||||||
'label': 'Authorize Password',
|
'label': 'Authorize Password',
|
||||||
|
|||||||
@@ -798,6 +798,7 @@ def test_vault_create_ok(post, organization, admin, version, params):
|
|||||||
'password': 'some_password',
|
'password': 'some_password',
|
||||||
'ssh_key_data': 'some_key_data',
|
'ssh_key_data': 'some_key_data',
|
||||||
'ssh_key_unlock': 'some_key_unlock',
|
'ssh_key_unlock': 'some_key_unlock',
|
||||||
|
'authorize': True,
|
||||||
'authorize_password': 'some_authorize_password',
|
'authorize_password': 'some_authorize_password',
|
||||||
}],
|
}],
|
||||||
['v2', {
|
['v2', {
|
||||||
@@ -808,6 +809,7 @@ def test_vault_create_ok(post, organization, admin, version, params):
|
|||||||
'password': 'some_password',
|
'password': 'some_password',
|
||||||
'ssh_key_data': 'some_key_data',
|
'ssh_key_data': 'some_key_data',
|
||||||
'ssh_key_unlock': 'some_key_unlock',
|
'ssh_key_unlock': 'some_key_unlock',
|
||||||
|
'authorize': True,
|
||||||
'authorize_password': 'some_authorize_password',
|
'authorize_password': 'some_authorize_password',
|
||||||
}
|
}
|
||||||
}]
|
}]
|
||||||
@@ -830,6 +832,7 @@ def test_net_create_ok(post, organization, admin, version, params):
|
|||||||
assert decrypt_field(cred, 'ssh_key_data') == 'some_key_data'
|
assert decrypt_field(cred, 'ssh_key_data') == 'some_key_data'
|
||||||
assert decrypt_field(cred, 'ssh_key_unlock') == 'some_key_unlock'
|
assert decrypt_field(cred, 'ssh_key_unlock') == 'some_key_unlock'
|
||||||
assert decrypt_field(cred, 'authorize_password') == 'some_authorize_password'
|
assert decrypt_field(cred, 'authorize_password') == 'some_authorize_password'
|
||||||
|
assert cred.inputs['authorize'] is True
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
|
|||||||
@@ -171,6 +171,16 @@ def test_credential_creation(organization_factory):
|
|||||||
@pytest.mark.parametrize('inputs', [
|
@pytest.mark.parametrize('inputs', [
|
||||||
['must-be-a-dict'],
|
['must-be-a-dict'],
|
||||||
{'user': 'wrong-key'},
|
{'user': 'wrong-key'},
|
||||||
|
{'username': 1},
|
||||||
|
{'username': 1.5},
|
||||||
|
{'username': ['a', 'b', 'c']},
|
||||||
|
{'username': {'a': 'b'}},
|
||||||
|
{'username': False},
|
||||||
|
{'flag': 1},
|
||||||
|
{'flag': 1.5},
|
||||||
|
{'flag': ['a', 'b', 'c']},
|
||||||
|
{'flag': {'a': 'b'}},
|
||||||
|
{'flag': 'some-string'},
|
||||||
])
|
])
|
||||||
def test_credential_creation_validation_failure(organization_factory, inputs):
|
def test_credential_creation_validation_failure(organization_factory, inputs):
|
||||||
org = organization_factory('test').organization
|
org = organization_factory('test').organization
|
||||||
@@ -183,16 +193,21 @@ def test_credential_creation_validation_failure(organization_factory, inputs):
|
|||||||
'id': 'username',
|
'id': 'username',
|
||||||
'label': 'Username for SomeCloud',
|
'label': 'Username for SomeCloud',
|
||||||
'type': 'string'
|
'type': 'string'
|
||||||
|
},{
|
||||||
|
'id': 'flag',
|
||||||
|
'label': 'Some Boolean Flag',
|
||||||
|
'type': 'boolean'
|
||||||
}]
|
}]
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
type_.save()
|
type_.save()
|
||||||
|
|
||||||
with pytest.raises(ValidationError):
|
with pytest.raises(Exception) as e:
|
||||||
cred = Credential(credential_type=type_, name="Bob's Credential",
|
cred = Credential(credential_type=type_, name="Bob's Credential",
|
||||||
inputs=inputs, organization=org)
|
inputs=inputs, organization=org)
|
||||||
cred.save()
|
cred.save()
|
||||||
cred.full_clean()
|
cred.full_clean()
|
||||||
|
assert e.type in (ValidationError, serializers.ValidationError)
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.django_db
|
@pytest.mark.django_db
|
||||||
|
|||||||
Reference in New Issue
Block a user