From a28a808434b0784ea3f17ac86b266e238a658179 Mon Sep 17 00:00:00 2001 From: Dan Corder Date: Tue, 30 Apr 2024 15:30:16 +0100 Subject: [PATCH 01/15] PYIC-5836: Run provider side tests against orchestrator branch --- .github/workflows/contract-tests.yaml | 8 +++++--- lambdas/build-user-identity/build.gradle | 5 +++++ .../pact/BuildUserIdentityHandlerTest.java | 15 +++++++++++++-- lambdas/call-ticf-cri/build.gradle | 2 +- lambdas/process-cri-callback/build.gradle | 2 +- 5 files changed, 25 insertions(+), 7 deletions(-) diff --git a/.github/workflows/contract-tests.yaml b/.github/workflows/contract-tests.yaml index 97a129160e..7cc288bd1a 100644 --- a/.github/workflows/contract-tests.yaml +++ b/.github/workflows/contract-tests.yaml @@ -35,8 +35,10 @@ jobs: java-version: '17' distribution: 'temurin' cache: 'gradle' - - name: Run contract tests - run: ./gradlew --parallel contractTests + - name: Run consumer contract tests + run: ./gradlew --parallel pactConsumerTests - name: Upload pacts to broker with gradle if: ${{ github.actor != 'dependabot[bot]' && github.event_name != 'merge_group' }} - run: ./gradlew pactPublish \ No newline at end of file + run: ./gradlew pactPublish + - name: Verify pacts + run: ./gradlew pactProviderTests \ No newline at end of file diff --git a/lambdas/build-user-identity/build.gradle b/lambdas/build-user-identity/build.gradle index 88d8ac14fd..6c3d741cd5 100644 --- a/lambdas/build-user-identity/build.gradle +++ b/lambdas/build-user-identity/build.gradle @@ -43,6 +43,11 @@ test { finalizedBy jacocoTestReport } +task pactProviderTests (type: Test) { + useJUnitPlatform() + include 'uk/gov/di/ipv/core/builduseridentity/pact/**' +} + jacocoTestReport { dependsOn test reports { diff --git a/lambdas/build-user-identity/src/test/java/uk/gov/di/ipv/core/builduseridentity/pact/BuildUserIdentityHandlerTest.java b/lambdas/build-user-identity/src/test/java/uk/gov/di/ipv/core/builduseridentity/pact/BuildUserIdentityHandlerTest.java index 4d5af38ccd..dea1bd17cc 100644 --- a/lambdas/build-user-identity/src/test/java/uk/gov/di/ipv/core/builduseridentity/pact/BuildUserIdentityHandlerTest.java +++ b/lambdas/build-user-identity/src/test/java/uk/gov/di/ipv/core/builduseridentity/pact/BuildUserIdentityHandlerTest.java @@ -5,7 +5,11 @@ import au.com.dius.pact.provider.junit5.PactVerificationInvocationContextProvider; import au.com.dius.pact.provider.junitsupport.Provider; import au.com.dius.pact.provider.junitsupport.State; +import au.com.dius.pact.provider.junitsupport.loader.PactBroker; +import au.com.dius.pact.provider.junitsupport.loader.PactBrokerAuth; +import au.com.dius.pact.provider.junitsupport.loader.PactBrokerConsumerVersionSelectors; import au.com.dius.pact.provider.junitsupport.loader.PactFolder; +import au.com.dius.pact.provider.junitsupport.loader.SelectorBuilder; import org.apache.commons.codec.digest.DigestUtils; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeAll; @@ -50,9 +54,10 @@ import static uk.gov.di.ipv.core.library.domain.CriConstants.ADDRESS_CRI; import static uk.gov.di.ipv.core.library.domain.CriConstants.DCMAW_CRI; -@PactFolder("pacts") -@Disabled("PACT tests should not be run in build pipelines at this time") @Provider("IpvCoreBackUserIdentityProvider") +@PactBroker( + url = "${PACT_URL}?testSource=${PACT_BROKER_SOURCE_SECRET_DEV}", + authentication = @PactBrokerAuth(username = "${PACT_USER}", password = "${PACT_PASSWORD}")) @ExtendWith(MockitoExtension.class) @MockitoSettings(strictness = Strictness.LENIENT) class BuildUserIdentityHandlerTest { @@ -75,6 +80,12 @@ static void setupServer() { System.setProperty("pact.content_type.override.application/jwt", "text"); } + @PactBrokerConsumerVersionSelectors + public static SelectorBuilder consumerVersionSelectors() { + return new SelectorBuilder().branch("origin/AUT-2711/Indicate_Forced_Password_Reset_For_Audit_Events"); + //qq:DCC .mainBranch().deployedOrReleased(); + } + @BeforeEach void pactSetup(PactVerificationContext context) throws IOException, CiRetrievalException, ParseException, CredentialParseException { diff --git a/lambdas/call-ticf-cri/build.gradle b/lambdas/call-ticf-cri/build.gradle index f01a3c0324..f61b0bb446 100644 --- a/lambdas/call-ticf-cri/build.gradle +++ b/lambdas/call-ticf-cri/build.gradle @@ -45,7 +45,7 @@ test { exclude 'uk/gov/di/ipv/core/callticfcri/pact/**' } -task contractTests (type: Test) { +task pactConsumerTests (type: Test) { useJUnitPlatform() include 'uk/gov/di/ipv/core/callticfcri/pact/**' systemProperties['pact.rootDir'] = "$rootDir/build/pacts" diff --git a/lambdas/process-cri-callback/build.gradle b/lambdas/process-cri-callback/build.gradle index 69516421d6..e54e981e7f 100644 --- a/lambdas/process-cri-callback/build.gradle +++ b/lambdas/process-cri-callback/build.gradle @@ -53,7 +53,7 @@ test { exclude 'uk/gov/di/ipv/core/processcricallback/pact/**' } -task contractTests (type: Test) { +task pactConsumerTests (type: Test) { useJUnitPlatform() include 'uk/gov/di/ipv/core/processcricallback/pact/**' systemProperties['pact.rootDir'] = "$rootDir/build/pacts" From 515d5e94356f2bdf0b6a7809e2513169f611c7a5 Mon Sep 17 00:00:00 2001 From: Dan Corder Date: Tue, 30 Apr 2024 17:07:55 +0100 Subject: [PATCH 02/15] PYIC-5836: Test against main branch --- .../builduseridentity/pact/BuildUserIdentityHandlerTest.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lambdas/build-user-identity/src/test/java/uk/gov/di/ipv/core/builduseridentity/pact/BuildUserIdentityHandlerTest.java b/lambdas/build-user-identity/src/test/java/uk/gov/di/ipv/core/builduseridentity/pact/BuildUserIdentityHandlerTest.java index dea1bd17cc..2eb2f978c9 100644 --- a/lambdas/build-user-identity/src/test/java/uk/gov/di/ipv/core/builduseridentity/pact/BuildUserIdentityHandlerTest.java +++ b/lambdas/build-user-identity/src/test/java/uk/gov/di/ipv/core/builduseridentity/pact/BuildUserIdentityHandlerTest.java @@ -82,8 +82,7 @@ static void setupServer() { @PactBrokerConsumerVersionSelectors public static SelectorBuilder consumerVersionSelectors() { - return new SelectorBuilder().branch("origin/AUT-2711/Indicate_Forced_Password_Reset_For_Audit_Events"); - //qq:DCC .mainBranch().deployedOrReleased(); + return new SelectorBuilder().mainBranch().deployedOrReleased(); } @BeforeEach From a2fada6ce421991fad60148673464cbf3a2b072d Mon Sep 17 00:00:00 2001 From: Dan Corder Date: Tue, 30 Apr 2024 18:26:06 +0100 Subject: [PATCH 03/15] PYIC-5836: Fix pact test --- .../pact/BuildUserIdentityHandlerTest.java | 39 ++++++++----------- 1 file changed, 16 insertions(+), 23 deletions(-) diff --git a/lambdas/build-user-identity/src/test/java/uk/gov/di/ipv/core/builduseridentity/pact/BuildUserIdentityHandlerTest.java b/lambdas/build-user-identity/src/test/java/uk/gov/di/ipv/core/builduseridentity/pact/BuildUserIdentityHandlerTest.java index 2eb2f978c9..9b898a3eac 100644 --- a/lambdas/build-user-identity/src/test/java/uk/gov/di/ipv/core/builduseridentity/pact/BuildUserIdentityHandlerTest.java +++ b/lambdas/build-user-identity/src/test/java/uk/gov/di/ipv/core/builduseridentity/pact/BuildUserIdentityHandlerTest.java @@ -8,13 +8,11 @@ import au.com.dius.pact.provider.junitsupport.loader.PactBroker; import au.com.dius.pact.provider.junitsupport.loader.PactBrokerAuth; import au.com.dius.pact.provider.junitsupport.loader.PactBrokerConsumerVersionSelectors; -import au.com.dius.pact.provider.junitsupport.loader.PactFolder; import au.com.dius.pact.provider.junitsupport.loader.SelectorBuilder; import org.apache.commons.codec.digest.DigestUtils; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.TestTemplate; import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.Mock; @@ -33,7 +31,7 @@ import uk.gov.di.ipv.core.library.persistence.DataStore; import uk.gov.di.ipv.core.library.persistence.item.ClientOAuthSessionItem; import uk.gov.di.ipv.core.library.persistence.item.IpvSessionItem; -import uk.gov.di.ipv.core.library.persistence.item.VcStoreItem; +import uk.gov.di.ipv.core.library.persistence.item.SessionCredentialItem; import uk.gov.di.ipv.core.library.service.AuditService; import uk.gov.di.ipv.core.library.service.CiMitService; import uk.gov.di.ipv.core.library.service.CiMitUtilityService; @@ -64,11 +62,13 @@ class BuildUserIdentityHandlerTest { private static final int PORT = 5050; + private static final String IPV_SESSION_ID = "dummyIpvSessionId"; + private LambdaHttpServer httpServer; @Mock private ConfigService mockConfigService; @Mock private AuditService mockAuditService; @Mock private DataStore mockIpvSessionDataStore; - @Mock private DataStore mockVcStore; + @Mock private DataStore mockSessionCredentialItemStore; @Mock private DataStore mockOAuthSessionStore; @Mock private CiMitService mockCiMitService; @Mock private CiMitUtilityService mockCiMitUtilityService; @@ -114,28 +114,21 @@ void pactSetup(PactVerificationContext context) // 2099-01-01 00:00:00 is 4070908800 in epoch seconds Instant theFuture = Instant.ofEpochSecond(1577836800); - List vcs = new ArrayList<>(); var passportVcBuilder = new PactJwtBuilder( VC_HEADER, VALID_UK_PASSPORT_VC_BODY, VALID_UK_PASSPORT_VC_SIGNATURE); var addressVcBuilder = new PactJwtBuilder(VC_HEADER, VALID_ADDRESS_VC_BODY, VALID_ADDRESS_VC_SIGNATURE); - var passportItem = new VcStoreItem(); - passportItem.setUserId("dummyOAuthUserId"); - passportItem.setCredential(passportVcBuilder.buildJwt()); - passportItem.setCredentialIssuer(DCMAW_CRI); - passportItem.setDateCreated(thePast); - passportItem.setExpirationTime(theFuture); - vcs.add(passportItem); - var addressItem = new VcStoreItem(); - addressItem.setUserId("dummyOAuthUserId"); - addressItem.setCredential(addressVcBuilder.buildJwt()); - addressItem.setCredentialIssuer(ADDRESS_CRI); - addressItem.setDateCreated(thePast); - addressItem.setExpirationTime(theFuture); - vcs.add(addressItem); - - when(mockVcStore.getItems("dummyOAuthUserId")).thenReturn(vcs); + + List sessionCredentials = new ArrayList<>(); + var passportCredential = new SessionCredentialItem(IPV_SESSION_ID, DCMAW_CRI, passportVcBuilder.buildSignedJwt(), true); + var addressCredential = new SessionCredentialItem(IPV_SESSION_ID, ADDRESS_CRI, addressVcBuilder.buildSignedJwt(), true); + sessionCredentials.add(passportCredential); + sessionCredentials.add(addressCredential); + + when(mockSessionCredentialItemStore.getItems(IPV_SESSION_ID)).thenReturn(sessionCredentials); + + var sessionCredentialService = new SessionCredentialsService(mockSessionCredentialItemStore); // Set up the web server for the tests var handler = @@ -147,7 +140,7 @@ void pactSetup(PactVerificationContext context) clientOAuthSessionDetailsService, mockCiMitService, mockCiMitUtilityService, - mockSessionCredentialsService); + sessionCredentialService); httpServer = new LambdaHttpServer(handler, "/user-identity", PORT); httpServer.startServer(); @@ -167,7 +160,7 @@ public void setAuthCode() {} public void setAccessToken() { var accessTokenMetaData = new AccessTokenMetadata(); var ipvSession = new IpvSessionItem(); - ipvSession.setIpvSessionId("dummyIpvSessionId"); + ipvSession.setIpvSessionId(IPV_SESSION_ID); ipvSession.setClientOAuthSessionId("dummyClientOAuthSessionId"); ipvSession.setVot(Vot.P2); From 5c4ff1894af7649919b97df74c718030ce881c84 Mon Sep 17 00:00:00 2001 From: Dan Corder Date: Tue, 30 Apr 2024 19:20:48 +0100 Subject: [PATCH 04/15] PYIC-5836: Fix secrets --- .secrets.baseline | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.secrets.baseline b/.secrets.baseline index a9c9124e4f..4501cfd0bb 100644 --- a/.secrets.baseline +++ b/.secrets.baseline @@ -197,21 +197,21 @@ "filename": "lambdas/build-user-identity/src/test/java/uk/gov/di/ipv/core/builduseridentity/pact/BuildUserIdentityHandlerTest.java", "hashed_secret": "85d1e7563098941624848ca8a7c731a6c013235b", "is_verified": false, - "line_number": 215 + "line_number": 218 }, { "type": "Base64 High Entropy String", "filename": "lambdas/build-user-identity/src/test/java/uk/gov/di/ipv/core/builduseridentity/pact/BuildUserIdentityHandlerTest.java", "hashed_secret": "69facda46567909882c049ea59985c33000974b3", "is_verified": false, - "line_number": 298 + "line_number": 301 }, { "type": "Base64 High Entropy String", "filename": "lambdas/build-user-identity/src/test/java/uk/gov/di/ipv/core/builduseridentity/pact/BuildUserIdentityHandlerTest.java", "hashed_secret": "1bb4f6b3cf1f8b05e40be98e555120bbac8bb8a8", "is_verified": false, - "line_number": 351 + "line_number": 354 } ], "lambdas/call-ticf-cri/src/main/java/uk/gov/di/ipv/core/callticfcri/service/TicfCriService.java": [ @@ -1879,5 +1879,5 @@ } ] }, - "generated_at": "2024-04-30T08:49:19Z" + "generated_at": "2024-04-30T18:19:14Z" } From 7032af7dcd34c291a5acabb451336005f04fcf48 Mon Sep 17 00:00:00 2001 From: Dan Corder Date: Wed, 1 May 2024 14:04:01 +0100 Subject: [PATCH 05/15] PYIC-5836: Upload contract test report --- .github/workflows/contract-tests.yaml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/contract-tests.yaml b/.github/workflows/contract-tests.yaml index 7cc288bd1a..cdf8643bee 100644 --- a/.github/workflows/contract-tests.yaml +++ b/.github/workflows/contract-tests.yaml @@ -41,4 +41,10 @@ jobs: if: ${{ github.actor != 'dependabot[bot]' && github.event_name != 'merge_group' }} run: ./gradlew pactPublish - name: Verify pacts - run: ./gradlew pactProviderTests \ No newline at end of file + run: ./gradlew pactProviderTests + - name: Upload build-user-identity provider pact test report + if: '!cancelled()' + uses: actions/upload-artifact@v4 + with: + name: build-user-identity provider pact test report + path: /home/runner/work/ipv-core-back/ipv-core-back/lambdas/build-user-identity/build/reports/tests/pactProviderTests/ From 8ac07fff3771eda63a87f5dadc733c49073ccde8 Mon Sep 17 00:00:00 2001 From: Dan Corder Date: Wed, 1 May 2024 16:37:06 +0100 Subject: [PATCH 06/15] PYIC-5836: Pause between consumer and provider contract tests --- .github/workflows/contract-tests.yaml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/contract-tests.yaml b/.github/workflows/contract-tests.yaml index cdf8643bee..37b49b8f8e 100644 --- a/.github/workflows/contract-tests.yaml +++ b/.github/workflows/contract-tests.yaml @@ -40,6 +40,12 @@ jobs: - name: Upload pacts to broker with gradle if: ${{ github.actor != 'dependabot[bot]' && github.event_name != 'merge_group' }} run: ./gradlew pactPublish + # The initial call to the pact broker starts a 30 second timer where calls will succeed. As uploading the pacts and + # verifying the pacts together takes over 30s we need to wait for the timer to expire so that the pact verification + # call starts it's own timer. + - name: Sleep for 30 seconds + run: sleep 30s + shell: bash - name: Verify pacts run: ./gradlew pactProviderTests - name: Upload build-user-identity provider pact test report From 934e3847ff0ffb4d297d905b3990d96ac95ac3d6 Mon Sep 17 00:00:00 2001 From: Dan Corder Date: Wed, 1 May 2024 16:47:28 +0100 Subject: [PATCH 07/15] PYIC-5836: Run spotless --- .secrets.baseline | 8 ++++---- .../pact/BuildUserIdentityHandlerTest.java | 14 ++++++++++---- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/.secrets.baseline b/.secrets.baseline index 4501cfd0bb..c222aee819 100644 --- a/.secrets.baseline +++ b/.secrets.baseline @@ -197,21 +197,21 @@ "filename": "lambdas/build-user-identity/src/test/java/uk/gov/di/ipv/core/builduseridentity/pact/BuildUserIdentityHandlerTest.java", "hashed_secret": "85d1e7563098941624848ca8a7c731a6c013235b", "is_verified": false, - "line_number": 218 + "line_number": 224 }, { "type": "Base64 High Entropy String", "filename": "lambdas/build-user-identity/src/test/java/uk/gov/di/ipv/core/builduseridentity/pact/BuildUserIdentityHandlerTest.java", "hashed_secret": "69facda46567909882c049ea59985c33000974b3", "is_verified": false, - "line_number": 301 + "line_number": 307 }, { "type": "Base64 High Entropy String", "filename": "lambdas/build-user-identity/src/test/java/uk/gov/di/ipv/core/builduseridentity/pact/BuildUserIdentityHandlerTest.java", "hashed_secret": "1bb4f6b3cf1f8b05e40be98e555120bbac8bb8a8", "is_verified": false, - "line_number": 354 + "line_number": 360 } ], "lambdas/call-ticf-cri/src/main/java/uk/gov/di/ipv/core/callticfcri/service/TicfCriService.java": [ @@ -1879,5 +1879,5 @@ } ] }, - "generated_at": "2024-04-30T18:19:14Z" + "generated_at": "2024-05-01T15:44:28Z" } diff --git a/lambdas/build-user-identity/src/test/java/uk/gov/di/ipv/core/builduseridentity/pact/BuildUserIdentityHandlerTest.java b/lambdas/build-user-identity/src/test/java/uk/gov/di/ipv/core/builduseridentity/pact/BuildUserIdentityHandlerTest.java index 9b898a3eac..ed16289636 100644 --- a/lambdas/build-user-identity/src/test/java/uk/gov/di/ipv/core/builduseridentity/pact/BuildUserIdentityHandlerTest.java +++ b/lambdas/build-user-identity/src/test/java/uk/gov/di/ipv/core/builduseridentity/pact/BuildUserIdentityHandlerTest.java @@ -121,14 +121,20 @@ void pactSetup(PactVerificationContext context) new PactJwtBuilder(VC_HEADER, VALID_ADDRESS_VC_BODY, VALID_ADDRESS_VC_SIGNATURE); List sessionCredentials = new ArrayList<>(); - var passportCredential = new SessionCredentialItem(IPV_SESSION_ID, DCMAW_CRI, passportVcBuilder.buildSignedJwt(), true); - var addressCredential = new SessionCredentialItem(IPV_SESSION_ID, ADDRESS_CRI, addressVcBuilder.buildSignedJwt(), true); + var passportCredential = + new SessionCredentialItem( + IPV_SESSION_ID, DCMAW_CRI, passportVcBuilder.buildSignedJwt(), true); + var addressCredential = + new SessionCredentialItem( + IPV_SESSION_ID, ADDRESS_CRI, addressVcBuilder.buildSignedJwt(), true); sessionCredentials.add(passportCredential); sessionCredentials.add(addressCredential); - when(mockSessionCredentialItemStore.getItems(IPV_SESSION_ID)).thenReturn(sessionCredentials); + when(mockSessionCredentialItemStore.getItems(IPV_SESSION_ID)) + .thenReturn(sessionCredentials); - var sessionCredentialService = new SessionCredentialsService(mockSessionCredentialItemStore); + var sessionCredentialService = + new SessionCredentialsService(mockSessionCredentialItemStore); // Set up the web server for the tests var handler = From cacb4973d79f856401e983bf1503c8c0df786736 Mon Sep 17 00:00:00 2001 From: Dan Corder Date: Wed, 1 May 2024 16:54:23 +0100 Subject: [PATCH 08/15] PYIC-5836: Don't run contract tests with other unit tests --- lambdas/build-user-identity/build.gradle | 1 + 1 file changed, 1 insertion(+) diff --git a/lambdas/build-user-identity/build.gradle b/lambdas/build-user-identity/build.gradle index 6c3d741cd5..1a5ee8e682 100644 --- a/lambdas/build-user-identity/build.gradle +++ b/lambdas/build-user-identity/build.gradle @@ -41,6 +41,7 @@ test { environment "LAMBDA_TASK_ROOT", "handler" useJUnitPlatform () finalizedBy jacocoTestReport + exclude 'uk/gov/di/ipv/core/builduseridentity/pact/**' } task pactProviderTests (type: Test) { From 4e83ce1471d2855dfc93c4b792dbbc7ae65a062f Mon Sep 17 00:00:00 2001 From: Dan Corder Date: Wed, 1 May 2024 17:04:59 +0100 Subject: [PATCH 09/15] PYIC-5836: Set provider version and branch when verifying pacts. Move some config from code to gradle --- .github/workflows/contract-tests.yaml | 2 +- .secrets.baseline | 8 ++++---- build.gradle | 2 +- lambdas/build-user-identity/build.gradle | 4 ++++ .../pact/BuildUserIdentityHandlerTest.java | 8 -------- 5 files changed, 10 insertions(+), 14 deletions(-) diff --git a/.github/workflows/contract-tests.yaml b/.github/workflows/contract-tests.yaml index 37b49b8f8e..f74a91e7d0 100644 --- a/.github/workflows/contract-tests.yaml +++ b/.github/workflows/contract-tests.yaml @@ -10,7 +10,7 @@ env: # The branch name for a pull request is in a property that only exists on pull request runs. If it doesn't exist # fall back to the branch name property for pushes. GIT_BRANCH: ${{ github.head_ref || github.ref_name }} - CONSUMER_APP_VERSION: ${{ github.sha }} + GIT_SHA: ${{ github.sha }} on: push: diff --git a/.secrets.baseline b/.secrets.baseline index c222aee819..e736108a2a 100644 --- a/.secrets.baseline +++ b/.secrets.baseline @@ -197,21 +197,21 @@ "filename": "lambdas/build-user-identity/src/test/java/uk/gov/di/ipv/core/builduseridentity/pact/BuildUserIdentityHandlerTest.java", "hashed_secret": "85d1e7563098941624848ca8a7c731a6c013235b", "is_verified": false, - "line_number": 224 + "line_number": 216 }, { "type": "Base64 High Entropy String", "filename": "lambdas/build-user-identity/src/test/java/uk/gov/di/ipv/core/builduseridentity/pact/BuildUserIdentityHandlerTest.java", "hashed_secret": "69facda46567909882c049ea59985c33000974b3", "is_verified": false, - "line_number": 307 + "line_number": 299 }, { "type": "Base64 High Entropy String", "filename": "lambdas/build-user-identity/src/test/java/uk/gov/di/ipv/core/builduseridentity/pact/BuildUserIdentityHandlerTest.java", "hashed_secret": "1bb4f6b3cf1f8b05e40be98e555120bbac8bb8a8", "is_verified": false, - "line_number": 360 + "line_number": 352 } ], "lambdas/call-ticf-cri/src/main/java/uk/gov/di/ipv/core/callticfcri/service/TicfCriService.java": [ @@ -1879,5 +1879,5 @@ } ] }, - "generated_at": "2024-05-01T15:44:28Z" + "generated_at": "2024-05-01T16:03:49Z" } diff --git a/build.gradle b/build.gradle index 00aeb13daf..e0637ce11e 100644 --- a/build.gradle +++ b/build.gradle @@ -46,7 +46,7 @@ pact { pactBrokerUrl = "${System.env.PACT_URL}?testSource=${System.env.PACT_BROKER_SOURCE_SECRET_DEV}" pactBrokerUsername = "${System.env.PACT_USER}" pactBrokerPassword = "${System.env.PACT_PASSWORD}" - consumerVersion = "${System.env.CONSUMER_APP_VERSION}" + consumerVersion = "${System.env.GIT_SHA}" consumerBranch = "${System.env.GIT_BRANCH}" } } diff --git a/lambdas/build-user-identity/build.gradle b/lambdas/build-user-identity/build.gradle index 1a5ee8e682..5ce8f20cfa 100644 --- a/lambdas/build-user-identity/build.gradle +++ b/lambdas/build-user-identity/build.gradle @@ -47,6 +47,10 @@ test { task pactProviderTests (type: Test) { useJUnitPlatform() include 'uk/gov/di/ipv/core/builduseridentity/pact/**' + systemProperties['pact.verifier.publishResults'] = "true" + systemProperties['pact.provider.branch'] = "${System.env.GIT_BRANCH}" + systemProperties['pact.provider.version'] = "${System.env.GIT_SHA}" + systemProperties['pact.consumerversionselectors.rawjson'] = "{ \"mainBranch\": true, \"deployedOrReleased\": true }" } jacocoTestReport { diff --git a/lambdas/build-user-identity/src/test/java/uk/gov/di/ipv/core/builduseridentity/pact/BuildUserIdentityHandlerTest.java b/lambdas/build-user-identity/src/test/java/uk/gov/di/ipv/core/builduseridentity/pact/BuildUserIdentityHandlerTest.java index ed16289636..9074aaa9e7 100644 --- a/lambdas/build-user-identity/src/test/java/uk/gov/di/ipv/core/builduseridentity/pact/BuildUserIdentityHandlerTest.java +++ b/lambdas/build-user-identity/src/test/java/uk/gov/di/ipv/core/builduseridentity/pact/BuildUserIdentityHandlerTest.java @@ -7,8 +7,6 @@ import au.com.dius.pact.provider.junitsupport.State; import au.com.dius.pact.provider.junitsupport.loader.PactBroker; import au.com.dius.pact.provider.junitsupport.loader.PactBrokerAuth; -import au.com.dius.pact.provider.junitsupport.loader.PactBrokerConsumerVersionSelectors; -import au.com.dius.pact.provider.junitsupport.loader.SelectorBuilder; import org.apache.commons.codec.digest.DigestUtils; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeAll; @@ -76,15 +74,9 @@ class BuildUserIdentityHandlerTest { @BeforeAll static void setupServer() { - System.setProperty("pact.verifier.publishResults", "true"); System.setProperty("pact.content_type.override.application/jwt", "text"); } - @PactBrokerConsumerVersionSelectors - public static SelectorBuilder consumerVersionSelectors() { - return new SelectorBuilder().mainBranch().deployedOrReleased(); - } - @BeforeEach void pactSetup(PactVerificationContext context) throws IOException, CiRetrievalException, ParseException, CredentialParseException { From 6662c10d33db8ca82e386417e40345abd8be744e Mon Sep 17 00:00:00 2001 From: Dan Corder Date: Wed, 1 May 2024 17:28:10 +0100 Subject: [PATCH 10/15] PYIC-5836: Add comment on how to run provider tests locally --- .../pact/BuildUserIdentityHandlerTest.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lambdas/build-user-identity/src/test/java/uk/gov/di/ipv/core/builduseridentity/pact/BuildUserIdentityHandlerTest.java b/lambdas/build-user-identity/src/test/java/uk/gov/di/ipv/core/builduseridentity/pact/BuildUserIdentityHandlerTest.java index 9074aaa9e7..e6b74620ec 100644 --- a/lambdas/build-user-identity/src/test/java/uk/gov/di/ipv/core/builduseridentity/pact/BuildUserIdentityHandlerTest.java +++ b/lambdas/build-user-identity/src/test/java/uk/gov/di/ipv/core/builduseridentity/pact/BuildUserIdentityHandlerTest.java @@ -50,10 +50,16 @@ import static uk.gov.di.ipv.core.library.domain.CriConstants.ADDRESS_CRI; import static uk.gov.di.ipv.core.library.domain.CriConstants.DCMAW_CRI; +// To run these tests locally you need to: +// - Obtain the relevant pact file (from the pact broker or another team) and put it in +// /lambdas/build-user-identity/pacts +// - Comment out the @PactBroker annotation below +// - Uncomment @PactFolder annotation below @Provider("IpvCoreBackUserIdentityProvider") @PactBroker( url = "${PACT_URL}?testSource=${PACT_BROKER_SOURCE_SECRET_DEV}", authentication = @PactBrokerAuth(username = "${PACT_USER}", password = "${PACT_PASSWORD}")) +// @PactFolder("pacts") @ExtendWith(MockitoExtension.class) @MockitoSettings(strictness = Strictness.LENIENT) class BuildUserIdentityHandlerTest { From 5f10b48175d20fd0db9fdc1cb03789a4cdd21ed8 Mon Sep 17 00:00:00 2001 From: Dan Corder Date: Wed, 1 May 2024 17:29:53 +0100 Subject: [PATCH 11/15] PYIC-5836: Run tests for issue-client-access-token too --- .github/workflows/contract-tests.yaml | 8 +++++++- .secrets.baseline | 20 +++++++++---------- .../issue-client-access-token/build.gradle | 10 ++++++++++ .../IssueClientAccessTokenHandlerTest.java | 15 ++++++++++---- 4 files changed, 38 insertions(+), 15 deletions(-) diff --git a/.github/workflows/contract-tests.yaml b/.github/workflows/contract-tests.yaml index f74a91e7d0..e312f0c405 100644 --- a/.github/workflows/contract-tests.yaml +++ b/.github/workflows/contract-tests.yaml @@ -42,7 +42,7 @@ jobs: run: ./gradlew pactPublish # The initial call to the pact broker starts a 30 second timer where calls will succeed. As uploading the pacts and # verifying the pacts together takes over 30s we need to wait for the timer to expire so that the pact verification - # call starts it's own timer. + # call starts its own timer. - name: Sleep for 30 seconds run: sleep 30s shell: bash @@ -54,3 +54,9 @@ jobs: with: name: build-user-identity provider pact test report path: /home/runner/work/ipv-core-back/ipv-core-back/lambdas/build-user-identity/build/reports/tests/pactProviderTests/ + - name: Upload issue-client-access-token provider pact test report + if: '!cancelled()' + uses: actions/upload-artifact@v4 + with: + name: issue-client-access-token provider pact test report + path: /home/runner/work/ipv-core-back/ipv-core-back/lambdas/issue-client-access-token/build/reports/tests/pactProviderTests/ diff --git a/.secrets.baseline b/.secrets.baseline index e736108a2a..6c4e4044a2 100644 --- a/.secrets.baseline +++ b/.secrets.baseline @@ -197,21 +197,21 @@ "filename": "lambdas/build-user-identity/src/test/java/uk/gov/di/ipv/core/builduseridentity/pact/BuildUserIdentityHandlerTest.java", "hashed_secret": "85d1e7563098941624848ca8a7c731a6c013235b", "is_verified": false, - "line_number": 216 + "line_number": 222 }, { "type": "Base64 High Entropy String", "filename": "lambdas/build-user-identity/src/test/java/uk/gov/di/ipv/core/builduseridentity/pact/BuildUserIdentityHandlerTest.java", "hashed_secret": "69facda46567909882c049ea59985c33000974b3", "is_verified": false, - "line_number": 299 + "line_number": 305 }, { "type": "Base64 High Entropy String", "filename": "lambdas/build-user-identity/src/test/java/uk/gov/di/ipv/core/builduseridentity/pact/BuildUserIdentityHandlerTest.java", "hashed_secret": "1bb4f6b3cf1f8b05e40be98e555120bbac8bb8a8", "is_verified": false, - "line_number": 352 + "line_number": 358 } ], "lambdas/call-ticf-cri/src/main/java/uk/gov/di/ipv/core/callticfcri/service/TicfCriService.java": [ @@ -314,42 +314,42 @@ "filename": "lambdas/issue-client-access-token/src/test/java/uk/gov/di/ipv/core/issueclientaccesstoken/pact/IssueClientAccessTokenHandlerTest.java", "hashed_secret": "85b64b6097e8bdbbf9c4e2cab9df0c237aae2dca", "is_verified": false, - "line_number": 119 + "line_number": 126 }, { "type": "Base64 High Entropy String", "filename": "lambdas/issue-client-access-token/src/test/java/uk/gov/di/ipv/core/issueclientaccesstoken/pact/IssueClientAccessTokenHandlerTest.java", "hashed_secret": "90972d09acf28b39b53f2ea5a145b3fd5017167e", "is_verified": false, - "line_number": 119 + "line_number": 126 }, { "type": "Base64 High Entropy String", "filename": "lambdas/issue-client-access-token/src/test/java/uk/gov/di/ipv/core/issueclientaccesstoken/pact/IssueClientAccessTokenHandlerTest.java", "hashed_secret": "c1305006857ab69a99734702cf8dbf6c71817857", "is_verified": false, - "line_number": 119 + "line_number": 126 }, { "type": "Base64 High Entropy String", "filename": "lambdas/issue-client-access-token/src/test/java/uk/gov/di/ipv/core/issueclientaccesstoken/pact/IssueClientAccessTokenHandlerTest.java", "hashed_secret": "01c2ef0ba40b5ac6268fb58d724ef0418536e5cb", "is_verified": false, - "line_number": 123 + "line_number": 130 }, { "type": "Base64 High Entropy String", "filename": "lambdas/issue-client-access-token/src/test/java/uk/gov/di/ipv/core/issueclientaccesstoken/pact/IssueClientAccessTokenHandlerTest.java", "hashed_secret": "256c2b82b396574d931fb1fe5977cb470bdc53e8", "is_verified": false, - "line_number": 123 + "line_number": 130 }, { "type": "Base64 High Entropy String", "filename": "lambdas/issue-client-access-token/src/test/java/uk/gov/di/ipv/core/issueclientaccesstoken/pact/IssueClientAccessTokenHandlerTest.java", "hashed_secret": "daa586bb42bc7f31bf51be59b3dda26c8c71f1d9", "is_verified": false, - "line_number": 123 + "line_number": 130 } ], "lambdas/process-async-cri-credential/src/test/java/uk/gov/di/ipv/core/processasynccricredential/pact/f2fCri/ContractTest.java": [ @@ -1879,5 +1879,5 @@ } ] }, - "generated_at": "2024-05-01T16:03:49Z" + "generated_at": "2024-05-01T16:27:07Z" } diff --git a/lambdas/issue-client-access-token/build.gradle b/lambdas/issue-client-access-token/build.gradle index 25e7011f54..8245ea42d9 100644 --- a/lambdas/issue-client-access-token/build.gradle +++ b/lambdas/issue-client-access-token/build.gradle @@ -42,6 +42,16 @@ test { environment "LAMBDA_TASK_ROOT", "handler" useJUnitPlatform () finalizedBy jacocoTestReport + exclude 'uk/gov/di/ipv/core/issueclientaccesstoken/pact/**' +} + +task pactProviderTests (type: Test) { + useJUnitPlatform() + include 'uk/gov/di/ipv/core/issueclientaccesstoken/pact/**' + systemProperties['pact.verifier.publishResults'] = "true" + systemProperties['pact.provider.branch'] = "${System.env.GIT_BRANCH}" + systemProperties['pact.provider.version'] = "${System.env.GIT_SHA}" + systemProperties['pact.consumerversionselectors.rawjson'] = "{ \"mainBranch\": true, \"deployedOrReleased\": true }" } jacocoTestReport { diff --git a/lambdas/issue-client-access-token/src/test/java/uk/gov/di/ipv/core/issueclientaccesstoken/pact/IssueClientAccessTokenHandlerTest.java b/lambdas/issue-client-access-token/src/test/java/uk/gov/di/ipv/core/issueclientaccesstoken/pact/IssueClientAccessTokenHandlerTest.java index e8213838b0..412a0a21f8 100644 --- a/lambdas/issue-client-access-token/src/test/java/uk/gov/di/ipv/core/issueclientaccesstoken/pact/IssueClientAccessTokenHandlerTest.java +++ b/lambdas/issue-client-access-token/src/test/java/uk/gov/di/ipv/core/issueclientaccesstoken/pact/IssueClientAccessTokenHandlerTest.java @@ -5,12 +5,12 @@ import au.com.dius.pact.provider.junit5.PactVerificationInvocationContextProvider; import au.com.dius.pact.provider.junitsupport.Provider; import au.com.dius.pact.provider.junitsupport.State; -import au.com.dius.pact.provider.junitsupport.loader.PactFolder; +import au.com.dius.pact.provider.junitsupport.loader.PactBroker; +import au.com.dius.pact.provider.junitsupport.loader.PactBrokerAuth; import org.apache.commons.codec.digest.DigestUtils; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.TestTemplate; import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.Mock; @@ -39,9 +39,16 @@ import static uk.gov.di.ipv.core.library.config.ConfigurationVariable.MAX_ALLOWED_AUTH_CLIENT_TTL; import static uk.gov.di.ipv.core.library.config.ConfigurationVariable.PUBLIC_KEY_MATERIAL_FOR_CORE_TO_VERIFY; -@PactFolder("pacts") -@Disabled("PACT tests should not be run in build pipelines at this time") +// To run these tests locally you need to: +// - Obtain the relevant pact file (from the pact broker or another team) and put it in +// /lambdas/build-user-identity/pacts +// - Comment out the @PactBroker annotation below +// - Uncomment @PactFolder annotation below @Provider("IpvCoreBackTokenProvider") +@PactBroker( + url = "${PACT_URL}?testSource=${PACT_BROKER_SOURCE_SECRET_DEV}", + authentication = @PactBrokerAuth(username = "${PACT_USER}", password = "${PACT_PASSWORD}")) +// @PactFolder("pacts") @ExtendWith(MockitoExtension.class) @MockitoSettings(strictness = Strictness.LENIENT) class IssueClientAccessTokenHandlerTest { From 7e9b7cbd79e278516116da2bc97b4c62e167172d Mon Sep 17 00:00:00 2001 From: Dan Corder Date: Thu, 9 May 2024 10:07:12 +0100 Subject: [PATCH 12/15] PYIC-5836: Let the test server pick an unused port instead of specifying one. --- .secrets.baseline | 20 +++++++++---------- .../pact/BuildUserIdentityHandlerTest.java | 6 ++---- .../IssueClientAccessTokenHandlerTest.java | 6 ++---- libs/pact-test-helpers/build.gradle | 1 + .../pacttesthelpers/LambdaHttpServer.java | 8 +++++--- 5 files changed, 20 insertions(+), 21 deletions(-) diff --git a/.secrets.baseline b/.secrets.baseline index a79addbdf6..30b87f7bf7 100644 --- a/.secrets.baseline +++ b/.secrets.baseline @@ -197,21 +197,21 @@ "filename": "lambdas/build-user-identity/src/test/java/uk/gov/di/ipv/core/builduseridentity/pact/BuildUserIdentityHandlerTest.java", "hashed_secret": "85d1e7563098941624848ca8a7c731a6c013235b", "is_verified": false, - "line_number": 222 + "line_number": 220 }, { "type": "Base64 High Entropy String", "filename": "lambdas/build-user-identity/src/test/java/uk/gov/di/ipv/core/builduseridentity/pact/BuildUserIdentityHandlerTest.java", "hashed_secret": "69facda46567909882c049ea59985c33000974b3", "is_verified": false, - "line_number": 305 + "line_number": 303 }, { "type": "Base64 High Entropy String", "filename": "lambdas/build-user-identity/src/test/java/uk/gov/di/ipv/core/builduseridentity/pact/BuildUserIdentityHandlerTest.java", "hashed_secret": "1bb4f6b3cf1f8b05e40be98e555120bbac8bb8a8", "is_verified": false, - "line_number": 358 + "line_number": 356 } ], "lambdas/call-ticf-cri/src/main/java/uk/gov/di/ipv/core/callticfcri/service/TicfCriService.java": [ @@ -314,42 +314,42 @@ "filename": "lambdas/issue-client-access-token/src/test/java/uk/gov/di/ipv/core/issueclientaccesstoken/pact/IssueClientAccessTokenHandlerTest.java", "hashed_secret": "85b64b6097e8bdbbf9c4e2cab9df0c237aae2dca", "is_verified": false, - "line_number": 126 + "line_number": 124 }, { "type": "Base64 High Entropy String", "filename": "lambdas/issue-client-access-token/src/test/java/uk/gov/di/ipv/core/issueclientaccesstoken/pact/IssueClientAccessTokenHandlerTest.java", "hashed_secret": "90972d09acf28b39b53f2ea5a145b3fd5017167e", "is_verified": false, - "line_number": 126 + "line_number": 124 }, { "type": "Base64 High Entropy String", "filename": "lambdas/issue-client-access-token/src/test/java/uk/gov/di/ipv/core/issueclientaccesstoken/pact/IssueClientAccessTokenHandlerTest.java", "hashed_secret": "c1305006857ab69a99734702cf8dbf6c71817857", "is_verified": false, - "line_number": 126 + "line_number": 124 }, { "type": "Base64 High Entropy String", "filename": "lambdas/issue-client-access-token/src/test/java/uk/gov/di/ipv/core/issueclientaccesstoken/pact/IssueClientAccessTokenHandlerTest.java", "hashed_secret": "01c2ef0ba40b5ac6268fb58d724ef0418536e5cb", "is_verified": false, - "line_number": 130 + "line_number": 128 }, { "type": "Base64 High Entropy String", "filename": "lambdas/issue-client-access-token/src/test/java/uk/gov/di/ipv/core/issueclientaccesstoken/pact/IssueClientAccessTokenHandlerTest.java", "hashed_secret": "256c2b82b396574d931fb1fe5977cb470bdc53e8", "is_verified": false, - "line_number": 130 + "line_number": 128 }, { "type": "Base64 High Entropy String", "filename": "lambdas/issue-client-access-token/src/test/java/uk/gov/di/ipv/core/issueclientaccesstoken/pact/IssueClientAccessTokenHandlerTest.java", "hashed_secret": "daa586bb42bc7f31bf51be59b3dda26c8c71f1d9", "is_verified": false, - "line_number": 130 + "line_number": 128 } ], "lambdas/process-async-cri-credential/src/test/java/uk/gov/di/ipv/core/processasynccricredential/pact/f2fCri/ContractTest.java": [ @@ -1879,5 +1879,5 @@ } ] }, - "generated_at": "2024-05-09T08:44:01Z" + "generated_at": "2024-05-09T09:06:08Z" } diff --git a/lambdas/build-user-identity/src/test/java/uk/gov/di/ipv/core/builduseridentity/pact/BuildUserIdentityHandlerTest.java b/lambdas/build-user-identity/src/test/java/uk/gov/di/ipv/core/builduseridentity/pact/BuildUserIdentityHandlerTest.java index e6b74620ec..e81d50bd8e 100644 --- a/lambdas/build-user-identity/src/test/java/uk/gov/di/ipv/core/builduseridentity/pact/BuildUserIdentityHandlerTest.java +++ b/lambdas/build-user-identity/src/test/java/uk/gov/di/ipv/core/builduseridentity/pact/BuildUserIdentityHandlerTest.java @@ -64,8 +64,6 @@ @MockitoSettings(strictness = Strictness.LENIENT) class BuildUserIdentityHandlerTest { - private static final int PORT = 5050; - private static final String IPV_SESSION_ID = "dummyIpvSessionId"; private LambdaHttpServer httpServer; @@ -146,10 +144,10 @@ void pactSetup(PactVerificationContext context) mockCiMitUtilityService, sessionCredentialService); - httpServer = new LambdaHttpServer(handler, "/user-identity", PORT); + httpServer = new LambdaHttpServer(handler, "/user-identity"); httpServer.startServer(); - context.setTarget(new HttpTestTarget("localhost", PORT)); + context.setTarget(new HttpTestTarget("localhost", httpServer.getPort())); } @AfterEach diff --git a/lambdas/issue-client-access-token/src/test/java/uk/gov/di/ipv/core/issueclientaccesstoken/pact/IssueClientAccessTokenHandlerTest.java b/lambdas/issue-client-access-token/src/test/java/uk/gov/di/ipv/core/issueclientaccesstoken/pact/IssueClientAccessTokenHandlerTest.java index 412a0a21f8..edfcc19d7d 100644 --- a/lambdas/issue-client-access-token/src/test/java/uk/gov/di/ipv/core/issueclientaccesstoken/pact/IssueClientAccessTokenHandlerTest.java +++ b/lambdas/issue-client-access-token/src/test/java/uk/gov/di/ipv/core/issueclientaccesstoken/pact/IssueClientAccessTokenHandlerTest.java @@ -53,8 +53,6 @@ @MockitoSettings(strictness = Strictness.LENIENT) class IssueClientAccessTokenHandlerTest { - private static final int PORT = 5050; - private LambdaHttpServer httpServer; private IpvSessionItem ipvSessionItem; @Mock private ConfigService configService; @@ -102,10 +100,10 @@ void pactSetup(PactVerificationContext context) throws IOException { clientOAuthSessionService, tokenRequestValidator); - httpServer = new LambdaHttpServer(handler, "/token", PORT); + httpServer = new LambdaHttpServer(handler, "/token"); httpServer.startServer(); - context.setTarget(new HttpTestTarget("localhost", PORT)); + context.setTarget(new HttpTestTarget("localhost", httpServer.getPort())); } @AfterEach diff --git a/libs/pact-test-helpers/build.gradle b/libs/pact-test-helpers/build.gradle index f607bdddd8..b548876cdd 100644 --- a/libs/pact-test-helpers/build.gradle +++ b/libs/pact-test-helpers/build.gradle @@ -15,6 +15,7 @@ dependencies { libs.mockitoJunit, libs.pactConsumerJunit, project(path: ':libs:common-services') + implementation 'org.projectlombok:lombok:1.18.28' testImplementation libs.junitJupiter, libs.mockitoJunit diff --git a/libs/pact-test-helpers/src/main/java/uk/gov/di/ipv/core/library/pacttesthelpers/LambdaHttpServer.java b/libs/pact-test-helpers/src/main/java/uk/gov/di/ipv/core/library/pacttesthelpers/LambdaHttpServer.java index 4f7392d48b..d748046a9e 100644 --- a/libs/pact-test-helpers/src/main/java/uk/gov/di/ipv/core/library/pacttesthelpers/LambdaHttpServer.java +++ b/libs/pact-test-helpers/src/main/java/uk/gov/di/ipv/core/library/pacttesthelpers/LambdaHttpServer.java @@ -28,13 +28,15 @@ @ExcludeFromGeneratedCoverageReport public class LambdaHttpServer { private final HttpServer server; + @lombok.Getter private final int port; public LambdaHttpServer( RequestHandler handler, - String path, - int port) + String path) throws IOException { - server = HttpServer.create(new InetSocketAddress(port), 0); + var socketAddress = new InetSocketAddress(0); + port = socketAddress.getPort(); + server = HttpServer.create(socketAddress, 0); server.createContext(path, new LambdaHandlerWrapper(handler)); server.setExecutor(Executors.newCachedThreadPool()); // creates a default executor } From 690ef66120d110c5b3bb4a5e0029381e1139ccda Mon Sep 17 00:00:00 2001 From: Dan Corder Date: Thu, 9 May 2024 10:14:17 +0100 Subject: [PATCH 13/15] PYIC-5836: Enable Lombok in libs/pact-test-helpers build --- libs/pact-test-helpers/build.gradle | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libs/pact-test-helpers/build.gradle b/libs/pact-test-helpers/build.gradle index b548876cdd..9f87cc567c 100644 --- a/libs/pact-test-helpers/build.gradle +++ b/libs/pact-test-helpers/build.gradle @@ -17,6 +17,9 @@ dependencies { project(path: ':libs:common-services') implementation 'org.projectlombok:lombok:1.18.28' + compileOnly libs.lombok + annotationProcessor libs.lombok + testImplementation libs.junitJupiter, libs.mockitoJunit From ab75636e4929dfb3a4092c142709851908672f88 Mon Sep 17 00:00:00 2001 From: Dan Corder Date: Thu, 9 May 2024 10:32:09 +0100 Subject: [PATCH 14/15] PYIC-5836: Try to get the port a different way. --- .../ipv/core/library/pacttesthelpers/LambdaHttpServer.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libs/pact-test-helpers/src/main/java/uk/gov/di/ipv/core/library/pacttesthelpers/LambdaHttpServer.java b/libs/pact-test-helpers/src/main/java/uk/gov/di/ipv/core/library/pacttesthelpers/LambdaHttpServer.java index d748046a9e..210c92936b 100644 --- a/libs/pact-test-helpers/src/main/java/uk/gov/di/ipv/core/library/pacttesthelpers/LambdaHttpServer.java +++ b/libs/pact-test-helpers/src/main/java/uk/gov/di/ipv/core/library/pacttesthelpers/LambdaHttpServer.java @@ -28,19 +28,21 @@ @ExcludeFromGeneratedCoverageReport public class LambdaHttpServer { private final HttpServer server; - @lombok.Getter private final int port; public LambdaHttpServer( RequestHandler handler, String path) throws IOException { var socketAddress = new InetSocketAddress(0); - port = socketAddress.getPort(); server = HttpServer.create(socketAddress, 0); server.createContext(path, new LambdaHandlerWrapper(handler)); server.setExecutor(Executors.newCachedThreadPool()); // creates a default executor } + public int getPort() { + return server.getAddress().getPort(); + } + public void startServer() { server.start(); } From 0fcbf356bf3a848a51067e631d507919ee547dc0 Mon Sep 17 00:00:00 2001 From: Dan Corder Date: Thu, 9 May 2024 10:45:33 +0100 Subject: [PATCH 15/15] PYIC-5836: Remove unused Lombok reference --- libs/pact-test-helpers/build.gradle | 4 ---- .../di/ipv/core/library/pacttesthelpers/LambdaHttpServer.java | 3 +-- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/libs/pact-test-helpers/build.gradle b/libs/pact-test-helpers/build.gradle index 9f87cc567c..f607bdddd8 100644 --- a/libs/pact-test-helpers/build.gradle +++ b/libs/pact-test-helpers/build.gradle @@ -15,10 +15,6 @@ dependencies { libs.mockitoJunit, libs.pactConsumerJunit, project(path: ':libs:common-services') - implementation 'org.projectlombok:lombok:1.18.28' - - compileOnly libs.lombok - annotationProcessor libs.lombok testImplementation libs.junitJupiter, libs.mockitoJunit diff --git a/libs/pact-test-helpers/src/main/java/uk/gov/di/ipv/core/library/pacttesthelpers/LambdaHttpServer.java b/libs/pact-test-helpers/src/main/java/uk/gov/di/ipv/core/library/pacttesthelpers/LambdaHttpServer.java index 210c92936b..7cf1568d35 100644 --- a/libs/pact-test-helpers/src/main/java/uk/gov/di/ipv/core/library/pacttesthelpers/LambdaHttpServer.java +++ b/libs/pact-test-helpers/src/main/java/uk/gov/di/ipv/core/library/pacttesthelpers/LambdaHttpServer.java @@ -33,8 +33,7 @@ public LambdaHttpServer( RequestHandler handler, String path) throws IOException { - var socketAddress = new InetSocketAddress(0); - server = HttpServer.create(socketAddress, 0); + server = HttpServer.create(new InetSocketAddress(0), 0); server.createContext(path, new LambdaHandlerWrapper(handler)); server.setExecutor(Executors.newCachedThreadPool()); // creates a default executor }