mirror of
https://github.com/ansible/awx.git
synced 2026-05-11 11:27:36 -02:30
Replace Job/JT cloud/network credentials with a single M2M relation.
The following fields:
* (Job | JobTemplate).cloud_credential
* (Job | JobTemplate).network_credential
...are replaced by M2M relationships:
* Job.extra_credentials
* JobTemplate.extra_credentials
Includes support for task execution with multiple cloud credentials.
see: #5807
This commit is contained in:
@@ -316,7 +316,6 @@ def test_prefetch_jt_copy_capability(job_template, project, inventory, machine_c
|
||||
qs = JobTemplate.objects.all()
|
||||
cache_list_capabilities(qs, [{'copy': [
|
||||
'project.use', 'inventory.use', 'credential.use',
|
||||
'cloud_credential.use', 'network_credential.use'
|
||||
]}], JobTemplate, rando)
|
||||
assert qs[0].capabilities_cache == {'copy': False}
|
||||
|
||||
@@ -326,7 +325,6 @@ def test_prefetch_jt_copy_capability(job_template, project, inventory, machine_c
|
||||
|
||||
cache_list_capabilities(qs, [{'copy': [
|
||||
'project.use', 'inventory.use', 'credential.use',
|
||||
'cloud_credential.use', 'network_credential.use'
|
||||
]}], JobTemplate, rando)
|
||||
assert qs[0].capabilities_cache == {'copy': True}
|
||||
|
||||
|
||||
60
awx/main/tests/functional/models/test_job_options.py
Normal file
60
awx/main/tests/functional/models/test_job_options.py
Normal file
@@ -0,0 +1,60 @@
|
||||
import pytest
|
||||
|
||||
from django.core.exceptions import ValidationError
|
||||
from awx.main.models import Credential
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_clean_credential_with_ssh_type(credentialtype_ssh, job_template):
|
||||
credential = Credential(
|
||||
name='My Credential',
|
||||
credential_type=credentialtype_ssh
|
||||
)
|
||||
credential.save()
|
||||
|
||||
job_template.credential = credential
|
||||
job_template.full_clean()
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_clean_credential_with_invalid_type_xfail(credentialtype_aws, job_template):
|
||||
credential = Credential(
|
||||
name='My Credential',
|
||||
credential_type=credentialtype_aws
|
||||
)
|
||||
credential.save()
|
||||
|
||||
with pytest.raises(ValidationError):
|
||||
job_template.credential = credential
|
||||
job_template.full_clean()
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_clean_credential_with_custom_types(credentialtype_aws, credentialtype_net, job_template):
|
||||
aws = Credential(
|
||||
name='AWS Credential',
|
||||
credential_type=credentialtype_aws
|
||||
)
|
||||
aws.save()
|
||||
net = Credential(
|
||||
name='Net Credential',
|
||||
credential_type=credentialtype_net
|
||||
)
|
||||
net.save()
|
||||
|
||||
job_template.extra_credentials.add(aws)
|
||||
job_template.extra_credentials.add(net)
|
||||
job_template.full_clean()
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_clean_credential_with_custom_types_xfail(credentialtype_ssh, job_template):
|
||||
ssh = Credential(
|
||||
name='SSH Credential',
|
||||
credential_type=credentialtype_ssh
|
||||
)
|
||||
ssh.save()
|
||||
|
||||
with pytest.raises(ValidationError):
|
||||
job_template.extra_credentials.add(ssh)
|
||||
job_template.full_clean()
|
||||
Reference in New Issue
Block a user