From 8a42fc590148beeb4e51bd925820504941587063 Mon Sep 17 00:00:00 2001 From: gquadrati Date: Tue, 20 Jun 2023 19:04:46 +0200 Subject: [PATCH 1/4] add Bearer prefix tojwt --- .../assertion/client/simple/AssertionSimpleClient.java | 2 +- .../client/simple/AssertionSimpleClientTestUtils.java | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/assertion-rest-client-native/src/main/java/it/pagopa/tech/lollipop/consumer/assertion/client/simple/AssertionSimpleClient.java b/assertion-rest-client-native/src/main/java/it/pagopa/tech/lollipop/consumer/assertion/client/simple/AssertionSimpleClient.java index 46cbfe29..b7cc1757 100644 --- a/assertion-rest-client-native/src/main/java/it/pagopa/tech/lollipop/consumer/assertion/client/simple/AssertionSimpleClient.java +++ b/assertion-rest-client-native/src/main/java/it/pagopa/tech/lollipop/consumer/assertion/client/simple/AssertionSimpleClient.java @@ -42,7 +42,7 @@ public SamlAssertion getAssertion(String jwt, String assertionRef) LCUserInfo responseAssertion; try { - responseAssertion = this.defaultApi.getAssertion(ref, jwt); + responseAssertion = this.defaultApi.getAssertion(ref, "Bearer " + jwt); } catch (ApiException e) { throw new LollipopAssertionNotFoundException( "Error retrieving assertion: " + e.getMessage(), e); diff --git a/assertion-rest-client-native/src/test/java/it/pagopa/tech/lollipop/consumer/assertion/client/simple/AssertionSimpleClientTestUtils.java b/assertion-rest-client-native/src/test/java/it/pagopa/tech/lollipop/consumer/assertion/client/simple/AssertionSimpleClientTestUtils.java index 1f93160a..52519209 100644 --- a/assertion-rest-client-native/src/test/java/it/pagopa/tech/lollipop/consumer/assertion/client/simple/AssertionSimpleClientTestUtils.java +++ b/assertion-rest-client-native/src/test/java/it/pagopa/tech/lollipop/consumer/assertion/client/simple/AssertionSimpleClientTestUtils.java @@ -267,7 +267,7 @@ public static void createExpectationAssertionFound() { new Header( "Ocp-Apim-Subscription-Key", "FakeSubscriptionKey"), new Header("Accept", "application/json"), - new Header("x-pagopa-lollipop-auth", JWT))) + new Header("x-pagopa-lollipop-auth", "Bearer " + JWT))) .respond(response().withStatusCode(200).withBody(RESPONSE_STRING)); } @@ -282,7 +282,7 @@ public static void createExpectationAssertionNotFound() { new Header( "Ocp-Apim-Subscription-Key", "FakeSubscriptionKey"), new Header("Accept", "application/json"), - new Header("x-pagopa-lollipop-auth", JWT))) + new Header("x-pagopa-lollipop-auth", "Bearer " + JWT))) .respond(response().withStatusCode(404).withBody("{}")); } } From afc43873287824f145cb81c3616d41454e0ce360 Mon Sep 17 00:00:00 2001 From: gquadrati Date: Tue, 20 Jun 2023 19:27:34 +0200 Subject: [PATCH 2/4] rename test --- .../tech/lollipop/consumer/servlet/ServletIntegrationTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/servlet-impl/src/test/java/it/pagopa/tech/lollipop/consumer/servlet/ServletIntegrationTest.java b/servlet-impl/src/test/java/it/pagopa/tech/lollipop/consumer/servlet/ServletIntegrationTest.java index 4cc5e771..80ffca84 100644 --- a/servlet-impl/src/test/java/it/pagopa/tech/lollipop/consumer/servlet/ServletIntegrationTest.java +++ b/servlet-impl/src/test/java/it/pagopa/tech/lollipop/consumer/servlet/ServletIntegrationTest.java @@ -58,7 +58,7 @@ public static void startServer() { } @Test - void testWithValidRequestReturnsSuccess() throws IOException { + void testWithAValidRequestReturnsSuccess() throws IOException { SimpleClientsTestUtils.createExpectationAssertionFound(); SimpleClientsTestUtils.createExpectationIdpFound(); lollipopConsumerRequestConfig.setAssertionExpireInDays(365); From 5caf269676f532227cc7eec17f2ca782e1fca2a9 Mon Sep 17 00:00:00 2001 From: gquadrati Date: Tue, 20 Jun 2023 19:58:10 +0200 Subject: [PATCH 3/4] increase version to RC4 --- build.gradle | 2 +- samples/servlet/build.gradle | 2 +- samples/simple/build.gradle | 2 +- samples/simpleTypesafe/build.gradle | 2 +- samples/spring/build.gradle | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/build.gradle b/build.gradle index e0a86de7..d9fa0e1f 100644 --- a/build.gradle +++ b/build.gradle @@ -22,7 +22,7 @@ repositories { } allprojects { - version = '1.0.0-RC3' + version = '1.0.0-RC4' group = 'it.pagopa.tech.lollipop-consumer-java-sdk' sourceCompatibility = '11' targetCompatibility = '11' diff --git a/samples/servlet/build.gradle b/samples/servlet/build.gradle index d2be0dde..c5e999d9 100644 --- a/samples/servlet/build.gradle +++ b/samples/servlet/build.gradle @@ -13,7 +13,7 @@ plugins { group = 'it.pagopa.tech.lollipop.consumer.samples' -version = '1.0.0-RC3' +version = '1.0.0-RC4' sourceCompatibility = '11' application { diff --git a/samples/simple/build.gradle b/samples/simple/build.gradle index 4e8f0956..f8c1aa52 100644 --- a/samples/simple/build.gradle +++ b/samples/simple/build.gradle @@ -13,7 +13,7 @@ plugins { group = 'it.pagopa.tech.lollipop.consumer.samples' -version = '1.0.0-RC3' +version = '1.0.0-RC4' sourceCompatibility = '11' application { diff --git a/samples/simpleTypesafe/build.gradle b/samples/simpleTypesafe/build.gradle index 74c1580c..b8786194 100644 --- a/samples/simpleTypesafe/build.gradle +++ b/samples/simpleTypesafe/build.gradle @@ -13,7 +13,7 @@ plugins { group = 'it.pagopa.tech.lollipop.consumer.samples' -version = '1.0.0-RC3' +version = '1.0.0-RC4' sourceCompatibility = '11' application { diff --git a/samples/spring/build.gradle b/samples/spring/build.gradle index bb634c7e..9ff07bfa 100644 --- a/samples/spring/build.gradle +++ b/samples/spring/build.gradle @@ -5,7 +5,7 @@ plugins { } group = 'it.pagopa.tech.lollipop.consumer.samples' -version = '1.0.0-RC3' +version = '1.0.0-RC4' sourceCompatibility = '11' configurations { From 2b73464168799c26f7859d1f55302978005ae29e Mon Sep 17 00:00:00 2001 From: Alessandro Masci Date: Wed, 21 Jun 2023 10:48:09 +0200 Subject: [PATCH 4/4] fix test --- .../consumer/servlet/ServletIntegrationTest.java | 11 ++++++----- .../servlet/utils/SimpleClientsTestUtils.java | 5 ++++- ...HttpVerifierHandlerInterceptorIntegrationTest.java | 2 +- .../consumer/spring/SimpleClientsTestUtils.java | 2 +- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/servlet-impl/src/test/java/it/pagopa/tech/lollipop/consumer/servlet/ServletIntegrationTest.java b/servlet-impl/src/test/java/it/pagopa/tech/lollipop/consumer/servlet/ServletIntegrationTest.java index 80ffca84..ce3dadda 100644 --- a/servlet-impl/src/test/java/it/pagopa/tech/lollipop/consumer/servlet/ServletIntegrationTest.java +++ b/servlet-impl/src/test/java/it/pagopa/tech/lollipop/consumer/servlet/ServletIntegrationTest.java @@ -9,10 +9,7 @@ import it.pagopa.tech.lollipop.consumer.servlet.config.HttpVerifierConfiguration; import it.pagopa.tech.lollipop.consumer.servlet.utils.SimpleClientsTestUtils; import java.io.IOException; -import org.junit.jupiter.api.AfterAll; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.*; import org.junit.jupiter.api.extension.ExtendWith; import org.mockserver.integration.ClientAndServer; import org.springframework.beans.factory.annotation.Autowired; @@ -57,6 +54,11 @@ public static void startServer() { mockServer = startClientAndServer(3000, 3001); } + @BeforeEach + void setup() { + idpCertSimpleClientConfig.setBaseUri("http://localhost:3001"); + } + @Test void testWithAValidRequestReturnsSuccess() throws IOException { SimpleClientsTestUtils.createExpectationAssertionFound(); @@ -64,7 +66,6 @@ void testWithAValidRequestReturnsSuccess() throws IOException { lollipopConsumerRequestConfig.setAssertionExpireInDays(365); lollipopConsumerRequestConfig.setAssertionNotBeforeDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'"); lollipopConsumerRequestConfig.setAssertionInstantDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'"); - idpCertSimpleClientConfig.setBaseUri("http://localhost:3001"); RestTemplate exec = restTemplate.getRestTemplate(); exec.getClientHttpRequestInitializers() diff --git a/servlet-impl/src/test/java/it/pagopa/tech/lollipop/consumer/servlet/utils/SimpleClientsTestUtils.java b/servlet-impl/src/test/java/it/pagopa/tech/lollipop/consumer/servlet/utils/SimpleClientsTestUtils.java index 94ff3420..e4661c9f 100644 --- a/servlet-impl/src/test/java/it/pagopa/tech/lollipop/consumer/servlet/utils/SimpleClientsTestUtils.java +++ b/servlet-impl/src/test/java/it/pagopa/tech/lollipop/consumer/servlet/utils/SimpleClientsTestUtils.java @@ -240,6 +240,8 @@ public class SimpleClientsTestUtils { "eyJrdHkiOiJFQyIsIngiOiJTaHlZa0ZyN1F3eE9rOE5BRXF6aklkTnc4dEVKODlZOVBlWFF1eVVOWDVjIiwieSI6InlULVJxNWc2VlVadENUd0ZnRExDM2RneGNuM2RsSmNGRjhnWGdxYWgyS0UiLCJjcnYiOiJQLTI1NiJ9"; private static final String IDP_TAG = "latest"; + private static final String SUBSCRIPTION_KEY = "FakeSubscriptionKey"; + public static void createExpectationAssertionFound() { new MockServerClient("localhost", 3000) .when( @@ -249,7 +251,8 @@ public static void createExpectationAssertionFound() { .withPathParameter("assertion", ASSERTION_REF) .withHeaders( new Header("Accept", "application/json"), - new Header("x-pagopa-lollipop-auth", JWT))) + new Header("x-pagopa-lollipop-auth", "Bearer " + JWT), + new Header("Ocp-Apim-Subscription-Key", SUBSCRIPTION_KEY))) .respond(response().withStatusCode(200).withBody(VALID_ASSERTION_XML)); } diff --git a/spring-impl/src/test/java/it/pagopa/tech/lollipop/consumer/spring/HttpVerifierHandlerInterceptorIntegrationTest.java b/spring-impl/src/test/java/it/pagopa/tech/lollipop/consumer/spring/HttpVerifierHandlerInterceptorIntegrationTest.java index d1405ce0..7e1d3cbe 100644 --- a/spring-impl/src/test/java/it/pagopa/tech/lollipop/consumer/spring/HttpVerifierHandlerInterceptorIntegrationTest.java +++ b/spring-impl/src/test/java/it/pagopa/tech/lollipop/consumer/spring/HttpVerifierHandlerInterceptorIntegrationTest.java @@ -53,6 +53,7 @@ public class HttpVerifierHandlerInterceptorIntegrationTest { public void startServer() { restTemplate = new TestRestTemplate(); mockServer = startClientAndServer(3000, 3001); + idpCertSimpleClientConfig.setBaseUri("http://localhost:3001"); } @Test @@ -63,7 +64,6 @@ void testWithValidRequestReturnsSuccess() throws IOException { "yyyy-MM-dd'T'HH:mm:ss'Z'"); springLollipopConsumerRequestConfig.setAssertionInstantDateFormat( "yyyy-MM-dd'T'HH:mm:ss'Z'"); - idpCertSimpleClientConfig.setBaseUri("http://localhost:3001"); RestTemplate exec = restTemplate.getRestTemplate(); exec.getClientHttpRequestInitializers() diff --git a/spring-impl/src/test/java/it/pagopa/tech/lollipop/consumer/spring/SimpleClientsTestUtils.java b/spring-impl/src/test/java/it/pagopa/tech/lollipop/consumer/spring/SimpleClientsTestUtils.java index 42b69912..802beaeb 100644 --- a/spring-impl/src/test/java/it/pagopa/tech/lollipop/consumer/spring/SimpleClientsTestUtils.java +++ b/spring-impl/src/test/java/it/pagopa/tech/lollipop/consumer/spring/SimpleClientsTestUtils.java @@ -249,7 +249,7 @@ public static void createExpectationAssertionFound() { .withPathParameter("assertion", ASSERTION_REF) .withHeaders( new Header("Accept", "application/json"), - new Header("x-pagopa-lollipop-auth", JWT))) + new Header("x-pagopa-lollipop-auth", "Bearer " + JWT))) .respond(response().withStatusCode(200).withBody(VALID_ASSERTION_XML)); }