Check to see if the env_role has been provisioned before disabling env_role in the csp
This commit is contained in:
parent
c501431719
commit
8330b4de24
@ -105,7 +105,7 @@ class EnvironmentRoles(object):
|
||||
def disable(cls, environment_role_id):
|
||||
environment_role = EnvironmentRoles.get_by_id(environment_role_id)
|
||||
|
||||
if not environment_role.environment.is_pending:
|
||||
if environment_role.csp_user_id and not environment_role.environment.is_pending:
|
||||
credentials = environment_role.environment.csp_credentials
|
||||
app.csp.cloud.disable_user(credentials, environment_role.csp_user_id)
|
||||
|
||||
|
@ -110,6 +110,23 @@ def test_disable_checks_env_provisioning_status(session):
|
||||
assert env_role2.disabled
|
||||
|
||||
|
||||
def test_disable_checks_env_role_provisioning_status():
|
||||
environment = EnvironmentFactory.create(
|
||||
cloud_id="cloud-id", root_user_info={"credentials": "credentials"}
|
||||
)
|
||||
env_role1 = EnvironmentRoleFactory.create(environment=environment)
|
||||
assert not env_role1.csp_user_id
|
||||
env_role1 = EnvironmentRoles.disable(env_role1.id)
|
||||
assert env_role1.disabled
|
||||
|
||||
env_role2 = EnvironmentRoleFactory.create(
|
||||
environment=environment, csp_user_id="123456"
|
||||
)
|
||||
assert env_role2.csp_user_id
|
||||
env_role2 = EnvironmentRoles.disable(env_role2.id)
|
||||
assert env_role2.disabled
|
||||
|
||||
|
||||
def test_get_for_update(application_role, environment):
|
||||
EnvironmentRoleFactory.create(
|
||||
application_role=application_role, environment=environment, deleted=True
|
||||
|
Loading…
x
Reference in New Issue
Block a user