Add hook into CSP when deleting an environment role

This commit is contained in:
Patrick Smith 2019-01-07 15:45:15 -05:00
parent 0798ce4019
commit c89e5b824c
2 changed files with 12 additions and 0 deletions

View File

@ -18,6 +18,13 @@ class CloudProviderInterface:
"""
raise NotImplementedError()
def delete_role(self, environment_role): # pragma: no cover
"""Takes an `atst.model.EnvironmentRole` object and performs any action
necessary in the CSP to remove the specified user from the specified
environment. This method does not return anything.
"""
raise NotImplementedError()
class MockCloudProvider(CloudProviderInterface):
def create_application(self, name):
@ -28,3 +35,7 @@ class MockCloudProvider(CloudProviderInterface):
def create_role(self, environment_role):
# Currently, there is nothing to mock out, so just do nothing.
pass
def delete_role(self, environment_role):
# Currently nothing to do.
pass

View File

@ -27,6 +27,7 @@ class EnvironmentRoles(object):
def delete(cls, user_id, environment_id):
existing_env_role = EnvironmentRoles.get(user_id, environment_id)
if existing_env_role:
app.csp.cloud.delete_role(existing_env_role)
db.session.delete(existing_env_role)
db.session.commit()
return True