diff --git a/compatibility-tests/sdk-test-awscli/test/payment-cryptography-card.bats b/compatibility-tests/sdk-test-awscli/test/payment-cryptography-card.bats index a4569bc673..044349ca49 100644 --- a/compatibility-tests/sdk-test-awscli/test/payment-cryptography-card.bats +++ b/compatibility-tests/sdk-test-awscli/test/payment-cryptography-card.bats @@ -65,11 +65,20 @@ create_acg() { CVK_ARN=$(create_cvk) [ -n "$CVK_ARN" ] + run aws_cmd payment-cryptography-data generate-card-validation-data \ + --key-identifier "$CVK_ARN" \ + --primary-account-number "5081470082639564" \ + --generation-attributes 'CardVerificationValue1={CardExpiryDate=3003,ServiceCode=201}' + assert_success + VALUE=$(json_get "$output" '.ValidationData') + # The card's own value with another first digit, so it can't be the key's own. + INVALID="$([ "${VALUE:0:1}" = 0 ] && echo 1 || echo 0)${VALUE:1}" + # The value is not the one over the card account, so the verification fails. run aws_cmd payment-cryptography-data verify-card-validation-data \ --key-identifier "$CVK_ARN" \ --primary-account-number "5081470082639564" \ - --validation-data "999" \ + --validation-data "$INVALID" \ --verification-attributes 'CardVerificationValue1={CardExpiryDate=3003,ServiceCode=201}' assert_failure # A value that does not verify is a verification that failed, not a malformed request. diff --git a/compatibility-tests/sdk-test-awscli/test/payment-cryptography-pin.bats b/compatibility-tests/sdk-test-awscli/test/payment-cryptography-pin.bats index 206e8002fa..a9bc33ad87 100644 --- a/compatibility-tests/sdk-test-awscli/test/payment-cryptography-pin.bats +++ b/compatibility-tests/sdk-test-awscli/test/payment-cryptography-pin.bats @@ -79,6 +79,9 @@ create_pvk() { --generation-attributes 'VisaPin={PinVerificationKeyIndex=1}' assert_success BLOCK=$(json_get "$output" '.EncryptedPinBlock') + PVV=$(json_get "$output" '.PinData.VerificationValue') + # The PIN's own verification value with another first digit, so it can't be the key's own. + INVALID="$([ "${PVV:0:1}" = 0 ] && echo 1 || echo 0)${PVV:1}" # The verification value is not the one over the PIN, so the verification fails. run aws_cmd payment-cryptography-data verify-pin-data \ @@ -87,7 +90,7 @@ create_pvk() { --pin-block-format ISO_FORMAT_0 \ --primary-account-number "5081470082639564" \ --encrypted-pin-block "$BLOCK" \ - --verification-attributes 'VisaPin={PinVerificationKeyIndex=1,VerificationValue=9999}' + --verification-attributes "VisaPin={PinVerificationKeyIndex=1,VerificationValue=$INVALID}" assert_failure # A PIN that does not verify is a verification that failed, not a malformed request. [[ "$output" == *"VerificationFailedException"* ]] diff --git a/compatibility-tests/sdk-test-java/src/test/java/com/floci/test/PaymentCryptographyCardTest.java b/compatibility-tests/sdk-test-java/src/test/java/com/floci/test/PaymentCryptographyCardTest.java index 8336b1404c..d2e96fa3a6 100644 --- a/compatibility-tests/sdk-test-java/src/test/java/com/floci/test/PaymentCryptographyCardTest.java +++ b/compatibility-tests/sdk-test-java/src/test/java/com/floci/test/PaymentCryptographyCardTest.java @@ -134,8 +134,7 @@ class PaymentCryptographyCardTest { @Test void aCardVerificationValueThatDoesNotVerifyIsRefused() { String value = generateCardVerificationValue().validationData(); - String differentFirstDigit = value.startsWith("0") ? "1" : "0"; - String invalidValue = differentFirstDigit + value.substring(1); + String invalidValue = PaymentCryptographyValues.withAnotherFirstDigit(value); assertThatThrownBy(() -> client.verifyCardValidationData(r -> r .keyIdentifier(cardVerificationKeyArn) diff --git a/compatibility-tests/sdk-test-java/src/test/java/com/floci/test/PaymentCryptographyPinTest.java b/compatibility-tests/sdk-test-java/src/test/java/com/floci/test/PaymentCryptographyPinTest.java index c9eeea595e..09379c1979 100644 --- a/compatibility-tests/sdk-test-java/src/test/java/com/floci/test/PaymentCryptographyPinTest.java +++ b/compatibility-tests/sdk-test-java/src/test/java/com/floci/test/PaymentCryptographyPinTest.java @@ -122,7 +122,7 @@ class PaymentCryptographyPinTest { @Test void aPinThatDoesNotVerifyIsRefused() { - String block = client.generatePinData(r -> r + GeneratePinDataResponse generated = client.generatePinData(r -> r .encryptionKeyIdentifier(pinEncryptionKeyArn) .generationKeyIdentifier(visaVerificationKeyArn) .pinBlockFormat(PinBlockFormatForPinData.ISO_FORMAT_0) @@ -131,8 +131,10 @@ class PaymentCryptographyPinTest { .visaPin(VisaPin.builder() .pinVerificationKeyIndex(VERIFICATION_KEY_INDEX) .build()) - .build())) - .encryptedPinBlock(); + .build())); + String block = generated.encryptedPinBlock(); + String value = generated.pinData().verificationValue(); + String invalidValue = PaymentCryptographyValues.withAnotherFirstDigit(value); // The verification value is not the one over the PIN, so the verification fails. assertThatThrownBy(() -> client.verifyPinData(r -> r @@ -144,7 +146,7 @@ class PaymentCryptographyPinTest { .verificationAttributes(PinVerificationAttributes.builder() .visaPin(VisaPinVerification.builder() .pinVerificationKeyIndex(VERIFICATION_KEY_INDEX) - .verificationValue("9999") + .verificationValue(invalidValue) .build()) .build()))) .isInstanceOf(VerificationFailedException.class); diff --git a/compatibility-tests/sdk-test-java/src/test/java/com/floci/test/PaymentCryptographyValues.java b/compatibility-tests/sdk-test-java/src/test/java/com/floci/test/PaymentCryptographyValues.java new file mode 100644 index 0000000000..cee37d5a00 --- /dev/null +++ b/compatibility-tests/sdk-test-java/src/test/java/com/floci/test/PaymentCryptographyValues.java @@ -0,0 +1,16 @@ +package com.floci.test; + +/** Values the Payment Cryptography tests derive from what a key generated. */ +final class PaymentCryptographyValues { + + private PaymentCryptographyValues() { + } + + /** + * {@code value} with another first digit: a value a test generated under a key of its own, changed so that it + * can't be that key's, as a fixed value could be once in its range. + */ + static String withAnotherFirstDigit(String value) { + return (value.startsWith("0") ? "1" : "0") + value.substring(1); + } +}