Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
masciale89 committed Jun 21, 2023
1 parent 5caf269 commit 2b73464
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -57,14 +54,18 @@ public static void startServer() {
mockServer = startClientAndServer(3000, 3001);
}

@BeforeEach
void setup() {
idpCertSimpleClientConfig.setBaseUri("http://localhost:3001");
}

@Test
void testWithAValidRequestReturnsSuccess() throws IOException {
SimpleClientsTestUtils.createExpectationAssertionFound();
SimpleClientsTestUtils.createExpectationIdpFound();
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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ public class HttpVerifierHandlerInterceptorIntegrationTest {
public void startServer() {
restTemplate = new TestRestTemplate();
mockServer = startClientAndServer(3000, 3001);
idpCertSimpleClientConfig.setBaseUri("http://localhost:3001");
}

@Test
Expand All @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}

Expand Down

0 comments on commit 2b73464

Please sign in to comment.