2018-05-01 10:26:47 +00:00
|
|
|
import random
|
|
|
|
import string
|
|
|
|
|
2018-04-24 11:54:07 +00:00
|
|
|
import pytest
|
|
|
|
|
|
|
|
from Crypto.PublicKey import RSA
|
|
|
|
from jwkest.jwk import RSAKey
|
|
|
|
|
|
|
|
from test.registry.protocols import Image, layer_bytes_for_contents
|
|
|
|
from test.registry.protocol_v1 import V1Protocol
|
|
|
|
from test.registry.protocol_v2 import V2Protocol
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture(scope="session")
|
|
|
|
def basic_images():
|
|
|
|
""" Returns basic images for push and pull testing. """
|
|
|
|
# Note: order is from base layer down to leaf.
|
2018-05-01 10:26:47 +00:00
|
|
|
parent_bytes = layer_bytes_for_contents('parent contents')
|
|
|
|
image_bytes = layer_bytes_for_contents('some contents')
|
|
|
|
return [
|
|
|
|
Image(id='parentid', bytes=parent_bytes, parent_id=None),
|
|
|
|
Image(id='someid', bytes=image_bytes, parent_id='parentid'),
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture(scope="session")
|
|
|
|
def sized_images():
|
|
|
|
""" Returns basic images (with sizes) for push and pull testing. """
|
|
|
|
# Note: order is from base layer down to leaf.
|
|
|
|
parent_bytes = layer_bytes_for_contents('parent contents', mode='')
|
|
|
|
image_bytes = layer_bytes_for_contents('some contents', mode='')
|
2018-04-24 11:54:07 +00:00
|
|
|
return [
|
2018-05-01 10:26:47 +00:00
|
|
|
Image(id='parentid', bytes=parent_bytes, parent_id=None, size=len(parent_bytes)),
|
|
|
|
Image(id='someid', bytes=image_bytes, parent_id='parentid', size=len(image_bytes)),
|
2018-04-24 11:54:07 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture(scope="session")
|
|
|
|
def jwk():
|
|
|
|
return RSAKey(key=RSA.generate(2048))
|
|
|
|
|
|
|
|
|
2018-05-01 10:26:47 +00:00
|
|
|
@pytest.fixture(params=[V2Protocol])
|
|
|
|
def v2_protocol(request, jwk):
|
|
|
|
return request.param(jwk)
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture(params=[V1Protocol])
|
|
|
|
def v1_protocol(request, jwk):
|
|
|
|
return request.param(jwk)
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture(params=[V2Protocol])
|
|
|
|
def manifest_protocol(request, jwk):
|
|
|
|
return request.param(jwk)
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture(params=[V1Protocol, V2Protocol])
|
|
|
|
def loginer(request, jwk):
|
|
|
|
return request.param(jwk)
|
|
|
|
|
|
|
|
|
2018-04-24 11:54:07 +00:00
|
|
|
@pytest.fixture(params=[V1Protocol, V2Protocol])
|
|
|
|
def pusher(request, jwk):
|
|
|
|
return request.param(jwk)
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture(params=[V1Protocol, V2Protocol])
|
|
|
|
def puller(request, jwk):
|
|
|
|
return request.param(jwk)
|
2018-05-01 10:26:47 +00:00
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture(scope="session")
|
|
|
|
def random_layer_data():
|
|
|
|
size = 4096
|
|
|
|
contents = ''.join(random.choice(string.ascii_uppercase + string.digits) for _ in range(size))
|
|
|
|
return layer_bytes_for_contents(contents)
|