Skip to content

Commit

Permalink
Merge pull request #2519 from alphagov/PP-6977-mask_card_number_and_s…
Browse files Browse the repository at this point in the history
…ecurity_code_pact_tests

PP-6977 Mask Moto credit card number and security code pact tests
  • Loading branch information
narinderchana authored Sep 3, 2020
2 parents 9981adf + 49272e4 commit 1d54c9c
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 5 deletions.
23 changes: 22 additions & 1 deletion src/test/java/uk/gov/pay/connector/it/dao/DatabaseFixtures.java
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,9 @@ EmailNotificationType.REFUND_ISSUED, new TestEmailNotification()
private long corporatePrepaidCreditCardSurchargeAmount;
private long corporatePrepaidDebitCardSurchargeAmount;
private int integrationVersion3ds = 2;
private boolean allowMoto;
private boolean motoMaskCardNumberInput;
private boolean motoMaskCardSecurityCodeInput;

public long getAccountId() {
return accountId;
Expand Down Expand Up @@ -455,6 +458,21 @@ public TestAccount withIntegrationVersion3ds(int integrationVersion3ds) {
return this;
}

public TestAccount withAllowMoto(boolean allowMoto) {
this.allowMoto = allowMoto;
return this;
}

public TestAccount withMotoMaskCardNumberInput(boolean motoMaskCardNumberInput) {
this.motoMaskCardNumberInput = motoMaskCardNumberInput;
return this;
}

public TestAccount withMotoMaskCardSecurityCodeInput(boolean motoMaskCardSecurityCodeInput) {
this.motoMaskCardSecurityCodeInput = motoMaskCardSecurityCodeInput;
return this;
}

public TestAccount insert() {
databaseTestHelper.addGatewayAccount(anAddGatewayAccountParams()
.withAccountId(String.valueOf(accountId))
Expand All @@ -470,6 +488,9 @@ public TestAccount insert() {
.withCorporatePrepaidCreditCardSurchargeAmount(corporatePrepaidCreditCardSurchargeAmount)
.withCorporatePrepaidDebitCardSurchargeAmount(corporatePrepaidDebitCardSurchargeAmount)
.withIntegrationVersion3ds(integrationVersion3ds)
.withAllowMoto(allowMoto)
.withMotoMaskCardNumberInput(motoMaskCardNumberInput)
.withMotoMaskCardSecurityCodeInput(motoMaskCardSecurityCodeInput)
.build());
for (TestCardType cardType : cardTypes) {
databaseTestHelper.addAcceptedCardType(this.getAccountId(), cardType.getId());
Expand Down Expand Up @@ -533,7 +554,7 @@ public TestCharge withReturnUrl(String returnUrl) {
this.returnUrl = returnUrl;
return this;
}

public TestCharge withChargeStatus(ChargeStatus chargeStatus) {
this.chargeStatus = chargeStatus;
return this;
Expand Down
12 changes: 12 additions & 0 deletions src/test/java/uk/gov/pay/connector/pact/ContractTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,18 @@ public void anAccountExists() {
.withPaymentProvider(aDigitalWalletSupportedPaymentProvider)
.insert();
}

@State("a gateway account with MOTO enabled and an external id 667 exists in the database")
public void anAccountExistsWithMotoEnableAndMaskCardNumberAndSecurityCode() {
DatabaseFixtures
.withDatabaseTestHelper(dbHelper)
.aTestAccount()
.withAccountId(667L)
.withAllowMoto(true)
.withMotoMaskCardNumberInput(true)
.withMotoMaskCardSecurityCodeInput(true)
.insert();
}

@State("gateway accounts with ids 111, 222 exist in the database")
public void multipleGatewayAccountsExist() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ public class AddGatewayAccountParams {
private long corporatePrepaidDebitCardSurchargeAmount;
private int integrationVersion3ds;
private boolean allowMoto;
private boolean motoMaskCardNumberInput;
private boolean motoMaskCardSecurityCodeInput;
private boolean allowApplePay;
private boolean allowGooglePay;
private boolean requires3ds;
Expand Down Expand Up @@ -83,6 +85,14 @@ public boolean isAllowMoto() {
return allowMoto;
}

public boolean isMotoMaskCardNumberInput() {
return motoMaskCardNumberInput;
}

public boolean isMotoMaskCardSecurityCodeInput() {
return motoMaskCardSecurityCodeInput;
}

public boolean isAllowApplePay() {
return allowApplePay;
}
Expand Down Expand Up @@ -110,6 +120,8 @@ public static final class AddGatewayAccountParamsBuilder {
private long corporatePrepaidDebitCardSurchargeAmount;
private int integrationVersion3ds = 2;
private boolean allowMoto;
private boolean motoMaskCardNumberInput;
private boolean motoMaskCardSecurityCodeInput;
private boolean allowApplePay;
private boolean allowGooglePay;
private boolean requires3ds;
Expand Down Expand Up @@ -185,6 +197,16 @@ public AddGatewayAccountParamsBuilder withAllowMoto(boolean allowMoto) {
this.allowMoto = allowMoto;
return this;
}

public AddGatewayAccountParamsBuilder withMotoMaskCardNumberInput(boolean motoMaskCardNumberInput) {
this.motoMaskCardNumberInput = motoMaskCardNumberInput;
return this;
}

public AddGatewayAccountParamsBuilder withMotoMaskCardSecurityCodeInput(boolean motoMaskCardSecurityCodeInput) {
this.motoMaskCardSecurityCodeInput = motoMaskCardSecurityCodeInput;
return this;
}

public AddGatewayAccountParamsBuilder withAllowApplePay(boolean allowApplePay) {
this.allowApplePay = allowApplePay;
Expand Down Expand Up @@ -217,6 +239,8 @@ public AddGatewayAccountParams build() {
addGatewayAccountParams.corporateDebitCardSurchargeAmount = this.corporateDebitCardSurchargeAmount;
addGatewayAccountParams.integrationVersion3ds = this.integrationVersion3ds;
addGatewayAccountParams.allowMoto = this.allowMoto;
addGatewayAccountParams.motoMaskCardNumberInput = this.motoMaskCardNumberInput;
addGatewayAccountParams.motoMaskCardSecurityCodeInput = this.motoMaskCardSecurityCodeInput;
addGatewayAccountParams.allowApplePay = this.allowApplePay;
addGatewayAccountParams.allowGooglePay = this.allowGooglePay;
addGatewayAccountParams.requires3ds = this.requires3ds;
Expand Down
11 changes: 7 additions & 4 deletions src/test/java/uk/gov/pay/connector/util/DatabaseTestHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,15 @@ public void addGatewayAccount(AddGatewayAccountParams params) {
"service_name, type, description, analytics_id, email_collection_mode, " +
"integration_version_3ds, corporate_credit_card_surcharge_amount, " +
"corporate_debit_card_surcharge_amount, corporate_prepaid_credit_card_surcharge_amount, " +
"corporate_prepaid_debit_card_surcharge_amount, allow_moto, allow_apple_pay, " +
"allow_google_pay, requires_3ds) " +
"corporate_prepaid_debit_card_surcharge_amount, allow_moto, moto_mask_card_number_input, " +
"moto_mask_card_security_code_input, allow_apple_pay, allow_google_pay, requires_3ds) " +
"VALUES (:id, :payment_provider, :credentials, :service_name, :type, " +
":description, :analytics_id, :email_collection_mode, :integration_version_3ds, " +
":corporate_credit_card_surcharge_amount, :corporate_debit_card_surcharge_amount, " +
":corporate_prepaid_credit_card_surcharge_amount, " +
":corporate_prepaid_debit_card_surcharge_amount, :allow_moto, :allow_apple_pay, " +
":allow_google_pay, :requires_3ds)")
":corporate_prepaid_debit_card_surcharge_amount, "+
":allow_moto, :moto_mask_card_number_input, :moto_mask_card_security_code_input, "+
":allow_apple_pay, :allow_google_pay, :requires_3ds)")
.bind("id", Long.valueOf(params.getAccountId()))
.bind("payment_provider", params.getPaymentGateway())
.bindBySqlType("credentials", jsonObject, OTHER)
Expand All @@ -72,6 +73,8 @@ public void addGatewayAccount(AddGatewayAccountParams params) {
.bind("corporate_prepaid_credit_card_surcharge_amount", params.getCorporatePrepaidCreditCardSurchargeAmount())
.bind("corporate_prepaid_debit_card_surcharge_amount", params.getCorporatePrepaidDebitCardSurchargeAmount())
.bind("allow_moto", params.isAllowMoto())
.bind("moto_mask_card_number_input", params.isMotoMaskCardNumberInput())
.bind("moto_mask_card_security_code_input", params.isMotoMaskCardSecurityCodeInput())
.bind("allow_apple_pay", params.isAllowApplePay())
.bind("allow_google_pay", params.isAllowGooglePay())
.bind("requires_3ds", params.isRequires3ds())
Expand Down

0 comments on commit 1d54c9c

Please sign in to comment.