-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(AAP-29090): remove member_organization permission from org admin …
…role (#999) * remove member_organization permission from org admin role * add tests for role user and team assignments for managed org roles
- Loading branch information
1 parent
0b5b20f
commit ed38a0c
Showing
4 changed files
with
80 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
# Copyright 2024 Red Hat, Inc. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
import pytest | ||
from ansible_base.rbac.models import RoleDefinition | ||
from rest_framework import status | ||
|
||
from aap_eda.core.management.commands.create_initial_data import ORG_ROLES | ||
from tests.integration.constants import api_url_v1 | ||
|
||
|
||
@pytest.mark.django_db | ||
def test_org_role_team_assignments( | ||
admin_client, default_organization, default_team, create_managed_org_roles | ||
): | ||
for org_role in ORG_ROLES: | ||
# ignore Org Member role as it is not assignable to teams | ||
if org_role["name"] != "Organization Member": | ||
role = RoleDefinition.objects.get(name=org_role["name"]) | ||
post_data = { | ||
"object_id": default_organization.id, | ||
"role_definition": role.id, | ||
"team": default_team.id, | ||
} | ||
response = admin_client.post( | ||
f"{api_url_v1}/role_team_assignments/", data=post_data | ||
) | ||
assert ( | ||
response.status_code == status.HTTP_201_CREATED | ||
), response.data | ||
|
||
|
||
@pytest.mark.django_db | ||
def test_org_role_user_assignments( | ||
admin_client, default_organization, default_user, create_managed_org_roles | ||
): | ||
for org_role in ORG_ROLES: | ||
role = RoleDefinition.objects.get(name=org_role["name"]) | ||
post_data = { | ||
"object_id": default_organization.id, | ||
"role_definition": role.id, | ||
"user": default_user.id, | ||
} | ||
response = admin_client.post( | ||
f"{api_url_v1}/role_user_assignments/", data=post_data | ||
) | ||
assert response.status_code == status.HTTP_201_CREATED, response.data |