Esempio n. 1
0
def test_prefetch_jt_copy_capability(job_template, project, inventory,
                                     machine_credential, vault_credential,
                                     rando):
    job_template.project = project
    job_template.inventory = inventory
    job_template.credential = machine_credential
    job_template.vault_credential = vault_credential
    job_template.save()

    qs = JobTemplate.objects.all()
    cache_list_capabilities(qs, [{
        'copy': [
            'project.use', 'inventory.use', 'credential.use',
            'vault_credential.use'
        ]
    }], JobTemplate, rando)
    assert qs[0].capabilities_cache == {'copy': False}

    project.use_role.members.add(rando)
    inventory.use_role.members.add(rando)
    machine_credential.use_role.members.add(rando)
    vault_credential.use_role.members.add(rando)

    cache_list_capabilities(qs, [{
        'copy': [
            'project.use', 'inventory.use', 'credential.use',
            'vault_credential.use'
        ]
    }], JobTemplate, rando)
    assert qs[0].capabilities_cache == {'copy': True}
Esempio n. 2
0
def test_prefetch_ujt_job_template_capabilities(alice, bob, job_template):
    job_template.execute_role.members.add(alice)
    qs = UnifiedJobTemplate.objects.all()
    cache_list_capabilities(qs, ['admin', 'execute'], UnifiedJobTemplate,
                            alice)
    assert qs[0].capabilities_cache == {'edit': False, 'start': True}
    qs = UnifiedJobTemplate.objects.all()
    cache_list_capabilities(qs, ['admin', 'execute'], UnifiedJobTemplate, bob)
    assert qs[0].capabilities_cache == {'edit': False, 'start': False}
Esempio n. 3
0
def test_prefetch_group_capabilities(group, rando):
    group.inventory.adhoc_role.members.add(rando)
    qs = Group.objects.all()
    cache_list_capabilities(qs, ['inventory.admin', 'inventory.adhoc'], Group,
                            rando)
    assert qs[0].capabilities_cache == {'edit': False, 'adhoc': True}
Esempio n. 4
0
def test_prefetch_ujt_project_capabilities(alice, project):
    project.update_role.members.add(alice)
    qs = UnifiedJobTemplate.objects.all()
    cache_list_capabilities(qs, ['admin', 'execute'], UnifiedJobTemplate,
                            alice)
    assert qs[0].capabilities_cache == {}
Esempio n. 5
0
def test_prefetch_jt_capabilities(job_template, rando):
    job_template.execute_role.members.add(rando)
    qs = JobTemplate.objects.all()
    cache_list_capabilities(qs, ['admin', 'execute'], JobTemplate, rando)
    assert qs[0].capabilities_cache == {'edit': False, 'start': True}