mirror of
https://github.com/ansible/awx.git
synced 2026-05-10 19:07:36 -02:30
test creating credential for self & org_member
This commit is contained in:
@@ -1,5 +1,7 @@
|
|||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
|
import mock
|
||||||
|
|
||||||
from awx.main.access import CredentialAccess
|
from awx.main.access import CredentialAccess
|
||||||
from awx.main.models.credential import Credential
|
from awx.main.models.credential import Credential
|
||||||
from django.contrib.auth.models import User
|
from django.contrib.auth.models import User
|
||||||
@@ -22,6 +24,21 @@ def test_credential_access_superuser():
|
|||||||
assert access.can_delete(credential)
|
assert access.can_delete(credential)
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.django_db
|
||||||
|
def test_credential_access_self(rando):
|
||||||
|
access = CredentialAccess(rando)
|
||||||
|
assert access.can_add({'user': rando.pk})
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.django_db
|
||||||
|
@pytest.mark.parametrize('ext_auth', [True, False])
|
||||||
|
def test_credential_access_org_user(org_member, org_admin, ext_auth):
|
||||||
|
access = CredentialAccess(org_admin)
|
||||||
|
with mock.patch('awx.main.access.settings') as settings_mock:
|
||||||
|
settings_mock.MANAGE_ORGANIZATION_AUTH = ext_auth
|
||||||
|
assert access.can_add({'user': org_member.pk})
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.django_db
|
@pytest.mark.django_db
|
||||||
def test_credential_access_auditor(credential, organization_factory):
|
def test_credential_access_auditor(credential, organization_factory):
|
||||||
objects = organization_factory("org_cred_auditor",
|
objects = organization_factory("org_cred_auditor",
|
||||||
|
|||||||
Reference in New Issue
Block a user