|
1 | 1 | package it.pagopa.oneid.web.controller; |
2 | 2 |
|
3 | 3 | import static io.restassured.RestAssured.given; |
4 | | -import static org.hamcrest.Matchers.containsString; |
5 | 4 | import static org.mockito.Mockito.doNothing; |
6 | 5 | import static org.mockito.Mockito.doThrow; |
7 | 6 | import com.nimbusds.oauth2.sdk.AuthorizationCode; |
|
11 | 10 | import com.nimbusds.oauth2.sdk.id.State; |
12 | 11 | import io.quarkus.test.InjectMock; |
13 | 12 | import io.quarkus.test.common.http.TestHTTPEndpoint; |
14 | | -import io.quarkus.test.junit.QuarkusMock; |
15 | 13 | import io.quarkus.test.junit.QuarkusTest; |
16 | 14 | import io.quarkus.test.junit.TestProfile; |
17 | 15 | import it.pagopa.oneid.common.model.exception.OneIdentityException; |
|
25 | 23 | import it.pagopa.oneid.service.SessionServiceImpl; |
26 | 24 | import it.pagopa.oneid.web.controller.interceptors.CurrentAuthDTO; |
27 | 25 | import it.pagopa.oneid.web.controller.mock.SAMLControllerTestProfile; |
28 | | -import it.pagopa.oneid.web.dto.AuthorizationRequestDTOExtended; |
29 | 26 | import jakarta.inject.Inject; |
30 | 27 | import java.net.URLEncoder; |
31 | 28 | import java.nio.charset.StandardCharsets; |
@@ -416,42 +413,43 @@ void samlACS_exceptionInCreatingCallbackURI() { |
416 | 413 | Assertions.assertTrue(location.contains(headerLocation)); |
417 | 414 | } |
418 | 415 |
|
419 | | - @Test |
420 | | - @SneakyThrows |
421 | | - void samlACS_SAMLResponseWithMultipleSignatures() { |
422 | | - // given |
423 | | - CurrentAuthDTO mockAuthDTO = Mockito.mock(CurrentAuthDTO.class); |
424 | | - QuarkusMock.installMockForType(mockAuthDTO, CurrentAuthDTO.class); |
425 | | - |
426 | | - Map<String, String> samlResponseDTO = new HashMap<>(); |
427 | | - samlResponseDTO.put("SAMLResponse", "dummySAMLResponse"); |
428 | | - samlResponseDTO.put("RelayState", "dummyRelayState"); |
429 | | - |
430 | | - // Mock CurrentAuthDTO to simulate multiple signatures scenario |
431 | | - Mockito.when(mockAuthDTO.isResponseWithMultipleSignatures()).thenReturn(true); |
432 | | - |
433 | | - // Setup mocks for response and samlSession as usual, but flow will stop at the multiple signatures check |
434 | | - Response response = Mockito.mock(Response.class); |
435 | | - Mockito.when(response.getInResponseTo()).thenReturn("Dummy"); |
436 | | - Mockito.when(samlServiceImpl.getSAMLResponseFromString(Mockito.any())).thenReturn(response); |
437 | | - Mockito.when(mockAuthDTO.getResponse()).thenReturn(response); |
438 | | - |
439 | | - AuthorizationRequestDTOExtended dto = Mockito.mock(AuthorizationRequestDTOExtended.class); |
440 | | - Mockito.when(dto.getIdp()).thenReturn("dummy-idp"); // Stub idp for cloudwatch metrics |
441 | | - SAMLSession samlSession = Mockito.mock(SAMLSession.class); |
442 | | - Mockito.when(samlSession.getAuthorizationRequestDTOExtended()).thenReturn(dto); |
443 | | - Mockito.when(mockAuthDTO.getSamlSession()).thenReturn(samlSession); |
444 | | - |
445 | | - // HTTP 302 |
446 | | - given() |
447 | | - .formParams(samlResponseDTO) |
448 | | - .when() |
449 | | - .post("/acs") |
450 | | - .then() |
451 | | - .statusCode(302) |
452 | | - .header("Location", containsString( |
453 | | - ErrorCode.IDP_ERROR_MULTIPLE_SAMLRESPONSE_SIGNATURES_PRESENT.getErrorCode())); |
454 | | - } |
| 416 | +// TODO re-enable this test when the feature is back |
| 417 | +// @Test |
| 418 | +// @SneakyThrows |
| 419 | +// void samlACS_SAMLResponseWithMultipleSignatures() { |
| 420 | +// // given |
| 421 | +// CurrentAuthDTO mockAuthDTO = Mockito.mock(CurrentAuthDTO.class); |
| 422 | +// QuarkusMock.installMockForType(mockAuthDTO, CurrentAuthDTO.class); |
| 423 | +// |
| 424 | +// Map<String, String> samlResponseDTO = new HashMap<>(); |
| 425 | +// samlResponseDTO.put("SAMLResponse", "dummySAMLResponse"); |
| 426 | +// samlResponseDTO.put("RelayState", "dummyRelayState"); |
| 427 | +// |
| 428 | +// // Mock CurrentAuthDTO to simulate multiple signatures scenario |
| 429 | +// Mockito.when(mockAuthDTO.isResponseWithMultipleSignatures()).thenReturn(true); |
| 430 | +// |
| 431 | +// // Setup mocks for response and samlSession as usual, but flow will stop at the multiple signatures check |
| 432 | +// Response response = Mockito.mock(Response.class); |
| 433 | +// Mockito.when(response.getInResponseTo()).thenReturn("Dummy"); |
| 434 | +// Mockito.when(samlServiceImpl.getSAMLResponseFromString(Mockito.any())).thenReturn(response); |
| 435 | +// Mockito.when(mockAuthDTO.getResponse()).thenReturn(response); |
| 436 | +// |
| 437 | +// AuthorizationRequestDTOExtended dto = Mockito.mock(AuthorizationRequestDTOExtended.class); |
| 438 | +// Mockito.when(dto.getIdp()).thenReturn("dummy-idp"); // Stub idp for cloudwatch metrics |
| 439 | +// SAMLSession samlSession = Mockito.mock(SAMLSession.class); |
| 440 | +// Mockito.when(samlSession.getAuthorizationRequestDTOExtended()).thenReturn(dto); |
| 441 | +// Mockito.when(mockAuthDTO.getSamlSession()).thenReturn(samlSession); |
| 442 | +// |
| 443 | +// // HTTP 302 |
| 444 | +// given() |
| 445 | +// .formParams(samlResponseDTO) |
| 446 | +// .when() |
| 447 | +// .post("/acs") |
| 448 | +// .then() |
| 449 | +// .statusCode(302) |
| 450 | +// .header("Location", containsString( |
| 451 | +// ErrorCode.IDP_ERROR_MULTIPLE_SAMLRESPONSE_SIGNATURES_PRESENT.getErrorCode())); |
| 452 | +// } |
455 | 453 |
|
456 | 454 | @Test |
457 | 455 | void assertion_ok() { |
|
0 commit comments