Browse Source

Merge "Functional test for deleting function version"

changes/81/565381/1
Zuul 3 years ago
committed by Gerrit Code Review
parent
commit
161bccaf9b
  1. 4
      qinling/api/controllers/v1/function_version.py
  2. 4
      qinling/db/api.py
  3. 33
      qinling_tempest_plugin/tests/api/test_function_versions.py

4
qinling/api/controllers/v1/function_version.py

@ -204,13 +204,15 @@ class FunctionVersionsController(rest.RestController):
- The version should not being used by any job
- The version should not being used by any webhook
- Admin user can not delete normal user's version
"""
ctx = context.get_ctx()
acl.enforce('function_version:delete', ctx)
LOG.info("Deleting version %s of function %s.", version, function_id)
with db_api.transaction():
version_db = db_api.get_function_version(function_id, version)
version_db = db_api.get_function_version(function_id, version,
insecure=False)
latest_version = version_db.function.latest_version
version_jobs = db_api.get_jobs(

4
qinling/db/api.py

@ -208,8 +208,8 @@ def increase_function_version(function_id, old_version, **kwargs):
return IMPL.increase_function_version(function_id, old_version, **kwargs)
def get_function_version(function_id, version):
return IMPL.get_function_version(function_id, version)
def get_function_version(function_id, version, **kwargs):
return IMPL.get_function_version(function_id, version, **kwargs)
# This function is only used in unit test.

33
qinling_tempest_plugin/tests/api/test_function_versions.py

@ -113,6 +113,39 @@ class FunctionVersionsTest(base.BaseQinlingTest):
[v['version_number'] for v in body['function_versions']]
)
@decorators.idempotent_id('0e70ef18-687c-4ce4-ae29-aee2f88b4b9c')
def test_delete(self):
function_id = self.create_function()
version = self.create_function_version(function_id)
resp = self.client.delete_function_version(function_id, version)
self.assertEqual(204, resp.status)
resp, body = self.client.get_function_versions(function_id)
self.assertEqual(200, resp.status)
self.assertNotIn(
version,
[v['version_number'] for v in body['function_versions']]
)
@decorators.idempotent_id('c6717e2e-e80a-43d9-a25b-84f4b7453c76')
def test_delete_by_admin(self):
"""test_delete_by_admin
Admin user can not delete normal user's function version.
"""
function_id = self.create_function()
version = self.create_function_version(function_id)
self.assertRaises(
exceptions.NotFound,
self.admin_client.delete_function_version,
function_id,
version
)
@decorators.idempotent_id('7898f89f-a490-42a3-8cf7-63cbd9543a06')
def test_detach(self):
"""Admin only operation."""

Loading…
Cancel
Save