Skip to content

Commit 3549bb3

Browse files
chore: deactivate temporarily the check on multiple signatures to monitor in prod
1 parent df4c382 commit 3549bb3

File tree

2 files changed

+39
-40
lines changed

2 files changed

+39
-40
lines changed

src/oneid/oneid-ecs-core/src/main/java/it/pagopa/oneid/web/controller/SAMLController.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,8 @@ public Response samlACS(@BeanParam @Valid SAMLResponseDTO samlResponseDTO) {
9595
cloudWatchConnectorImpl.sendIDPErrorMetricData(
9696
samlSession.getAuthorizationRequestDTOExtended().getIdp(),
9797
ErrorCode.IDP_ERROR_MULTIPLE_SAMLRESPONSE_SIGNATURES_PRESENT);
98-
throw new GenericHTMLException(ErrorCode.IDP_ERROR_MULTIPLE_SAMLRESPONSE_SIGNATURES_PRESENT);
98+
// TODO uncomment to activate the check for multiple signatures
99+
// throw new GenericHTMLException(ErrorCode.IDP_ERROR_MULTIPLE_SAMLRESPONSE_SIGNATURES_PRESENT);
99100
}
100101

101102
// 1d. Check status, will raise CustomException in case of error mapped to a custom html error page

src/oneid/oneid-ecs-core/src/test/java/it/pagopa/oneid/web/controller/SAMLControllerTest.java

Lines changed: 37 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package it.pagopa.oneid.web.controller;
22

33
import static io.restassured.RestAssured.given;
4-
import static org.hamcrest.Matchers.containsString;
54
import static org.mockito.Mockito.doNothing;
65
import static org.mockito.Mockito.doThrow;
76
import com.nimbusds.oauth2.sdk.AuthorizationCode;
@@ -11,7 +10,6 @@
1110
import com.nimbusds.oauth2.sdk.id.State;
1211
import io.quarkus.test.InjectMock;
1312
import io.quarkus.test.common.http.TestHTTPEndpoint;
14-
import io.quarkus.test.junit.QuarkusMock;
1513
import io.quarkus.test.junit.QuarkusTest;
1614
import io.quarkus.test.junit.TestProfile;
1715
import it.pagopa.oneid.common.model.exception.OneIdentityException;
@@ -25,7 +23,6 @@
2523
import it.pagopa.oneid.service.SessionServiceImpl;
2624
import it.pagopa.oneid.web.controller.interceptors.CurrentAuthDTO;
2725
import it.pagopa.oneid.web.controller.mock.SAMLControllerTestProfile;
28-
import it.pagopa.oneid.web.dto.AuthorizationRequestDTOExtended;
2926
import jakarta.inject.Inject;
3027
import java.net.URLEncoder;
3128
import java.nio.charset.StandardCharsets;
@@ -416,42 +413,43 @@ void samlACS_exceptionInCreatingCallbackURI() {
416413
Assertions.assertTrue(location.contains(headerLocation));
417414
}
418415

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+
// }
455453

456454
@Test
457455
void assertion_ok() {

0 commit comments

Comments
 (0)