Changeset View
Changeset View
Standalone View
Standalone View
swh/journal/tests/conftest.py
Show All 17 Lines | from pytest_kafka import ( | ||||
make_zookeeper_process, make_kafka_server, ZOOKEEPER_CONFIG_TEMPLATE, | make_zookeeper_process, make_kafka_server, ZOOKEEPER_CONFIG_TEMPLATE, | ||||
) | ) | ||||
from swh.model.hashutil import hash_to_bytes | from swh.model.hashutil import hash_to_bytes | ||||
logger = logging.getLogger(__name__) | logger = logging.getLogger(__name__) | ||||
CONTENTS = [ | CONTENTS = [ | ||||
{ | { | ||||
'length': 3, | 'length': 3, | ||||
'sha1': hash_to_bytes( | 'sha1': hash_to_bytes( | ||||
'34973274ccef6ab4dfaaf86599792fa9c3fe4689'), | '34973274ccef6ab4dfaaf86599792fa9c3fe4689'), | ||||
'sha1_git': b'foo', | 'sha1_git': b'foo', | ||||
'blake2s256': b'bar', | 'blake2s256': b'bar', | ||||
'sha256': b'baz', | 'sha256': b'baz', | ||||
'status': 'visible', | 'status': 'visible', | ||||
}, | }, | ||||
] | ] | ||||
duplicate_content1 = { | |||||
'length': 4, | |||||
'sha1': hash_to_bytes( | |||||
'44973274ccef6ab4dfaaf86599792fa9c3fe4689'), | |||||
'sha1_git': b'another-foo', | |||||
'blake2s256': b'another-bar', | |||||
'sha256': b'another-baz', | |||||
'status': 'visible', | |||||
} | |||||
# Craft a sha1 collision | |||||
duplicate_content2 = duplicate_content1.copy() | |||||
sha1_array = bytearray(duplicate_content1['sha1_git']) | |||||
sha1_array[0] += 1 | |||||
duplicate_content2['sha1_git'] = bytes(sha1_array) | |||||
DUPLICATE_CONTENTS = [duplicate_content1, duplicate_content2] | |||||
COMMITTERS = [ | COMMITTERS = [ | ||||
{ | { | ||||
'fullname': b'foo', | 'fullname': b'foo', | ||||
'name': b'foo', | 'name': b'foo', | ||||
'email': b'', | 'email': b'', | ||||
}, | }, | ||||
{ | { | ||||
'fullname': b'bar', | 'fullname': b'bar', | ||||
▲ Show 20 Lines • Show All 199 Lines • Show Last 20 Lines |