Skip to content

Commit 707d1f5

Browse files
committed
Fixing first batch of test failures
1 parent 38398a9 commit 707d1f5

File tree

4 files changed

+9
-10
lines changed

4 files changed

+9
-10
lines changed

ansible_base/authentication/utils/claims.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@
88
from django.conf import settings
99
from django.contrib.auth import get_user_model
1010
from django.contrib.auth.models import AbstractUser
11-
from django.contrib.contenttypes.models import ContentType
1211
from django.core.exceptions import ObjectDoesNotExist
1312
from django.db import IntegrityError, models
1413
from django.utils.timezone import now
1514
from django.utils.translation import gettext_lazy as _
1615
from rest_framework.serializers import DateTimeField
1716

1817
from ansible_base.authentication.models import Authenticator, AuthenticatorMap, AuthenticatorUser
18+
from ansible_base.rbac.models import DABContentType
1919
from ansible_base.lib.abstract_models import AbstractOrganization, AbstractTeam, CommonModel
2020
from ansible_base.lib.utils.auth import get_organization_model, get_team_model
2121
from ansible_base.lib.utils.string import is_empty
@@ -582,7 +582,7 @@ class RoleUserAssignmentsCache:
582582
def __init__(self):
583583
self.cache = {}
584584
# NOTE(cutwater): We may probably execute this query once and cache the query results.
585-
self.content_types = {content_type.model: content_type for content_type in ContentType.objects.get_for_models(Organization, Team).values()}
585+
self.content_types = {content_type.model: content_type for content_type in DABContentType.objects.get_for_models(Organization, Team).values()}
586586
self.role_definitions = {}
587587

588588
def items(self):

ansible_base/rbac/migrations/0005_remote_permissions_migration.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Generated by Django 4.2.23 on 2025-06-30 18:45
22

3-
from django.db import migrations, models
3+
from django.db import migrations
44

55

66
class Migration(migrations.Migration):

test_app/tests/authentication/utils/test_claims_reconcile_user.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44

55
import pytest
66
from django.contrib.auth import get_user_model
7-
from django.contrib.contenttypes.models import ContentType
87

98
from ansible_base.authentication.utils.claims import ReconcileUser, create_organizations_and_teams
9+
from ansible_base.rbac.models import DABContentType
1010
from ansible_base.lib.utils.auth import get_organization_model, get_team_model
1111

1212
Organization = get_organization_model()
@@ -259,10 +259,10 @@ def test_remove_users_setting_set(org_member_rd, org_admin_rd, member_rd, admin_
259259
assert user.has_obj_perm(teams[1], 'change')
260260

261261
# Nothing was specified in orgs[2], teams[2]
262-
org_content_type = ContentType.objects.get_for_model(Organization)
262+
org_content_type = DABContentType.objects.get_for_model(Organization)
263263
user_role_assignments_for_org_2 = user.role_assignments.filter(content_type=org_content_type, object_id=str(orgs[2].id))
264264
assert (
265265
not user_role_assignments_for_org_2.exists()
266266
), f"Expected no assignments for org2 but got {', '.join([r.role_definition.name for r in user_role_assignments_for_org_2])}"
267-
team_content_type = ContentType.objects.get_for_model(Team)
267+
team_content_type = DABContentType.objects.get_for_model(Team)
268268
assert not user.role_assignments.filter(content_type=team_content_type, object_id=str(teams[2].id)).exists()

test_app/tests/jwt_consumer/hub/test_auth.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,10 @@
22
from uuid import uuid4
33

44
import pytest
5-
from django.contrib.contenttypes.models import ContentType
65

76
from ansible_base.jwt_consumer.common.exceptions import InvalidService
87
from ansible_base.jwt_consumer.hub.auth import HubJWTAuth
9-
from ansible_base.rbac.models import RoleDefinition, RoleUserAssignment
8+
from ansible_base.rbac.models import RoleDefinition, RoleUserAssignment, DABContentType
109
from test_app.models import Organization, Team, User
1110

1211

@@ -61,9 +60,9 @@ def test_hub_jwt_orgs_teams_groups_memberships(mock_contenttype, mock_resource):
6160
# The rbac hooks will attempt to assign these roledefs
6261
# when users are added/removed from orgs+teams, so they
6362
# must exist before claims are processed ...
64-
org_content_type = ContentType.objects.get_for_model(Organization)
63+
org_content_type = DABContentType.objects.get_for_model(Organization)
6564
org_member_role, _ = RoleDefinition.objects.get_or_create(name="Organization Member", content_type=org_content_type)
66-
team_content_type = ContentType.objects.get_for_model(Team)
65+
team_content_type = DABContentType.objects.get_for_model(Team)
6766
team_member_role, _ = RoleDefinition.objects.get_or_create(name="Team Member", content_type=team_content_type)
6867
team_admin_role, _ = RoleDefinition.objects.get_or_create(name="Team Admin", content_type=team_content_type)
6968

0 commit comments

Comments
 (0)