Skip to content

Commit c4fb3b4

Browse files
chore: add IDP error cloudwatch metric
1 parent ff02aa5 commit c4fb3b4

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,9 @@ public Response samlACS(@BeanParam @Valid SAMLResponseDTO samlResponseDTO) {
9292
// in this case the raw SAMLResponse is stored in SAML record, but the flow is interrupted
9393
if (currentAuthDTO.isResponseWithMultipleSignatures()) {
9494
Log.error("SAML Response contains multiple signatures");
95+
cloudWatchConnectorImpl.sendIDPErrorMetricData(
96+
samlSession.getAuthorizationRequestDTOExtended().getIdp(),
97+
ErrorCode.IDP_ERROR_MULTIPLE_SAMLRESPONSE_SIGNATURES_PRESENT);
9598
throw new GenericHTMLException(ErrorCode.IDP_ERROR_MULTIPLE_SAMLRESPONSE_SIGNATURES_PRESENT);
9699
}
97100

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import it.pagopa.oneid.service.SessionServiceImpl;
2626
import it.pagopa.oneid.web.controller.interceptors.CurrentAuthDTO;
2727
import it.pagopa.oneid.web.controller.mock.SAMLControllerTestProfile;
28+
import it.pagopa.oneid.web.dto.AuthorizationRequestDTOExtended;
2829
import jakarta.inject.Inject;
2930
import java.net.URLEncoder;
3031
import java.nio.charset.StandardCharsets;
@@ -433,9 +434,12 @@ void samlACS_SAMLResponseWithMultipleSignatures() {
433434
Response response = Mockito.mock(Response.class);
434435
Mockito.when(response.getInResponseTo()).thenReturn("Dummy");
435436
Mockito.when(samlServiceImpl.getSAMLResponseFromString(Mockito.any())).thenReturn(response);
437+
Mockito.when(mockAuthDTO.getResponse()).thenReturn(response);
436438

439+
AuthorizationRequestDTOExtended dto = Mockito.mock(AuthorizationRequestDTOExtended.class);
440+
Mockito.when(dto.getIdp()).thenReturn("dummy-idp"); // Stub idp for cloudwatch metrics
437441
SAMLSession samlSession = Mockito.mock(SAMLSession.class);
438-
Mockito.when(mockAuthDTO.getResponse()).thenReturn(response);
442+
Mockito.when(samlSession.getAuthorizationRequestDTOExtended()).thenReturn(dto);
439443
Mockito.when(mockAuthDTO.getSamlSession()).thenReturn(samlSession);
440444

441445
// HTTP 302

0 commit comments

Comments
 (0)