mirror of
https://github.com/ZwareBear/awx.git
synced 2026-05-06 16:32:01 -05:00
Fix up some project multi-org -> single-org fallout
This commit is contained in:
@@ -4,6 +4,7 @@ from awx.main.models import (
|
||||
Role,
|
||||
RolePermission,
|
||||
Organization,
|
||||
Group,
|
||||
)
|
||||
|
||||
|
||||
@@ -97,20 +98,24 @@ def test_team_symantics(organization, team, alice):
|
||||
assert organization.accessible_by(alice, {'read': True}) is False
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_auto_m2m_adjuments(organization, project, alice):
|
||||
def test_auto_m2m_adjuments(organization, inventory, group, alice):
|
||||
'Ensures the auto role reparenting is working correctly through m2m maps'
|
||||
organization.admin_role.members.add(alice)
|
||||
assert project.accessible_by(alice, {'read': True}) is True
|
||||
g1 = group(name='g1')
|
||||
g1.admin_role.members.add(alice)
|
||||
assert g1.accessible_by(alice, {'read': True}) is True
|
||||
g2 = group(name='g2')
|
||||
assert g2.accessible_by(alice, {'read': True}) is False
|
||||
|
||||
project.organizations.remove(organization)
|
||||
assert project.accessible_by(alice, {'read': True}) is False
|
||||
project.organizations.add(organization)
|
||||
assert project.accessible_by(alice, {'read': True}) is True
|
||||
g2.parents.add(g1)
|
||||
assert g2.accessible_by(alice, {'read': True}) is True
|
||||
g2.parents.remove(g1)
|
||||
assert g2.accessible_by(alice, {'read': True}) is False
|
||||
|
||||
g1.children.add(g2)
|
||||
assert g2.accessible_by(alice, {'read': True}) is True
|
||||
g1.children.remove(g2)
|
||||
assert g2.accessible_by(alice, {'read': True}) is False
|
||||
|
||||
organization.projects.remove(project)
|
||||
assert project.accessible_by(alice, {'read': True}) is False
|
||||
organization.projects.add(project)
|
||||
assert project.accessible_by(alice, {'read': True}) is True
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_auto_field_adjuments(organization, inventory, team, alice):
|
||||
|
||||
@@ -16,7 +16,7 @@ def test_job_template_migration_check(deploy_jobtemplate, check_jobtemplate, use
|
||||
joe = user('joe')
|
||||
|
||||
|
||||
check_jobtemplate.project.organizations.all()[0].deprecated_users.add(joe)
|
||||
check_jobtemplate.project.organization.deprecated_users.add(joe)
|
||||
|
||||
Permission(user=joe, inventory=check_jobtemplate.inventory, permission_type='read').save()
|
||||
Permission(user=joe, inventory=check_jobtemplate.inventory,
|
||||
@@ -45,7 +45,7 @@ def test_job_template_migration_deploy(deploy_jobtemplate, check_jobtemplate, us
|
||||
joe = user('joe')
|
||||
|
||||
|
||||
deploy_jobtemplate.project.organizations.all()[0].deprecated_users.add(joe)
|
||||
deploy_jobtemplate.project.organization.deprecated_users.add(joe)
|
||||
|
||||
Permission(user=joe, inventory=deploy_jobtemplate.inventory, permission_type='read').save()
|
||||
Permission(user=joe, inventory=deploy_jobtemplate.inventory,
|
||||
@@ -77,7 +77,7 @@ def test_job_template_team_migration_check(deploy_jobtemplate, check_jobtemplate
|
||||
team.organization = organization
|
||||
team.save()
|
||||
|
||||
check_jobtemplate.project.organizations.all()[0].deprecated_users.add(joe)
|
||||
check_jobtemplate.project.organization.deprecated_users.add(joe)
|
||||
|
||||
Permission(team=team, inventory=check_jobtemplate.inventory, permission_type='read').save()
|
||||
Permission(team=team, inventory=check_jobtemplate.inventory,
|
||||
@@ -112,7 +112,7 @@ def test_job_template_team_deploy_migration(deploy_jobtemplate, check_jobtemplat
|
||||
team.organization = organization
|
||||
team.save()
|
||||
|
||||
deploy_jobtemplate.project.organizations.all()[0].deprecated_users.add(joe)
|
||||
deploy_jobtemplate.project.organization.deprecated_users.add(joe)
|
||||
|
||||
Permission(team=team, inventory=deploy_jobtemplate.inventory, permission_type='read').save()
|
||||
Permission(team=team, inventory=deploy_jobtemplate.inventory,
|
||||
|
||||
Reference in New Issue
Block a user