diff --git a/muranoapi/api/v1/environments.py b/muranoapi/api/v1/environments.py index 4d79c6db3..2e3a52a65 100644 --- a/muranoapi/api/v1/environments.py +++ b/muranoapi/api/v1/environments.py @@ -53,6 +53,11 @@ class Controller(object): session = get_session() environment = session.query(Environment).get(environment_id) + if environment is None: + log.info('Environment is not found' + .format(environment_id)) + raise exc.HTTPNotFound + if environment.tenant_id != request.context.tenant: log.info('User is not authorized to access this tenant resources.') raise exc.HTTPUnauthorized @@ -77,6 +82,11 @@ class Controller(object): session = get_session() environment = session.query(Environment).get(environment_id) + if environment is None: + log.info('Environment is not found' + .format(environment_id)) + raise exc.HTTPNotFound + if environment.tenant_id != request.context.tenant: log.info('User is not authorized to access this tenant resources.') raise exc.HTTPUnauthorized @@ -92,6 +102,11 @@ class Controller(object): unit = get_session() environment = unit.query(Environment).get(environment_id) + if environment is None: + log.info('Environment is not found' + .format(environment_id)) + raise exc.HTTPNotFound + if environment.tenant_id != request.context.tenant: log.info('User is not authorized to access this tenant resources.') raise exc.HTTPUnauthorized