fix(exchange): preserve old archives during server key rotation
All checks were successful
State Corp Backend CI/CD / Quality gate (push) Successful in 3m19s
State Corp Backend CI/CD / Build linux/amd64 images once (push) Successful in 2m54s
State Corp Backend CI/CD / Refresh and release internal main (push) Has been skipped
State Corp Backend CI/CD / Release customer main (push) Has been skipped
State Corp Backend CI/CD / Release dev (push) Successful in 54s
All checks were successful
State Corp Backend CI/CD / Quality gate (push) Successful in 3m19s
State Corp Backend CI/CD / Build linux/amd64 images once (push) Successful in 2m54s
State Corp Backend CI/CD / Refresh and release internal main (push) Has been skipped
State Corp Backend CI/CD / Release customer main (push) Has been skipped
State Corp Backend CI/CD / Release dev (push) Successful in 54s
This commit is contained in:
@@ -58,6 +58,8 @@ def build_exchange_archive(
|
||||
bin_name: str = "exchange_package_20260407.bin",
|
||||
data: dict[str, list[dict[str, object]]] | None = None,
|
||||
schema_version: int = ExchangePackageImportService.SUPPORTED_SCHEMA_VERSION,
|
||||
token: str = TEST_TOKEN,
|
||||
key_id: str = "test-shared-token",
|
||||
) -> SimpleUploadedFile:
|
||||
"""Build encrypted exchange archive compatible with import service."""
|
||||
provided_data = data or {}
|
||||
@@ -92,13 +94,13 @@ def build_exchange_archive(
|
||||
compressed_payload = zlib.compress(payload_bytes, level=9)
|
||||
nonce = b"sc-exch-0001"
|
||||
aad = ExchangePackageImportService.AAD
|
||||
raw_key = hashlib.sha256(TEST_TOKEN.encode("utf-8")).digest()
|
||||
raw_key = hashlib.sha256(token.encode("utf-8")).digest()
|
||||
encrypted_payload = AESGCM(raw_key).encrypt(nonce, compressed_payload, aad)
|
||||
|
||||
header = {
|
||||
"format": ExchangePackageImportService.BIN_FORMAT,
|
||||
"version": 1,
|
||||
"key_id": "test-shared-token",
|
||||
"key_id": key_id,
|
||||
"nonce": _b64url(nonce),
|
||||
"aad": _b64url(aad),
|
||||
"package_id": package_id,
|
||||
|
||||
Reference in New Issue
Block a user