Skip to content

Commit 31a4df4

Browse files
committed
feat: Payment Cryptography: avoid backend lookup in KCV test
1 parent 388f527 commit 31a4df4

1 file changed

Lines changed: 7 additions & 10 deletions

File tree

tests/test_paymentcryptography/test_control_plane.py

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,7 @@
1010
from cryptography.hazmat.primitives.ciphers.algorithms import AES
1111

1212
from moto import mock_aws
13-
from moto.core import DEFAULT_ACCOUNT_ID
14-
from moto.paymentcryptography.models import (
15-
PaymentCryptographyControlPlaneBackend,
16-
paymentcryptography_backends,
17-
)
13+
from moto.paymentcryptography.models import PaymentCryptographyControlPlaneBackend
1814
from moto.paymentcryptography.responses import PaymentCryptographyControlPlaneResponse
1915

2016
ATTRIBUTES = {
@@ -235,13 +231,14 @@ def test_import_export_certificates_and_token_reuse():
235231

236232

237233
@mock_aws
238-
def test_kcv_matches_aes_cmac():
234+
def test_kcv_matches_aes_cmac(monkeypatch):
235+
material = bytes(range(16))
236+
monkeypatch.setattr(
237+
"moto.paymentcryptography.models.os.urandom", lambda size: material[:size]
238+
)
239239
pc = client()
240240
key = pc.create_key(KeyAttributes=ATTRIBUTES, Exportable=True)["Key"]
241-
backend_key = paymentcryptography_backends[DEFAULT_ACCOUNT_ID]["us-east-1"].keys[
242-
key["KeyArn"]
243-
]
244-
calculator = cmac.CMAC(AES(backend_key.material))
241+
calculator = cmac.CMAC(AES(material))
245242
calculator.update(bytes(16))
246243
assert key["KeyCheckValue"] == calculator.finalize()[:3].hex().upper()
247244

0 commit comments

Comments
 (0)