Merge pull request #785 from dod-ccpo/check-user-is-in-app-before-adding-env-role

Check user is in app before adding env role
This commit is contained in:
montana-mil
2019-04-30 14:31:08 -04:00
committed by GitHub
11 changed files with 85 additions and 6 deletions

View File

@@ -14,7 +14,7 @@ def test_create_application_role():
)
assert application_role.permission_sets == PermissionSets.get_many(
[PermissionSets.EDIT_APPLICATION_TEAM]
[PermissionSets.EDIT_APPLICATION_TEAM, PermissionSets.VIEW_APPLICATION]
)
assert application_role.application == application
assert application_role.user == user

View File

@@ -11,6 +11,7 @@ from tests.factories import (
PortfolioFactory,
EnvironmentFactory,
EnvironmentRoleFactory,
ApplicationRoleFactory,
)
@@ -24,6 +25,9 @@ def test_create_environments():
def test_update_env_role():
env_role = EnvironmentRoleFactory.create(role=CSPRole.BASIC_ACCESS.value)
new_role = CSPRole.TECHNICAL_READ.value
ApplicationRoleFactory.create(
user=env_role.user, application=env_role.environment.application
)
assert Environments.update_env_role(env_role.environment, env_role.user, new_role)
assert env_role.role == new_role
@@ -31,6 +35,9 @@ def test_update_env_role():
def test_update_env_role_no_access():
env_role = EnvironmentRoleFactory.create(role=CSPRole.BASIC_ACCESS.value)
ApplicationRoleFactory.create(
user=env_role.user, application=env_role.environment.application
)
assert Environments.update_env_role(env_role.environment, env_role.user, None)
assert not EnvironmentRoles.get(env_role.user.id, env_role.environment.id)
@@ -48,6 +55,7 @@ def test_update_env_role_no_change():
def test_update_env_role_creates_cloud_id_for_new_member(session):
user = UserFactory.create()
env = EnvironmentFactory.create()
ApplicationRoleFactory.create(user=user, application=env.application)
assert not user.cloud_id
assert Environments.update_env_role(env, user, CSPRole.TECHNICAL_READ.value)
assert EnvironmentRoles.get(user.id, env.id)
@@ -65,6 +73,8 @@ def test_update_env_roles_by_environment():
env_role_3 = EnvironmentRoleFactory.create(
environment=environment, role=CSPRole.TECHNICAL_READ.value
)
for user in [env_role_1.user, env_role_2.user, env_role_3.user]:
ApplicationRoleFactory.create(user=user, application=environment.application)
team_roles = [
{