From c6ec0fda878a5024939159a3fdf04158762956ff Mon Sep 17 00:00:00 2001 From: Margus Sipria Date: Tue, 14 Nov 2023 10:47:20 +0200 Subject: [PATCH 1/4] Create maven.yml action config Adding GitHub action for testing --- .github/workflows/maven.yml | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 .github/workflows/maven.yml diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml new file mode 100644 index 0000000..5789c15 --- /dev/null +++ b/.github/workflows/maven.yml @@ -0,0 +1,37 @@ +name: Java CI with Maven + +on: + push: + branches: [ "master" ] + pull_request: + branches: [ "master" ] + +jobs: + build: + + runs-on: ubuntu-latest + + strategy: + matrix: + java-version: [8, 11] + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Set up JDK ${{ matrix.java-version }} + uses: actions/setup-java@v3 + with: + java-version: ${{ matrix.java-version }} + distribution: 'temurin' + cache: maven + + - name: Cache Maven dependencies + uses: actions/cache@v2 + with: + path: | + ~/.m2/repository + key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} + + - name: Build and Test with Maven + run: mvn clean test From 64d69e2802f25853edf175a9e3722d4fa7a0ff2b Mon Sep 17 00:00:00 2001 From: Margus Sipria Date: Tue, 14 Nov 2023 10:52:15 +0200 Subject: [PATCH 2/4] Removed .travis.yml config --- .travis.yml | 9 --------- 1 file changed, 9 deletions(-) delete mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 91b87e0..0000000 --- a/.travis.yml +++ /dev/null @@ -1,9 +0,0 @@ -language: java - -jdk: - - openjdk8 - - openjdk11 - -cache: - directories: - - $HOME/.m2 From afcdf4c8cc0d22bd548e23284dae826254932029 Mon Sep 17 00:00:00 2001 From: Margus Sipria Date: Tue, 14 Nov 2023 11:15:13 +0200 Subject: [PATCH 3/4] Fixed unit tests and upgraded test cards --- .../io/paymenthighway/PaymentAPITest.java | 30 +++++++++---------- .../connect/FormAPIConnectionTest.java | 2 +- .../connect/PaymentAPIConnectionTest.java | 26 ++++++++-------- 3 files changed, 29 insertions(+), 29 deletions(-) diff --git a/src/test/java/io/paymenthighway/PaymentAPITest.java b/src/test/java/io/paymenthighway/PaymentAPITest.java index f0b8d34..9b12224 100644 --- a/src/test/java/io/paymenthighway/PaymentAPITest.java +++ b/src/test/java/io/paymenthighway/PaymentAPITest.java @@ -81,8 +81,8 @@ private PaymentAPI createPaymentAPI() { static private final String RESULT_CODE_OK = "100"; static private final String RESULT_CODE_SOFT_DECLINE = "400"; - private static Card validTestCard = new Card("4153013999700321", "2023", "11", "321"); - private static Card softDeclineCard = new Card("4153013999701170", "2023", "11", "170"); + private static Card validTestCard = new Card("4153013999700321", "2026", "11", "321"); + private static Card softDeclineCard = new Card("4153013999701170", "2026", "11", "170"); private UUID initTransaction(PaymentAPI paymentAPI) throws IOException { InitTransactionResponse response = paymentAPI.initTransaction(); @@ -148,7 +148,7 @@ public void testDebitWithCard() { String pan = "4153013999700024"; String cvc = "024"; - String expiryYear = "2023"; + String expiryYear = "2026"; String expiryMonth = "11"; Card card = new Card(pan, expiryYear, expiryMonth, cvc); TransactionRequest transaction = new TransactionRequest(card, "9999", "EUR"); @@ -319,7 +319,7 @@ public void testCommitWithCardTransaction() { String pan = "4153013999700024"; String cvc = "024"; - String expiryYear = "2023"; + String expiryYear = "2026"; String expiryMonth = "11"; Card card = new Card(pan, expiryYear, expiryMonth, cvc); @@ -377,7 +377,7 @@ public void testRevertTransaction() { String pan = "4153013999700024"; String cvc = "024"; - String expiryYear = "2023"; + String expiryYear = "2026"; String expiryMonth = "11"; Card card = new Card(pan, expiryYear, expiryMonth, cvc); @@ -428,7 +428,7 @@ public void testRevertFullAmountTransaction() { String pan = "4153013999700024"; String cvc = "024"; - String expiryYear = "2023"; + String expiryYear = "2026"; String expiryMonth = "11"; Card card = new Card(pan, expiryYear, expiryMonth, cvc); @@ -493,7 +493,7 @@ public void testTransactionStatus() { String pan = "4153013999700024"; String cvc = "024"; - String expiryYear = "2023"; + String expiryYear = "2026"; String expiryMonth = "11"; Card card = new Card(pan, expiryYear, expiryMonth, cvc); @@ -561,7 +561,7 @@ public void testOrderSearch() { String pan = "4153013999700024"; String cvc = "024"; - String expiryYear = "2023"; + String expiryYear = "2026"; String expiryMonth = "11"; Card card = new Card(pan, expiryYear, expiryMonth, cvc); UUID orderId = UUID.randomUUID(); @@ -657,7 +657,7 @@ public void testCommit() { submitParameters.add(new BasicNameValuePair("card_number_formatted", "4153 0139 9970 0024")); submitParameters.add(new BasicNameValuePair("card_number", "4153013999700024")); submitParameters.add(new BasicNameValuePair("expiration_month", "11")); - submitParameters.add(new BasicNameValuePair("expiration_year", "2023")); + submitParameters.add(new BasicNameValuePair("expiration_year", "2026")); submitParameters.add(new BasicNameValuePair("expiry", "11 / 17")); submitParameters.add(new BasicNameValuePair("cvv", "024")); @@ -700,7 +700,7 @@ public void testCommit() { assertEquals(commitResponse.getResult().getMessage(), "OK"); assertTrue(commitResponse.getCardToken().toString().length() == 36); assertEquals(commitResponse.getCard().getPartialPan(), "0024"); - assertEquals(commitResponse.getCard().getExpireYear(), "2023"); + assertEquals(commitResponse.getCard().getExpireYear(), "2026"); } @@ -737,7 +737,7 @@ public void testTokenize() { submitParameters.add(new BasicNameValuePair("card_number_formatted", "4153 0139 9970 0024")); submitParameters.add(new BasicNameValuePair("card_number", "4153013999700024")); submitParameters.add(new BasicNameValuePair("expiration_month", "11")); - submitParameters.add(new BasicNameValuePair("expiration_year", "2023")); + submitParameters.add(new BasicNameValuePair("expiration_year", "2026")); submitParameters.add(new BasicNameValuePair("expiry", "11 / 17")); submitParameters.add(new BasicNameValuePair("cvv", "024")); @@ -773,10 +773,10 @@ public void testTokenize() { } assertNotNull(tokenResponse); - assertEquals(tokenResponse.getCard().getExpireYear(), "2023"); + assertEquals(tokenResponse.getCard().getExpireYear(), "2026"); assertTrue(tokenResponse.getCardToken().toString().length() == 36); assertEquals(tokenResponse.getResult().getMessage(), "OK"); - assertEquals(tokenResponse.getCard().getCvcRequired(), "no"); + assertEquals(tokenResponse.getCard().getCvcRequired(), "not_tested"); } @@ -812,7 +812,7 @@ public void testDebitWithToken() { submitParameters.add(new BasicNameValuePair("card_number_formatted", "4153 0139 9970 0024")); submitParameters.add(new BasicNameValuePair("card_number", "4153013999700024")); submitParameters.add(new BasicNameValuePair("expiration_month", "11")); - submitParameters.add(new BasicNameValuePair("expiration_year", "2023")); + submitParameters.add(new BasicNameValuePair("expiration_year", "2026")); submitParameters.add(new BasicNameValuePair("expiry", "11 / 17")); submitParameters.add(new BasicNameValuePair("cvv", "024")); @@ -848,7 +848,7 @@ public void testDebitWithToken() { } assertNotNull(tokenResponse); - assertEquals(tokenResponse.getCard().getExpireYear(), "2023"); + assertEquals(tokenResponse.getCard().getExpireYear(), "2026"); assertTrue(tokenResponse.getCardToken().toString().length() == 36); assertEquals(tokenResponse.getResult().getMessage(), "OK"); diff --git a/src/test/java/io/paymenthighway/connect/FormAPIConnectionTest.java b/src/test/java/io/paymenthighway/connect/FormAPIConnectionTest.java index 0fa9b06..9747629 100644 --- a/src/test/java/io/paymenthighway/connect/FormAPIConnectionTest.java +++ b/src/test/java/io/paymenthighway/connect/FormAPIConnectionTest.java @@ -288,6 +288,6 @@ public void testGetFormSubmitResponse() { assertTrue(matcher.find()); String formUri = matcher.group(); - postCardFormAndReturnLastQueryString(this.serviceUrl, formUri, "4153013999700024", "11", "2023", "024"); + postCardFormAndReturnLastQueryString(this.serviceUrl, formUri, "4153013999700024", "11", "2026", "024"); } } diff --git a/src/test/java/io/paymenthighway/connect/PaymentAPIConnectionTest.java b/src/test/java/io/paymenthighway/connect/PaymentAPIConnectionTest.java index 6b19a8b..ec8d3ad 100644 --- a/src/test/java/io/paymenthighway/connect/PaymentAPIConnectionTest.java +++ b/src/test/java/io/paymenthighway/connect/PaymentAPIConnectionTest.java @@ -479,7 +479,7 @@ public void testDebitTransaction5() { TokenizationResponse tokenResponse = createAndTestTokenizationId("4153013999700024", "11", "2023", "024"); - assertEquals("no", tokenResponse.getCard().getCvcRequired()); + assertEquals("not_tested", tokenResponse.getCard().getCvcRequired()); assertEquals("debit", tokenResponse.getCard().getFunding()); assertEquals("unknown", tokenResponse.getCard().getCategory()); @@ -526,7 +526,7 @@ public void testDebitTransaction5() { ); assertEquals("9999", statusResponse.getTransaction().getCurrentAmount()); assertEquals(transactionId, statusResponse.getTransaction().getId()); - assertEquals("no", statusResponse.getTransaction().getCard().getCvcRequired()); + assertEquals("not_tested", statusResponse.getTransaction().getCard().getCvcRequired()); checkAcquirerInfo(statusResponse.getTransaction(), "000"); } @@ -822,7 +822,7 @@ public void testRevertTransaction4() { String pan = "4153013999700024"; String cvc = "024"; - String expiryYear = "2023"; + String expiryYear = "2026"; String expiryMonth = "11"; Card card = new Card(pan, expiryYear, expiryMonth, cvc); @@ -883,7 +883,7 @@ public void testRevertTransaction5() { String pan = "4153013999700024"; String cvc = "024"; - String expiryYear = "2023"; + String expiryYear = "2026"; String expiryMonth = "11"; Card card = new Card(pan, expiryYear, expiryMonth, cvc); @@ -951,7 +951,7 @@ public void testRevertTransaction6() { String pan = "4153013999700024"; String cvc = "024"; - String expiryYear = "2023"; + String expiryYear = "2026"; String expiryMonth = "11"; Card card = new Card(pan, expiryYear, expiryMonth, cvc); @@ -1018,7 +1018,7 @@ public void testTransactionStatus1() { String pan = "4153013999700024"; String cvc = "024"; - String expiryYear = "2023"; + String expiryYear = "2026"; String expiryMonth = "11"; Card card = new Card(pan, expiryYear, expiryMonth, cvc); Customer customer = new Customer("83.145.208.186"); @@ -1091,7 +1091,7 @@ public void testTransactionStatus2() { String pan = "4153013999700024"; String cvc = "024"; - String expiryYear = "2023"; + String expiryYear = "2026"; String expiryMonth = "11"; Card card = new Card(pan, expiryYear, expiryMonth, cvc); Customer customer = new Customer("83.145.208.186"); @@ -1162,7 +1162,7 @@ public void testOrderSearch1() { String pan = "4153013999700024"; String cvc = "024"; - String expiryYear = "2023"; + String expiryYear = "2026"; String expiryMonth = "11"; Card card = new Card(pan, expiryYear, expiryMonth, cvc); UUID orderId = UUID.randomUUID(); @@ -1312,7 +1312,7 @@ public void testTokenization() { // 1. execute a new add_card request using our test form (target staging), // 2. replace with the value of query parameter "sph-tokenization-id" found in success redirect URL, // 3. adjust assertions. - UUID tokenizationId = UUID.fromString("475d49ec-2c37-4ae5-a6ef-33dc6b60ac71"); + UUID tokenizationId = UUID.fromString("ffdd479c-f783-49fa-9c01-5bb60d3f9e57"); TokenizationResponse tokenResponse = null; try { @@ -1321,9 +1321,9 @@ public void testTokenization() { e.printStackTrace(); } assertNotNull(tokenResponse); - assertEquals("2017", tokenResponse.getCard().getExpireYear()); - assertEquals("71435029-fbb6-4506-aa86-8529efb640b0", tokenResponse.getCardToken().toString()); - assertEquals("no", tokenResponse.getCard().getCvcRequired()); + assertEquals("2026", tokenResponse.getCard().getExpireYear()); + assertEquals("feabf8e0-6836-4f9a-88e7-5e34e6c9320e", tokenResponse.getCardToken().toString()); + assertEquals("not_tested", tokenResponse.getCard().getCvcRequired()); assertEquals("415301", tokenResponse.getCard().getBin()); assertEquals("debit", tokenResponse.getCard().getFunding()); assertEquals("unknown", tokenResponse.getCard().getCategory()); @@ -1331,7 +1331,7 @@ public void testTokenization() { // Customer information from the time the tokenizationId was generated through the Form API add_card request assertEquals("83.145.208.185", tokenResponse.getCustomer().getNetworkAddress()); // Manually updated :/ assertEquals("FI", tokenResponse.getCustomer().getCountryCode()); - assertEquals("no", tokenResponse.getCardholderAuthentication()); + assertEquals("attempted", tokenResponse.getCardholderAuthentication()); checkAcquirerInfo(tokenResponse, "060"); } From 5df28e8fdf4c0b4c8ada5990770a8c811d0d8306 Mon Sep 17 00:00:00 2001 From: Margus Sipria Date: Tue, 14 Nov 2023 11:37:16 +0200 Subject: [PATCH 4/4] Using cache from setup-java --- .github/workflows/maven.yml | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 5789c15..c09c3a2 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -18,7 +18,7 @@ jobs: steps: - name: Checkout code uses: actions/checkout@v3 - + - name: Set up JDK ${{ matrix.java-version }} uses: actions/setup-java@v3 with: @@ -26,12 +26,5 @@ jobs: distribution: 'temurin' cache: maven - - name: Cache Maven dependencies - uses: actions/cache@v2 - with: - path: | - ~/.m2/repository - key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} - - name: Build and Test with Maven run: mvn clean test