Skip to content

Commit

Permalink
Add another test
Browse files Browse the repository at this point in the history
  • Loading branch information
AlanCoding committed Apr 30, 2024
1 parent f5e56b6 commit 2c59b2e
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions test_app/tests/rbac/api/test_rbac_permissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,22 @@ def test_related_view_permissions(inventory, organization, user, user_api_client
assert inventory.credential == credential


@pytest.mark.django_db
@override_settings(ANSIBLE_BASE_CHECK_RELATED_PERMISSIONS=[])
def test_related_no_permissions(inventory, organization, user, user_api_client, inv_rd):
"Turn off checking of related permissions"
credential = Credential.objects.create(name='foo-cred', organization=organization)
assert not inventory.credential # sanity
inv_rd.give_permission(user, inventory)
url = reverse('inventory-detail', kwargs={'pk': inventory.pk})

# No permissions to related credential needed, YOLO
response = user_api_client.patch(url, data={'credential': credential.pk})
assert response.status_code == 200
inventory.refresh_from_db()
assert inventory.credential == credential


@pytest.mark.django_db
def test_related_use_permission(inventory, organization, user, user_api_client, inv_rd, cred_view_rd):
credential = Credential.objects.create(name='foo-cred', organization=organization)
Expand Down

0 comments on commit 2c59b2e

Please sign in to comment.