Change revert tag into restore tag and add manifest support
This commit is contained in:
parent
35752176b5
commit
e90cab4d77
4 changed files with 137 additions and 56 deletions
|
@ -12,7 +12,7 @@ from endpoints.api import api_bp, api
|
|||
|
||||
from endpoints.api.team import (TeamMember, TeamMemberList, OrganizationTeam, TeamMemberInvite,
|
||||
TeamPermissions)
|
||||
from endpoints.api.tag import RepositoryTagImages, RepositoryTag, ListRepositoryTags, RevertTag
|
||||
from endpoints.api.tag import RepositoryTagImages, RepositoryTag, ListRepositoryTags, RestoreTag
|
||||
from endpoints.api.search import EntitySearch
|
||||
from endpoints.api.image import RepositoryImage, RepositoryImageList
|
||||
from endpoints.api.build import (FileDropResource, RepositoryBuildStatus, RepositoryBuildLogs,
|
||||
|
@ -2539,10 +2539,10 @@ class TestRepositoryImage5avqBuynlargeOrgrepo(ApiTestCase):
|
|||
self._run_test('GET', 404, 'devtable', None)
|
||||
|
||||
|
||||
class TestRevertTagHp8rPublicPublicrepo(ApiTestCase):
|
||||
class TestRestoreTagHp8rPublicPublicrepo(ApiTestCase):
|
||||
def setUp(self):
|
||||
ApiTestCase.setUp(self)
|
||||
self._set_url(RevertTag, tag="HP8R", repository="public/publicrepo")
|
||||
self._set_url(RestoreTag, tag="HP8R", repository="public/publicrepo")
|
||||
|
||||
def test_post_anonymous(self):
|
||||
self._run_test('POST', 401, None, {u'image': 'WXNG'})
|
||||
|
@ -2557,10 +2557,10 @@ class TestRevertTagHp8rPublicPublicrepo(ApiTestCase):
|
|||
self._run_test('POST', 403, 'devtable', {u'image': 'WXNG'})
|
||||
|
||||
|
||||
class TestRevertTagHp8rDevtableShared(ApiTestCase):
|
||||
class TestRestoreTagHp8rDevtableShared(ApiTestCase):
|
||||
def setUp(self):
|
||||
ApiTestCase.setUp(self)
|
||||
self._set_url(RevertTag, tag="HP8R", repository="devtable/shared")
|
||||
self._set_url(RestoreTag, tag="HP8R", repository="devtable/shared")
|
||||
|
||||
def test_post_anonymous(self):
|
||||
self._run_test('POST', 401, None, {u'image': 'WXNG'})
|
||||
|
@ -2572,13 +2572,13 @@ class TestRevertTagHp8rDevtableShared(ApiTestCase):
|
|||
self._run_test('POST', 403, 'reader', {u'image': 'WXNG'})
|
||||
|
||||
def test_post_devtable(self):
|
||||
self._run_test('POST', 404, 'devtable', {u'image': 'WXNG'})
|
||||
self._run_test('POST', 400, 'devtable', {u'image': 'WXNG'})
|
||||
|
||||
|
||||
class TestRevertTagHp8rBuynlargeOrgrepo(ApiTestCase):
|
||||
class TestRestoreTagHp8rBuynlargeOrgrepo(ApiTestCase):
|
||||
def setUp(self):
|
||||
ApiTestCase.setUp(self)
|
||||
self._set_url(RevertTag, tag="HP8R", repository="buynlarge/orgrepo")
|
||||
self._set_url(RestoreTag, tag="HP8R", repository="buynlarge/orgrepo")
|
||||
|
||||
def test_post_anonymous(self):
|
||||
self._run_test('POST', 401, None, {u'image': 'WXNG'})
|
||||
|
@ -2590,7 +2590,7 @@ class TestRevertTagHp8rBuynlargeOrgrepo(ApiTestCase):
|
|||
self._run_test('POST', 403, 'reader', {u'image': 'WXNG'})
|
||||
|
||||
def test_post_devtable(self):
|
||||
self._run_test('POST', 404, 'devtable', {u'image': 'WXNG'})
|
||||
self._run_test('POST', 400, 'devtable', {u'image': 'WXNG'})
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ from util.secscan.fake import fake_security_scanner
|
|||
|
||||
from endpoints.api.team import (TeamMember, TeamMemberList, TeamMemberInvite, OrganizationTeam,
|
||||
TeamPermissions, InviteTeamMember)
|
||||
from endpoints.api.tag import RepositoryTagImages, RepositoryTag, RevertTag, ListRepositoryTags
|
||||
from endpoints.api.tag import RepositoryTagImages, RepositoryTag, RestoreTag, ListRepositoryTags
|
||||
from endpoints.api.search import EntitySearch, ConductSearch
|
||||
from endpoints.api.image import RepositoryImage, RepositoryImageList
|
||||
from endpoints.api.build import RepositoryBuildStatus, RepositoryBuildList, RepositoryBuildResource
|
||||
|
@ -2872,24 +2872,32 @@ class TestGetImageChanges(ApiTestCase):
|
|||
# image_id=image_id))
|
||||
|
||||
|
||||
class TestRevertTag(ApiTestCase):
|
||||
def test_reverttag_invalidtag(self):
|
||||
class TestRestoreTag(ApiTestCase):
|
||||
def test_restoretag_invalidtag(self):
|
||||
self.login(ADMIN_ACCESS_USER)
|
||||
|
||||
self.postResponse(RevertTag,
|
||||
self.postResponse(RestoreTag,
|
||||
params=dict(repository=ADMIN_ACCESS_USER + '/history', tag='invalidtag'),
|
||||
data=dict(image='invalid_image'),
|
||||
expected_code=404)
|
||||
expected_code=400)
|
||||
|
||||
def test_reverttag_invalidimage(self):
|
||||
def test_restoretag_invalidimage(self):
|
||||
self.login(ADMIN_ACCESS_USER)
|
||||
|
||||
self.postResponse(RevertTag,
|
||||
self.postResponse(RestoreTag,
|
||||
params=dict(repository=ADMIN_ACCESS_USER + '/history', tag='latest'),
|
||||
data=dict(image='invalid_image'),
|
||||
expected_code=400)
|
||||
|
||||
def test_reverttag(self):
|
||||
def test_restoretag_invalidmanifest(self):
|
||||
self.login(ADMIN_ACCESS_USER)
|
||||
|
||||
self.postResponse(RestoreTag,
|
||||
params=dict(repository=ADMIN_ACCESS_USER + '/history', tag='latest'),
|
||||
data=dict(manifest_digest='invalid_digest'),
|
||||
expected_code=400)
|
||||
|
||||
def test_restoretag(self):
|
||||
self.login(ADMIN_ACCESS_USER)
|
||||
|
||||
json = self.getJsonResponse(ListRepositoryTags,
|
||||
|
@ -2901,8 +2909,8 @@ class TestRevertTag(ApiTestCase):
|
|||
|
||||
previous_image_id = json['tags'][1]['docker_image_id']
|
||||
|
||||
self.postJsonResponse(RevertTag, params=dict(repository=ADMIN_ACCESS_USER + '/history',
|
||||
tag='latest'),
|
||||
self.postJsonResponse(RestoreTag, params=dict(repository=ADMIN_ACCESS_USER + '/history',
|
||||
tag='latest'),
|
||||
data=dict(image=previous_image_id))
|
||||
|
||||
json = self.getJsonResponse(ListRepositoryTags,
|
||||
|
@ -2912,6 +2920,29 @@ class TestRevertTag(ApiTestCase):
|
|||
self.assertFalse('end_ts' in json['tags'][0])
|
||||
self.assertEquals(previous_image_id, json['tags'][0]['docker_image_id'])
|
||||
|
||||
def test_restoretag_to_digest(self):
|
||||
self.login(ADMIN_ACCESS_USER)
|
||||
|
||||
json = self.getJsonResponse(ListRepositoryTags,
|
||||
params=dict(repository=ADMIN_ACCESS_USER + '/history',
|
||||
tag='latest'))
|
||||
|
||||
self.assertEquals(2, len(json['tags']))
|
||||
self.assertFalse('end_ts' in json['tags'][0])
|
||||
|
||||
previous_manifest = json['tags'][1]['manifest_digest']
|
||||
|
||||
self.postJsonResponse(RestoreTag, params=dict(repository=ADMIN_ACCESS_USER + '/history',
|
||||
tag='latest'),
|
||||
data=dict(image='foo', manifest_digest=previous_manifest))
|
||||
|
||||
json = self.getJsonResponse(ListRepositoryTags,
|
||||
params=dict(repository=ADMIN_ACCESS_USER + '/history',
|
||||
tag='latest'))
|
||||
self.assertEquals(3, len(json['tags']))
|
||||
self.assertFalse('end_ts' in json['tags'][0])
|
||||
self.assertEquals(previous_manifest, json['tags'][0]['manifest_digest'])
|
||||
|
||||
|
||||
|
||||
class TestListAndDeleteTag(ApiTestCase):
|
||||
|
|
Reference in a new issue