mirror of
https://github.com/ansible/awx.git
synced 2026-05-17 14:27:42 -02:30
delete user role on deletion of a user
This commit is contained in:
@@ -1,9 +1,10 @@
|
||||
import pytest
|
||||
|
||||
from django.test import TransactionTestCase
|
||||
from django.contrib.contenttypes.models import ContentType
|
||||
|
||||
from awx.main.access import UserAccess
|
||||
from awx.main.models import User, Organization, Inventory
|
||||
from awx.main.models import User, Organization, Inventory, Role
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
@@ -102,6 +103,27 @@ def test_org_user_removed(user, organization):
|
||||
assert admin not in member.admin_role
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_create_user_role(rando):
|
||||
assert Role.objects.filter(
|
||||
role_field='admin_role',
|
||||
content_type=ContentType.objects.get_for_model(User),
|
||||
object_id=rando.id
|
||||
).count() == 1
|
||||
assert rando in rando.admin_role
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_user_role_deleted(rando):
|
||||
rando_id = rando.id
|
||||
rando.delete()
|
||||
assert not Role.objects.filter(
|
||||
role_field='admin_role',
|
||||
content_type=ContentType.objects.get_for_model(User),
|
||||
object_id=rando_id
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_org_admin_create_sys_auditor(org_admin):
|
||||
access = UserAccess(org_admin)
|
||||
|
||||
Reference in New Issue
Block a user