mirror of
https://github.com/ansible/awx.git
synced 2026-01-11 10:00:01 -03:30
fix a few tests caused by fallout between 3.2.2 bugs and 3.3 multicred
This commit is contained in:
parent
d35bfafcf5
commit
ea4cd99003
@ -2181,8 +2181,8 @@ class CredentialSerializer(BaseSerializer):
|
||||
'insights_inventories',
|
||||
'inventorysources',
|
||||
'inventoryupdates',
|
||||
'jobs',
|
||||
'jobtemplates',
|
||||
'unifiedjobs',
|
||||
'unifiedjobtemplates',
|
||||
'projects',
|
||||
'projectupdates',
|
||||
'workflowjobnodes'
|
||||
|
||||
@ -54,7 +54,7 @@ def test_ctint_activity_stream(monkeypatch, get, user, settings):
|
||||
Setting.objects.create(key="FOO", value="bar")
|
||||
settings.ACTIVITY_STREAM_ENABLED = True
|
||||
u = user('admin', True)
|
||||
activity_stream = ActivityStream.objects.filter(setting={'name': 'FOO', 'category': None}).latest('pk')
|
||||
activity_stream = ActivityStream.objects.filter(setting__icontains="FOO").latest('pk')
|
||||
activity_stream.actor = u
|
||||
activity_stream.save()
|
||||
|
||||
|
||||
@ -1427,8 +1427,8 @@ def test_field_removal(put, organization, admin, credentialtype_ssh, version, pa
|
||||
['ad_hoc_commands', AdHocCommand()],
|
||||
['insights_inventories', Inventory()],
|
||||
['inventorysources', InventorySource()],
|
||||
['jobs', Job()],
|
||||
['jobtemplates', JobTemplate()],
|
||||
['unifiedjobs', Job()],
|
||||
['unifiedjobtemplates', JobTemplate()],
|
||||
['projects', Project()],
|
||||
['workflowjobnodes', WorkflowJobNode()],
|
||||
])
|
||||
|
||||
@ -64,15 +64,6 @@ class TestWorkflowJobTemplateNodeAccess:
|
||||
access = WorkflowJobTemplateNodeAccess(org_admin)
|
||||
assert access.can_change(wfjt_node, {'job_type': 'check'})
|
||||
|
||||
def test_prompted_resource_prevents_edit(self, wfjt_node, org_admin, machine_credential):
|
||||
# without access to prompted resources, admin to the WFJT can
|
||||
# not change the other prompted resources
|
||||
wfjt_node.unified_job_template.admin_role.members.add(org_admin)
|
||||
wfjt_node.credential = machine_credential
|
||||
wfjt_node.save()
|
||||
access = WorkflowJobTemplateNodeAccess(org_admin)
|
||||
assert not access.can_change(wfjt_node, {'inventory': 45})
|
||||
|
||||
def test_access_to_edit_non_JT(self, rando, workflow_job_template, organization, project):
|
||||
workflow_job_template.admin_role.members.add(rando)
|
||||
node = workflow_job_template.workflow_job_template_nodes.create(
|
||||
|
||||
@ -98,62 +98,3 @@ def test_unified_job_migration(old_enc, new_enc, value):
|
||||
# Exception if the encryption type of AESCBC is not properly skipped, ensures
|
||||
# our `startswith` calls don't have typos
|
||||
_unified_jobs(apps)
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
@pytest.mark.parametrize("attr, cls", [
|
||||
['job_template', JobTemplate],
|
||||
['workflow_job_template', WorkflowJobTemplate]
|
||||
])
|
||||
def test_survey_default_password_encryption(attr, cls, request):
|
||||
factory = request.getfuncargvalue('{}_factory'.format(attr))
|
||||
jt = getattr(factory('jt'), attr)
|
||||
jt.survey_enabled = True
|
||||
jt.survey_spec = {
|
||||
'description': 'A survey',
|
||||
'spec': [{
|
||||
'index': 0,
|
||||
'question_name': 'What is your password?',
|
||||
'required': True,
|
||||
'variable': 'secret_value',
|
||||
'default': 'SUPERSECRET',
|
||||
'type': 'password'
|
||||
}],
|
||||
'name': 'my survey'
|
||||
}
|
||||
jt.save()
|
||||
|
||||
_encrypt_survey_passwords(Job, JobTemplate, WorkflowJob, WorkflowJobTemplate)
|
||||
spec = cls.objects.get(pk=jt.pk).survey_spec['spec']
|
||||
assert decrypt_value(get_encryption_key('value', pk=None), spec[0]['default']) == 'SUPERSECRET'
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
@pytest.mark.parametrize("attr, cls", [
|
||||
['job_template', Job],
|
||||
['workflow_job_template', WorkflowJob]
|
||||
])
|
||||
def test_job_survey_vars_encryption(attr, cls, request):
|
||||
factory = request.getfuncargvalue('{}_factory'.format(attr))
|
||||
jt = getattr(factory('jt'), attr)
|
||||
jt.survey_enabled = True
|
||||
jt.survey_spec = {
|
||||
'description': 'A survey',
|
||||
'spec': [{
|
||||
'index': 0,
|
||||
'question_name': 'What is your password?',
|
||||
'required': True,
|
||||
'variable': 'secret_value',
|
||||
'default': '',
|
||||
'type': 'password'
|
||||
}],
|
||||
'name': 'my survey'
|
||||
}
|
||||
jt.save()
|
||||
job = jt.create_unified_job()
|
||||
job.extra_vars = json.dumps({'secret_value': 'SUPERSECRET'})
|
||||
job.save()
|
||||
|
||||
_encrypt_survey_passwords(Job, JobTemplate, WorkflowJob, WorkflowJobTemplate)
|
||||
job = cls.objects.get(pk=job.pk)
|
||||
assert json.loads(job.decrypted_extra_vars()) == {'secret_value': 'SUPERSECRET'}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user