From 7abe41afdb6f454e02126dbc90fb0352d0d15f74 Mon Sep 17 00:00:00 2001 From: Thomas Lenz Date: Fri, 30 Jul 2021 09:16:47 +0200 Subject: throw a specific error in case of a EHVD response that contains no GDA information --- .../modules/ehvd/service/EhvdCommunicationService.java | 12 +++++------- .../resources/properties/id_messages.properties | 1 + .../properties/protocol_response_statuscodes.properties | 1 + .../InjectEhvdIdentityInformationQsSystemTest.java | 4 ++-- .../tasks/InjectEhvdIdentityInformationTaskTest.java | 17 +++++++++++++++++ 5 files changed, 26 insertions(+), 9 deletions(-) diff --git a/id/server/modules/moa-id-module-ehvd_integration/src/main/java/at/gv/egovernment/moa/id/auth/modules/ehvd/service/EhvdCommunicationService.java b/id/server/modules/moa-id-module-ehvd_integration/src/main/java/at/gv/egovernment/moa/id/auth/modules/ehvd/service/EhvdCommunicationService.java index ab4a70751..2ef79a141 100644 --- a/id/server/modules/moa-id-module-ehvd_integration/src/main/java/at/gv/egovernment/moa/id/auth/modules/ehvd/service/EhvdCommunicationService.java +++ b/id/server/modules/moa-id-module-ehvd_integration/src/main/java/at/gv/egovernment/moa/id/auth/modules/ehvd/service/EhvdCommunicationService.java @@ -51,6 +51,7 @@ public class EhvdCommunicationService implements IEhvdCommunication { private static final String ERROR_EHVD_00 = "ehvd.00"; private static final String ERROR_EHVD_01 = "ehvd.01"; private static final String ERROR_EHVD_02 = "ehvd.02"; + private static final String ERROR_EHVD_03 = "ehvd.03"; private static final String ERROR_CONFIG_05 = "config.05"; @Autowired @@ -100,8 +101,7 @@ public class EhvdCommunicationService implements IEhvdCommunication { // extract reason for this error String errorMsg = e.getFault() != null ? StringUtils.isNotEmpty(e.getFault().getFaultString()) ? e.getFault().getFaultString() : e.getMessage() - : e.getMessage(); - + : e.getMessage(); Logger.warn("EHVD communication failed with SOAP response: " + errorMsg, e); throw new EhvdException(ERROR_EHVD_02, new Object[] {errorMsg}, e); @@ -127,13 +127,11 @@ public class EhvdCommunicationService implements IEhvdCommunication { } } else { - Logger.debug("Receive empty GDA response"); - // TODO: what we to in case of empty response? + Logger.info("Receive empty GDA response"); + throw new EhvdException(ERROR_EHVD_03, new Object[] {}); + } - - return Collections.emptyList(); - } private GetGdaDescriptors buildGdaRequest(String bPK) { diff --git a/id/server/modules/moa-id-module-ehvd_integration/src/main/resources/resources/properties/id_messages.properties b/id/server/modules/moa-id-module-ehvd_integration/src/main/resources/resources/properties/id_messages.properties index 104342a9d..643893413 100644 --- a/id/server/modules/moa-id-module-ehvd_integration/src/main/resources/resources/properties/id_messages.properties +++ b/id/server/modules/moa-id-module-ehvd_integration/src/main/resources/resources/properties/id_messages.properties @@ -1,5 +1,6 @@ ehvd.00=Für den abgefragtem GDA liegt keine Berechtigung vor ehvd.01=Technischer Fehler bei der Abfrage von GDA Informationen. Ursache: {0} ehvd.02=Fehler bei der Abfrage von GDA Informationen. Ursache: {0} +ehvd.03=Antwort des EHVD Service beinhaltet keine GDA Informationen ehvd.99=Allgemeiner Fehler bei der Abfrage des EHVD Service diff --git a/id/server/modules/moa-id-module-ehvd_integration/src/main/resources/resources/properties/protocol_response_statuscodes.properties b/id/server/modules/moa-id-module-ehvd_integration/src/main/resources/resources/properties/protocol_response_statuscodes.properties index 400994330..72048b8e3 100644 --- a/id/server/modules/moa-id-module-ehvd_integration/src/main/resources/resources/properties/protocol_response_statuscodes.properties +++ b/id/server/modules/moa-id-module-ehvd_integration/src/main/resources/resources/properties/protocol_response_statuscodes.properties @@ -4,4 +4,5 @@ test.02=zzzyyyxxx ehvd.00=7000 ehvd.01=7001 ehvd.02=7001 +ehvd.03=7001 ehvd.99=7099 \ No newline at end of file diff --git a/id/server/modules/moa-id-module-ehvd_integration/src/test/java/at/gv/egovernment/moa/id/auth/modules/ehvd/test/tasks/InjectEhvdIdentityInformationQsSystemTest.java b/id/server/modules/moa-id-module-ehvd_integration/src/test/java/at/gv/egovernment/moa/id/auth/modules/ehvd/test/tasks/InjectEhvdIdentityInformationQsSystemTest.java index 585083a77..e77e2db58 100644 --- a/id/server/modules/moa-id-module-ehvd_integration/src/test/java/at/gv/egovernment/moa/id/auth/modules/ehvd/test/tasks/InjectEhvdIdentityInformationQsSystemTest.java +++ b/id/server/modules/moa-id-module-ehvd_integration/src/test/java/at/gv/egovernment/moa/id/auth/modules/ehvd/test/tasks/InjectEhvdIdentityInformationQsSystemTest.java @@ -120,8 +120,8 @@ public class InjectEhvdIdentityInformationQsSystemTest { final AuthenticationSessionWrapper moaSession = pendingReq.getSessionData( AuthenticationSessionWrapper.class); moaSession.setIdentityLink(TestUtils.generateDummyIdl( - RandomStringUtils.randomAlphanumeric(10), - EAAFConstants.URN_PREFIX_BASEID)); + "SUTFhJ/FXHmLGfTFchYnnWG/e3A=", + EAAFConstants.URN_PREFIX_CDID + "GH")); task.execute(pendingReq, context); diff --git a/id/server/modules/moa-id-module-ehvd_integration/src/test/java/at/gv/egovernment/moa/id/auth/modules/ehvd/test/tasks/InjectEhvdIdentityInformationTaskTest.java b/id/server/modules/moa-id-module-ehvd_integration/src/test/java/at/gv/egovernment/moa/id/auth/modules/ehvd/test/tasks/InjectEhvdIdentityInformationTaskTest.java index 0c84a7bcf..8620ef98b 100644 --- a/id/server/modules/moa-id-module-ehvd_integration/src/test/java/at/gv/egovernment/moa/id/auth/modules/ehvd/test/tasks/InjectEhvdIdentityInformationTaskTest.java +++ b/id/server/modules/moa-id-module-ehvd_integration/src/test/java/at/gv/egovernment/moa/id/auth/modules/ehvd/test/tasks/InjectEhvdIdentityInformationTaskTest.java @@ -196,6 +196,23 @@ public class InjectEhvdIdentityInformationTaskTest { } } + @Test + public void noGdaInfosInResponse() throws TaskExecutionException, PendingReqIdValidationException { + // set-up EHVD response + GdaIndexResponse gdaResponse = new GdaIndexResponse(); + when(ehvdService.getGDA(any())).thenReturn(gdaResponse); + + try { + task.execute(pendingReq, context); + fail("wrong state not detected"); + + } catch (final TaskExecutionException e) { + Assert.isInstanceOf(AuthenticationException.class, e.getOriginalException(), "wrong execpetion"); + assertEquals("wrong errorCode", "ehvd.03", ((EAAFException) e.getOriginalException()).getErrorId()); + + } + } + @Test public void validateState() throws TaskExecutionException, PendingReqIdValidationException { // set-up EHVD response -- cgit v1.2.3