Exemplo n.º 1
0
def test_org_member_inventory_script_permissions(org_member, organization):
    custom_inv = CustomInventoryScript.objects.create(
        name='test', script='test', organization=organization)
    access = CustomInventoryScriptAccess(org_member)
    assert access.can_read(custom_inv)
    assert not access.can_delete(custom_inv)
    assert not access.can_change(custom_inv, {'name': 'ed-test'})
Exemplo n.º 2
0
def test_modify_inv_script_foreign_org_admin(org_admin, organization,
                                             organization_factory, project,
                                             custom_inv):
    other_org = organization_factory('not-my-org').organization
    access = CustomInventoryScriptAccess(org_admin)
    assert not access.can_change(custom_inv, {
        'organization': other_org.pk,
        'name': 'new-project'
    })
Exemplo n.º 3
0
def test_copy_only_admin(org_member, organization, custom_inv):
    custom_inv.admin_role.members.add(org_member)
    access = CustomInventoryScriptAccess(org_member)
    assert not access.can_copy(custom_inv)
    assert access.get_user_capabilities(custom_inv,
                                        method_list=['edit', 'delete',
                                                     'copy']) == {
                                                         'edit': True,
                                                         'delete': True,
                                                         'copy': False
                                                     }
Exemplo n.º 4
0
def test_modify_inv_script_foreign_org_admin(org_admin, organization,
                                             organization_factory, project):
    custom_inv = CustomInventoryScript.objects.create(
        name='test',
        script='test',
        description='test',
        organization=organization)

    other_org = organization_factory('not-my-org').organization
    access = CustomInventoryScriptAccess(org_admin)
    assert not access.can_change(custom_inv, {
        'organization': other_org.pk,
        'name': 'new-project'
    })
Exemplo n.º 5
0
def test_org_member_inventory_script_permissions(org_member, organization,
                                                 custom_inv):
    access = CustomInventoryScriptAccess(org_member)
    assert access.can_read(custom_inv)
    assert not access.can_delete(custom_inv)
    assert not access.can_change(custom_inv, {'name': 'ed-test'})