mirror of
https://github.com/floci-io/floci.git
synced 2026-11-26 23:29:28 -05:00
test(paymentcryptography): refuse a value other than the generated one, not a fixed one (#9234)
The PIN refusal test of the Java SDK suite, and the card and PIN refusal tests of the AWS CLI suite, verified a fixed value, 9999 or 999, under a key created for the run. The key is new each time, so the fixed value was the key's own once in 10,000 PIN runs and once in 1,000 card runs, and the test then failed: it did on #8611's native arm64 / sdk-test-java job. Each now generates the value under its key and verifies it with another first digit, which can't be it, as the Java card test has done since #8664. The card test and the PIN test of the Java SDK suite each derived the value to refuse by changing the first digit of the one their key generated. That is now PaymentCryptographyValues.withAnotherFirstDigit, and both use it.
This commit is contained in:
1 parent
3a1ea212f0
commit
a2051d4085
5 files changed
+37
-8
No files matched your search
+1
-2
@@ -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)
|
||||
|
||||
+6
-4
@@ -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);
|
||||
|
||||
+16
@@ -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);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user