mirror of
https://github.com/ansible/awx.git
synced 2026-01-11 10:00:01 -03:30
Unit tests added.
This commit is contained in:
parent
1d3c890e79
commit
a0ea2337c6
@ -9,12 +9,13 @@ from awx.main.models import (
|
||||
from awx.main.access import (
|
||||
InventoryAccess,
|
||||
HostAccess,
|
||||
InventoryUpdateAccess
|
||||
InventoryUpdateAccess,
|
||||
CustomInventoryScriptAccess
|
||||
)
|
||||
from django.apps import apps
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_custom_inv_script_access(organization, user):
|
||||
def test_custom_inv_script_access(organization, user, organization_factory):
|
||||
u = user('user', False)
|
||||
ou = user('oadm', False)
|
||||
|
||||
@ -29,6 +30,10 @@ def test_custom_inv_script_access(organization, user):
|
||||
organization.admin_role.members.add(ou)
|
||||
assert ou in custom_inv.admin_role
|
||||
|
||||
other_org = organization_factory('not-my-org').organization
|
||||
access = CustomInventoryScriptAccess(ou)
|
||||
assert not access.can_change(custom_inv, {'organization': other_org.pk, 'name': 'new-project'})
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_inventory_admin_user(inventory, permissions, user):
|
||||
u = user('admin', False)
|
||||
|
||||
@ -217,3 +217,10 @@ def test_create_project_foreign_org_admin(org_admin, organization, organization_
|
||||
other_org = organization_factory('not-my-org').organization
|
||||
access = ProjectAccess(org_admin)
|
||||
assert not access.can_add({'organization': other_org.pk, 'name': 'new-project'})
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_modify_project_foreign_org_admin(org_admin, organization, organization_factory, project):
|
||||
"""Org admins can only modify projects in their own org."""
|
||||
other_org = organization_factory('not-my-org').organization
|
||||
access = ProjectAccess(org_admin)
|
||||
assert not access.can_change(project, {'organization': other_org.pk, 'name': 'new-project'})
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user