Add blob mounting tests to the new registry test suite
This commit is contained in:
parent
0fa1a1d5fd
commit
f6eaf7ce9d
3 changed files with 112 additions and 55 deletions
|
@ -783,6 +783,43 @@ def test_squashed_images(use_estimates, pusher, sized_images, liveserver_session
|
|||
tarfile.open(fileobj=tar.extractfile(tar.getmember('%s/layer.tar' % expected_image_id)))
|
||||
|
||||
|
||||
@pytest.mark.parametrize('push_user, push_namespace, push_repo, mount_repo_name, expected_failure', [
|
||||
# Successful mount, same namespace.
|
||||
('devtable', 'devtable', 'baserepo', 'devtable/baserepo', None),
|
||||
|
||||
# Successful mount, cross namespace.
|
||||
('devtable', 'buynlarge', 'baserepo', 'buynlarge/baserepo', None),
|
||||
|
||||
# Unsuccessful mount, unknown repo.
|
||||
('devtable', 'devtable', 'baserepo', 'unknown/repohere', Failures.UNAUTHORIZED_FOR_MOUNT),
|
||||
|
||||
# Unsuccessful mount, no access.
|
||||
('public', 'public', 'baserepo', 'public/baserepo', Failures.UNAUTHORIZED_FOR_MOUNT),
|
||||
])
|
||||
def test_blob_mounting(push_user, push_namespace, push_repo, mount_repo_name, expected_failure,
|
||||
manifest_protocol, pusher, puller, basic_images, liveserver_session,
|
||||
app_reloader):
|
||||
# Push an image so we can attempt to mount it.
|
||||
pusher.push(liveserver_session, push_namespace, push_repo, 'latest', basic_images,
|
||||
credentials=(push_user, 'password'))
|
||||
|
||||
# Push again, trying to mount the image layer(s) from the mount repo.
|
||||
options = ProtocolOptions()
|
||||
options.scopes = ['repository:devtable/newrepo:push,pull',
|
||||
'repository:%s:pull' % (mount_repo_name)]
|
||||
options.mount_blobs = {image.id: mount_repo_name for image in basic_images}
|
||||
|
||||
manifest_protocol.push(liveserver_session, 'devtable', 'newrepo', 'latest', basic_images,
|
||||
credentials=('devtable', 'password'),
|
||||
options=options,
|
||||
expected_failure=expected_failure)
|
||||
|
||||
if expected_failure is None:
|
||||
# Pull to ensure it worked.
|
||||
puller.pull(liveserver_session, 'devtable', 'newrepo', 'latest', basic_images,
|
||||
credentials=('devtable', 'password'))
|
||||
|
||||
|
||||
def get_robot_password(api_caller):
|
||||
api_caller.conduct_auth('devtable', 'password')
|
||||
resp = api_caller.get('/api/v1/organization/buynlarge/robots/ownerbot')
|
||||
|
|
Reference in a new issue