aboutsummaryrefslogtreecommitdiff
path: root/id/server/modules/moa-id-module-ehvd_integration/src/test/java
diff options
context:
space:
mode:
Diffstat (limited to 'id/server/modules/moa-id-module-ehvd_integration/src/test/java')
-rw-r--r--id/server/modules/moa-id-module-ehvd_integration/src/test/java/at/gv/egovernment/moa/id/auth/modules/ehvd/test/tasks/InjectEhvdIdentityInformationTaskTest.java42
1 files changed, 38 insertions, 4 deletions
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 adedd1d02..818a2c34b 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
@@ -1,8 +1,10 @@
package at.gv.egovernment.moa.id.auth.modules.ehvd.test.tasks;
+import static org.hamcrest.CoreMatchers.instanceOf;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.when;
@@ -61,11 +63,14 @@ import at.gv.egiz.eaaf.core.impl.idp.module.test.TestRequestImpl;
import at.gv.egiz.eaaf.core.impl.idp.process.ExecutionContextImpl;
import at.gv.egovernment.moa.id.auth.data.AuthenticationSessionWrapper;
import at.gv.egovernment.moa.id.auth.exception.AuthenticationException;
+import at.gv.egovernment.moa.id.auth.modules.ehvd.ConfigurationProperties;
import at.gv.egovernment.moa.id.auth.modules.ehvd.client.wsdl.EHVD;
import at.gv.egovernment.moa.id.auth.modules.ehvd.client.wsdl.GDARoles;
import at.gv.egovernment.moa.id.auth.modules.ehvd.client.wsdl.GDAStatus;
+import at.gv.egovernment.moa.id.auth.modules.ehvd.client.wsdl.GdaAddress;
import at.gv.egovernment.moa.id.auth.modules.ehvd.client.wsdl.GdaDescriptor;
import at.gv.egovernment.moa.id.auth.modules.ehvd.client.wsdl.GdaIndexResponse;
+import at.gv.egovernment.moa.id.auth.modules.ehvd.client.wsdl.InstanceIdentifier;
import at.gv.egovernment.moa.id.auth.modules.ehvd.task.InjectEhvdInformationTask;
import at.gv.egovernment.moa.id.auth.modules.ehvd.test.dummy.DummyAuthConfigMap;
import at.gv.egovernment.moa.id.auth.modules.ehvd.test.dummy.TestUtils;
@@ -251,7 +256,7 @@ public class InjectEhvdIdentityInformationTaskTest {
assertFalse("foreign", moaSession.isForeigner());
assertFalse("mandate", moaSession.isMandateUsed());
- assertEquals("missing attributes", 1, moaSession.getGenericSessionDataStorage().size());
+ assertEquals("missing attributes", 2, moaSession.getGenericSessionDataStorage().size());
assertNotNull("no Role attr", moaSession.getGenericDataFromSession(PVPConstants.ROLES_NAME));
assertEquals("wrong role attr",
"EPI-GDA()",
@@ -278,7 +283,7 @@ public class InjectEhvdIdentityInformationTaskTest {
assertFalse("foreign", moaSession.isForeigner());
assertFalse("mandate", moaSession.isMandateUsed());
- assertEquals("missing attributes", 1, moaSession.getGenericSessionDataStorage().size());
+ assertEquals("missing attributes", 2, moaSession.getGenericSessionDataStorage().size());
assertNotNull("no Role attr", moaSession.getGenericDataFromSession(PVPConstants.ROLES_NAME));
assertEquals("wrong role attr",
"EPI-GDA()",
@@ -292,7 +297,8 @@ public class InjectEhvdIdentityInformationTaskTest {
String role1 = "1.2.40.0.33.5.2.101";
String role2 = "1.2.40.0.34.5.2:158";
String role3 = RandomStringUtils.randomAlphabetic(10);
- when(ehvdService.getGDA(any())).thenReturn(generateGdaResponse(true, Arrays.asList(role1, role2, role3)));
+ GdaIndexResponse gdaResponse = generateGdaResponse(true, Arrays.asList(role1, role2, role3));
+ when(ehvdService.getGDA(any())).thenReturn(gdaResponse);
task.execute(pendingReq, context);
@@ -305,11 +311,17 @@ public class InjectEhvdIdentityInformationTaskTest {
assertFalse("foreign", moaSession.isForeigner());
assertFalse("mandate", moaSession.isMandateUsed());
- assertEquals("missing attributes", 1, moaSession.getGenericSessionDataStorage().size());
+ assertEquals("missing attributes", 2, moaSession.getGenericSessionDataStorage().size());
assertNotNull("no Role attr", moaSession.getGenericDataFromSession(PVPConstants.ROLES_NAME));
assertEquals("wrong role attr",
"EPI-GDA()",
moaSession.getGenericDataFromSession(PVPConstants.ROLES_NAME, String.class));
+
+ assertNotNull("no full GDA response",
+ moaSession.getGenericDataFromSession(ConfigurationProperties.ATTRIBUTE_URN_EHVD_PREFIX));
+ assertTrue("wrong GDA response type",
+ moaSession.getGenericDataFromSession(ConfigurationProperties.ATTRIBUTE_URN_EHVD_PREFIX) instanceof GdaDescriptor);
+
}
@@ -322,6 +334,20 @@ public class InjectEhvdIdentityInformationTaskTest {
gda.setStatus(status);
status.setEhvdstatus(isActive ? "Aktiv" : "Inaktiv");
+ gda.setFirstname(RandomStringUtils.randomAlphabetic(5));
+ gda.setSurname(RandomStringUtils.randomAlphabetic(5));
+ gda.setTitle(RandomStringUtils.randomAlphabetic(5));
+
+ InstanceIdentifier id = new InstanceIdentifier();
+ id.setId(RandomStringUtils.randomAlphabetic(5));
+ gda.setId(id);
+
+ gda.getOtherID().add(RandomStringUtils.randomAlphabetic(5));
+ gda.getOtherID().add(RandomStringUtils.randomAlphabetic(5));
+
+ gda.getAddress().add(generateAddress());
+ gda.getAddress().add(generateAddress());
+
GDARoles gdaRoles = new GDARoles();
gda.setRoles(gdaRoles);
gdaRoles.getRole().addAll(roles);
@@ -329,6 +355,14 @@ public class InjectEhvdIdentityInformationTaskTest {
return resp;
}
+ private GdaAddress generateAddress() {
+ GdaAddress address = new GdaAddress();
+ address.setZip(RandomStringUtils.randomNumeric(4));
+ address.setState(RandomStringUtils.randomAlphabetic(10));
+ return address;
+
+ }
+
private SOAPFault generateSoaFault(String msg) {
return new SOAPFault() {