Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RHCLOUD-36014] Test: No replication call for group without principals #1302

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion tests/migration_tool/tests_migrate.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,11 @@
from uuid import uuid4

from django.test import TestCase, override_settings
from functools import partial

from api.models import Tenant
from management.models import *
from migration_tool.migrate import migrate_data
from migration_tool.migrate import migrate_data, migrate_groups_for_tenant
from management.group.definer import seed_group, clone_default_group_in_public_schema


Expand Down Expand Up @@ -107,6 +108,18 @@ def setUp(self):
# tenant 2 - org_id=7654321
another_tenant = Tenant.objects.create(org_id="7654321")

root_workspace_another_tenant = Workspace.objects.create(
type=Workspace.Types.ROOT, tenant=another_tenant, name="Root Workspace"
)
Workspace.objects.create(
type=Workspace.Types.DEFAULT,
tenant=another_tenant,
name="Default Workspace",
parent=root_workspace_another_tenant,
)

Group.objects.create(name="another_group", tenant=another_tenant)

# setup data for another tenant 7654321
self.role_b = Role.objects.create(name="role_b", tenant=another_tenant)
self.access_b = Access.objects.create(permission=permission2, role=self.role_b, tenant=another_tenant)
Expand All @@ -117,6 +130,14 @@ def setUp(self):
# create custom default group
self.custom_default_group = clone_default_group_in_public_schema(default_group, self.tenant)

@override_settings(REPLICATION_TO_RELATION_ENABLED=True, PRINCIPAL_USER_DOMAIN="redhat", READ_ONLY_API_MODE=True)
@patch("migration_tool.migrate.RelationApiDualWriteGroupHandler.replicate")
def test_migration_of_data_no_replication_event_to_migrate_groups(self, replicate_method):
"""Test that we get the correct access for a principal."""
kwargs = {"exclude_apps": ["app1"], "orgs": ["7654321"]}
migrate_data(**kwargs)
replicate_method.assert_not_called()

@override_settings(REPLICATION_TO_RELATION_ENABLED=True, PRINCIPAL_USER_DOMAIN="redhat", READ_ONLY_API_MODE=True)
@patch("management.relation_replicator.logging_replicator.logger")
def test_migration_of_data(self, logger_mock):
Expand Down