mirror of
https://github.com/ansible/awx.git
synced 2026-05-19 14:57:39 -02:30
Added user role creation, accessible methods, and fixed up m2m_update
This commit is contained in:
@@ -1,8 +1,11 @@
|
||||
import pytest
|
||||
|
||||
from awx.main.migrations import _rbac as rbac
|
||||
from awx.main.models import Role
|
||||
from django.apps import apps
|
||||
from django.contrib.auth.models import User
|
||||
|
||||
from awx.main.migrations import _rbac as rbac
|
||||
from awx.main.access import UserAccess
|
||||
from awx.main.models import Role
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_user_admin(user_project, project, user):
|
||||
@@ -23,3 +26,21 @@ def test_user_admin(user_project, project, user):
|
||||
assert sa.members.filter(id=joe.id).exists() is False
|
||||
assert sa.members.filter(id=admin.id).exists() is True
|
||||
assert len(migrations) == 1
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_user_queryset(user):
|
||||
u = user('pete', False)
|
||||
|
||||
access = UserAccess(u)
|
||||
qs = access.get_queryset()
|
||||
assert qs.count() == 1
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_user_accessible_by(user, organization):
|
||||
admin = user('admin', False)
|
||||
u = user('john', False)
|
||||
|
||||
organization.member_role.members.add(u)
|
||||
organization.admin_role.members.add(admin)
|
||||
|
||||
assert User.accessible_objects(admin, {'read':True}).count() == 2
|
||||
|
||||
Reference in New Issue
Block a user