aboutsummaryrefslogtreecommitdiff
path: root/id/server/modules/moa-id-module-ehvd_integration/src/test/java/at
diff options
context:
space:
mode:
authorThomas Lenz <thomas.lenz@egiz.gv.at>2021-09-16 09:48:24 +0200
committerThomas Lenz <thomas.lenz@egiz.gv.at>2021-09-16 09:48:24 +0200
commit90eac625e68bdb9aaf1397b04f242fb94381bd4c (patch)
tree8bb2d12f8a428b342e5d5bfc7a12c63f3206bbe8 /id/server/modules/moa-id-module-ehvd_integration/src/test/java/at
parent664c9bcffc537dc206140f03ca0a7c9b81b396cd (diff)
downloadmoa-id-spss-90eac625e68bdb9aaf1397b04f242fb94381bd4c.tar.gz
moa-id-spss-90eac625e68bdb9aaf1397b04f242fb94381bd4c.tar.bz2
moa-id-spss-90eac625e68bdb9aaf1397b04f242fb94381bd4c.zip
add new attribute builder for EHVD specific attributes
Diffstat (limited to 'id/server/modules/moa-id-module-ehvd_integration/src/test/java/at')
-rw-r--r--id/server/modules/moa-id-module-ehvd_integration/src/test/java/at/gv/egovernment/moa/id/auth/modules/ehvd/test/attributes/AbstractEhvdAttributeBuilderTest.java97
-rw-r--r--id/server/modules/moa-id-module-ehvd_integration/src/test/java/at/gv/egovernment/moa/id/auth/modules/ehvd/test/attributes/EhvdAddressStateAttributeBuilderTest.java106
-rw-r--r--id/server/modules/moa-id-module-ehvd_integration/src/test/java/at/gv/egovernment/moa/id/auth/modules/ehvd/test/attributes/EhvdAddressZipAttributeBuilderTest.java107
-rw-r--r--id/server/modules/moa-id-module-ehvd_integration/src/test/java/at/gv/egovernment/moa/id/auth/modules/ehvd/test/attributes/EhvdFirstnameAttributeBuilderTest.java47
-rw-r--r--id/server/modules/moa-id-module-ehvd_integration/src/test/java/at/gv/egovernment/moa/id/auth/modules/ehvd/test/attributes/EhvdIdAttributeBuilderTest.java64
-rw-r--r--id/server/modules/moa-id-module-ehvd_integration/src/test/java/at/gv/egovernment/moa/id/auth/modules/ehvd/test/attributes/EhvdOtherIdAttributeBuilderTest.java86
-rw-r--r--id/server/modules/moa-id-module-ehvd_integration/src/test/java/at/gv/egovernment/moa/id/auth/modules/ehvd/test/attributes/EhvdSurnameAttributeBuilderTest.java48
-rw-r--r--id/server/modules/moa-id-module-ehvd_integration/src/test/java/at/gv/egovernment/moa/id/auth/modules/ehvd/test/attributes/EhvdTitelAttributeBuilderTest.java46
-rw-r--r--id/server/modules/moa-id-module-ehvd_integration/src/test/java/at/gv/egovernment/moa/id/auth/modules/ehvd/test/attributes/PvpRoleAttributeBuilderTest.java9
9 files changed, 610 insertions, 0 deletions
diff --git a/id/server/modules/moa-id-module-ehvd_integration/src/test/java/at/gv/egovernment/moa/id/auth/modules/ehvd/test/attributes/AbstractEhvdAttributeBuilderTest.java b/id/server/modules/moa-id-module-ehvd_integration/src/test/java/at/gv/egovernment/moa/id/auth/modules/ehvd/test/attributes/AbstractEhvdAttributeBuilderTest.java
new file mode 100644
index 000000000..b1ac7d99a
--- /dev/null
+++ b/id/server/modules/moa-id-module-ehvd_integration/src/test/java/at/gv/egovernment/moa/id/auth/modules/ehvd/test/attributes/AbstractEhvdAttributeBuilderTest.java
@@ -0,0 +1,97 @@
+package at.gv.egovernment.moa.id.auth.modules.ehvd.test.attributes;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+
+import java.util.Collections;
+
+import org.apache.commons.lang3.RandomStringUtils;
+import org.junit.Before;
+import org.junit.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import at.gv.egiz.eaaf.core.api.idp.IAttributeBuilder;
+import at.gv.egiz.eaaf.core.api.idp.IAttributeGenerator;
+import at.gv.egiz.eaaf.core.api.idp.IAuthData;
+import at.gv.egiz.eaaf.core.api.idp.IConfiguration;
+import at.gv.egiz.eaaf.core.exceptions.AttributeBuilderException;
+import at.gv.egiz.eaaf.core.exceptions.EAAFStorageException;
+import at.gv.egiz.eaaf.core.impl.idp.AuthenticationData;
+import at.gv.egiz.eaaf.core.impl.idp.builder.SimpleStringAttributeGenerator;
+import at.gv.egiz.eaaf.core.impl.idp.module.test.DummySPConfiguration;
+import at.gv.egiz.eaaf.modules.pvp2.impl.builder.PVPAttributeBuilder;
+import at.gv.egovernment.moa.id.auth.modules.ehvd.ConfigurationProperties;
+import at.gv.egovernment.moa.id.auth.modules.ehvd.client.wsdl.GdaAddress;
+import at.gv.egovernment.moa.id.auth.modules.ehvd.client.wsdl.GdaDescriptor;
+
+public abstract class AbstractEhvdAttributeBuilderTest {
+
+ @Autowired
+ protected IConfiguration basicConfig;
+
+ protected DummySPConfiguration oaParam;
+ protected AuthenticationData authData;
+ protected IAttributeGenerator<String> g = new SimpleStringAttributeGenerator();
+
+ protected abstract String expectedAttrName();
+ protected abstract IAttributeBuilder getAttributeBuilderUnderTest();
+
+ protected GdaAddress generateAddress(String zip, String state) {
+ GdaAddress addr = new GdaAddress();
+ addr.setZip(zip);
+ addr.setState(state);
+ return addr;
+
+ }
+
+ @Before
+ public void initialize() {
+ oaParam = new DummySPConfiguration(Collections.emptyMap(), basicConfig);
+ authData = new AuthenticationData();
+
+ }
+
+ @Test
+ public void checkAttributeRegistration() {
+ assertNotNull("Attribute: " + expectedAttrName() + " not registrated",
+ PVPAttributeBuilder.getAttributeBuilder(expectedAttrName()));
+
+ }
+
+ @Test
+ public void checkName() {
+ assertEquals("wrong attr. name", expectedAttrName(), getAttributeBuilderUnderTest().getName());
+
+ }
+
+ @Test
+ public void checkEmptyAttribute() {
+ assertNull("wrong empty attr.", getAttributeBuilderUnderTest().buildEmpty(g));
+
+ }
+
+ @Test
+ public void noGdaInfos() throws AttributeBuilderException {
+ IAuthData authData = new AuthenticationData();
+ assertNull("wrong empty attr.", getAttributeBuilderUnderTest().build(oaParam, authData, g));
+
+ }
+
+ @Test
+ public void wrongGdaInfos() throws AttributeBuilderException, EAAFStorageException {
+ AuthenticationData authData = new AuthenticationData();
+ authData.setGenericData(ConfigurationProperties.ATTRIBUTE_URN_EHVD_PREFIX, RandomStringUtils.randomAlphabetic(10));
+ assertNull("wrong empty attr.", getAttributeBuilderUnderTest().build(oaParam, authData, g));
+
+ }
+
+ @Test
+ public void emptyGdaInfos() throws AttributeBuilderException, EAAFStorageException {
+ AuthenticationData authData = new AuthenticationData();
+ authData.setGenericData(ConfigurationProperties.ATTRIBUTE_URN_EHVD_PREFIX, new GdaDescriptor());
+ assertNull("wrong empty attr.", getAttributeBuilderUnderTest().build(oaParam, authData, g));
+
+ }
+
+}
diff --git a/id/server/modules/moa-id-module-ehvd_integration/src/test/java/at/gv/egovernment/moa/id/auth/modules/ehvd/test/attributes/EhvdAddressStateAttributeBuilderTest.java b/id/server/modules/moa-id-module-ehvd_integration/src/test/java/at/gv/egovernment/moa/id/auth/modules/ehvd/test/attributes/EhvdAddressStateAttributeBuilderTest.java
new file mode 100644
index 000000000..d342d331b
--- /dev/null
+++ b/id/server/modules/moa-id-module-ehvd_integration/src/test/java/at/gv/egovernment/moa/id/auth/modules/ehvd/test/attributes/EhvdAddressStateAttributeBuilderTest.java
@@ -0,0 +1,106 @@
+//package at.gv.egovernment.moa.id.auth.modules.ehvd.test.attributes;
+//
+//import static org.junit.Assert.assertEquals;
+//import static org.junit.Assert.assertNull;
+//
+//import org.apache.commons.lang3.RandomStringUtils;
+//import org.junit.Test;
+//import org.junit.runner.RunWith;
+//import org.springframework.test.context.ContextConfiguration;
+//import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+//
+//import at.gv.egiz.eaaf.core.api.idp.IAttributeBuilder;
+//import at.gv.egiz.eaaf.core.exceptions.AttributeBuilderException;
+//import at.gv.egiz.eaaf.core.exceptions.EAAFStorageException;
+//import at.gv.egovernment.moa.id.auth.modules.ehvd.ConfigurationProperties;
+//import at.gv.egovernment.moa.id.auth.modules.ehvd.attributes.EhvdAddressStateAttributeBuilder;
+//import at.gv.egovernment.moa.id.auth.modules.ehvd.attributes.EhvdAddressZipcodeAttributeBuilder;
+//import at.gv.egovernment.moa.id.auth.modules.ehvd.attributes.EhvdFirstnameAttributeBuilder;
+//import at.gv.egovernment.moa.id.auth.modules.ehvd.attributes.EhvdOtherIdAttributeBuilder;
+//import at.gv.egovernment.moa.id.auth.modules.ehvd.attributes.EhvdSurnameAttributeBuilder;
+//import at.gv.egovernment.moa.id.auth.modules.ehvd.attributes.EhvdTitelAttributeBuilder;
+//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.InstanceIdentifier;
+//
+//@RunWith(SpringJUnit4ClassRunner.class)
+//@ContextConfiguration({
+// "/test_ehvd_service_auth.beans.xml" })
+//public class EhvdAddressStateAttributeBuilderTest extends AbstractEhvdAttributeBuilderTest {
+//
+// @Override
+// protected String expectedAttrName() {
+// return "urn:brzgvat:attributes.ehvd.state";
+//
+// }
+//
+// @Override
+// protected IAttributeBuilder getAttributeBuilderUnderTest() {
+// return new EhvdAddressStateAttributeBuilder();
+//
+// }
+//
+// @Test
+// public void checkMissing() throws EAAFStorageException, AttributeBuilderException {
+// final GdaDescriptor gdaInfo = new GdaDescriptor();
+// authData.setGenericData(ConfigurationProperties.ATTRIBUTE_URN_EHVD_PREFIX, gdaInfo);
+// assertNull("wrong empty attr.", getAttributeBuilderUnderTest().build(oaParam, authData, g));
+//
+// }
+//
+// @Test
+// public void singleAddress() throws EAAFStorageException, AttributeBuilderException {
+// String state = RandomStringUtils.randomAlphabetic(5);
+// final GdaDescriptor gdaInfo = new GdaDescriptor();
+// gdaInfo.getAddress().add(generateAddress(RandomStringUtils.randomNumeric(5), state));
+//
+// authData.setGenericData(ConfigurationProperties.ATTRIBUTE_URN_EHVD_PREFIX, gdaInfo);
+// assertEquals("wrong empty attr.", state,
+// getAttributeBuilderUnderTest().build(oaParam, authData, g));
+//
+// }
+//
+// @Test
+// public void multiAddress() throws EAAFStorageException, AttributeBuilderException {
+// String state1 = RandomStringUtils.randomAlphabetic(4);
+// String state2 = RandomStringUtils.randomAlphabetic(4);
+// final GdaDescriptor gdaInfo = new GdaDescriptor();
+// gdaInfo.getAddress().add(generateAddress(RandomStringUtils.randomNumeric(4), state1));
+// gdaInfo.getAddress().add(generateAddress(RandomStringUtils.randomNumeric(4), state2));
+//
+// authData.setGenericData(ConfigurationProperties.ATTRIBUTE_URN_EHVD_PREFIX, gdaInfo);
+// assertEquals("wrong empty attr.", state1 + "|" + state2,
+// getAttributeBuilderUnderTest().build(oaParam, authData, g));
+//
+// }
+//
+// @Test
+// public void multiAddressNullBefore() throws EAAFStorageException, AttributeBuilderException {
+// String state1 = null;
+// String state2 = RandomStringUtils.randomAlphabetic(4);
+// final GdaDescriptor gdaInfo = new GdaDescriptor();
+// gdaInfo.getAddress().add(generateAddress(RandomStringUtils.randomNumeric(4), state1));
+// gdaInfo.getAddress().add(generateAddress(RandomStringUtils.randomNumeric(4), state2));
+//
+// authData.setGenericData(ConfigurationProperties.ATTRIBUTE_URN_EHVD_PREFIX, gdaInfo);
+// assertEquals("wrong empty attr.", "|" + state2,
+// getAttributeBuilderUnderTest().build(oaParam, authData, g));
+//
+// }
+//
+// @Test
+// public void multiAddressNullAfter() throws EAAFStorageException, AttributeBuilderException {
+// String state1 = RandomStringUtils.randomAlphabetic(4);
+// String state2 = null;
+// final GdaDescriptor gdaInfo = new GdaDescriptor();
+// gdaInfo.getAddress().add(generateAddress(RandomStringUtils.randomNumeric(4), state1));
+// gdaInfo.getAddress().add(generateAddress(RandomStringUtils.randomNumeric(4), state2));
+//
+// authData.setGenericData(ConfigurationProperties.ATTRIBUTE_URN_EHVD_PREFIX, gdaInfo);
+// assertEquals("wrong empty attr.", state1 + "|",
+// getAttributeBuilderUnderTest().build(oaParam, authData, g));
+//
+// }
+//
+//
+//}
diff --git a/id/server/modules/moa-id-module-ehvd_integration/src/test/java/at/gv/egovernment/moa/id/auth/modules/ehvd/test/attributes/EhvdAddressZipAttributeBuilderTest.java b/id/server/modules/moa-id-module-ehvd_integration/src/test/java/at/gv/egovernment/moa/id/auth/modules/ehvd/test/attributes/EhvdAddressZipAttributeBuilderTest.java
new file mode 100644
index 000000000..69d17f8c3
--- /dev/null
+++ b/id/server/modules/moa-id-module-ehvd_integration/src/test/java/at/gv/egovernment/moa/id/auth/modules/ehvd/test/attributes/EhvdAddressZipAttributeBuilderTest.java
@@ -0,0 +1,107 @@
+//package at.gv.egovernment.moa.id.auth.modules.ehvd.test.attributes;
+//
+//import static org.junit.Assert.assertEquals;
+//import static org.junit.Assert.assertNull;
+//
+//import org.apache.commons.lang3.RandomStringUtils;
+//import org.junit.Test;
+//import org.junit.runner.RunWith;
+//import org.springframework.test.context.ContextConfiguration;
+//import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+//
+//import at.gv.egiz.eaaf.core.api.idp.IAttributeBuilder;
+//import at.gv.egiz.eaaf.core.exceptions.AttributeBuilderException;
+//import at.gv.egiz.eaaf.core.exceptions.EAAFStorageException;
+//import at.gv.egovernment.moa.id.auth.modules.ehvd.ConfigurationProperties;
+//import at.gv.egovernment.moa.id.auth.modules.ehvd.attributes.EhvdAddressZipcodeAttributeBuilder;
+//import at.gv.egovernment.moa.id.auth.modules.ehvd.attributes.EhvdFirstnameAttributeBuilder;
+//import at.gv.egovernment.moa.id.auth.modules.ehvd.attributes.EhvdOtherIdAttributeBuilder;
+//import at.gv.egovernment.moa.id.auth.modules.ehvd.attributes.EhvdSurnameAttributeBuilder;
+//import at.gv.egovernment.moa.id.auth.modules.ehvd.attributes.EhvdTitelAttributeBuilder;
+//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.InstanceIdentifier;
+//
+//@RunWith(SpringJUnit4ClassRunner.class)
+//@ContextConfiguration({
+// "/test_ehvd_service_auth.beans.xml" })
+//public class EhvdAddressZipAttributeBuilderTest extends AbstractEhvdAttributeBuilderTest {
+//
+// @Override
+// protected String expectedAttrName() {
+// return "urn:brzgvat:attributes.ehvd.zip";
+//
+// }
+//
+// @Override
+// protected IAttributeBuilder getAttributeBuilderUnderTest() {
+// return new EhvdAddressZipcodeAttributeBuilder();
+//
+// }
+//
+// @Test
+// public void checkMissing() throws EAAFStorageException, AttributeBuilderException {
+// final GdaDescriptor gdaInfo = new GdaDescriptor();
+// authData.setGenericData(ConfigurationProperties.ATTRIBUTE_URN_EHVD_PREFIX, gdaInfo);
+// assertNull("wrong empty attr.", getAttributeBuilderUnderTest().build(oaParam, authData, g));
+//
+// }
+//
+// @Test
+// public void singleAddress() throws EAAFStorageException, AttributeBuilderException {
+// String zip = RandomStringUtils.randomNumeric(4);
+// final GdaDescriptor gdaInfo = new GdaDescriptor();
+// gdaInfo.getAddress().add(generateAddress(
+// zip,
+// RandomStringUtils.randomAlphabetic(5)));
+//
+// authData.setGenericData(ConfigurationProperties.ATTRIBUTE_URN_EHVD_PREFIX, gdaInfo);
+// assertEquals("wrong empty attr.", zip,
+// getAttributeBuilderUnderTest().build(oaParam, authData, g));
+//
+// }
+//
+// @Test
+// public void multiAddress() throws EAAFStorageException, AttributeBuilderException {
+// String zip1 = RandomStringUtils.randomNumeric(4);
+// String zip2 = RandomStringUtils.randomNumeric(4);
+// final GdaDescriptor gdaInfo = new GdaDescriptor();
+// gdaInfo.getAddress().add(generateAddress(zip1, RandomStringUtils.randomAlphabetic(5)));
+// gdaInfo.getAddress().add(generateAddress(zip2, RandomStringUtils.randomAlphabetic(5)));
+//
+// authData.setGenericData(ConfigurationProperties.ATTRIBUTE_URN_EHVD_PREFIX, gdaInfo);
+// assertEquals("wrong empty attr.", zip1 + "|" + zip2,
+// getAttributeBuilderUnderTest().build(oaParam, authData, g));
+//
+// }
+//
+// @Test
+// public void multiAddressNullBefore() throws EAAFStorageException, AttributeBuilderException {
+// String zip1 = null;
+// String zip2 = RandomStringUtils.randomNumeric(4);
+// final GdaDescriptor gdaInfo = new GdaDescriptor();
+// gdaInfo.getAddress().add(generateAddress(zip1, RandomStringUtils.randomAlphabetic(5)));
+// gdaInfo.getAddress().add(generateAddress(zip2, RandomStringUtils.randomAlphabetic(5)));
+//
+// authData.setGenericData(ConfigurationProperties.ATTRIBUTE_URN_EHVD_PREFIX, gdaInfo);
+// assertEquals("wrong empty attr.", "|" + zip2,
+// getAttributeBuilderUnderTest().build(oaParam, authData, g));
+//
+// }
+//
+// @Test
+// public void multiAddressNullAfter() throws EAAFStorageException, AttributeBuilderException {
+// String zip1 = RandomStringUtils.randomNumeric(4);
+// String zip2 = null;
+// final GdaDescriptor gdaInfo = new GdaDescriptor();
+// gdaInfo.getAddress().add(generateAddress(zip1, RandomStringUtils.randomAlphabetic(5)));
+// gdaInfo.getAddress().add(generateAddress(zip2, RandomStringUtils.randomAlphabetic(5)));
+//
+// authData.setGenericData(ConfigurationProperties.ATTRIBUTE_URN_EHVD_PREFIX, gdaInfo);
+// assertEquals("wrong empty attr.", zip1 + "|",
+// getAttributeBuilderUnderTest().build(oaParam, authData, g));
+//
+// }
+//
+//
+//}
diff --git a/id/server/modules/moa-id-module-ehvd_integration/src/test/java/at/gv/egovernment/moa/id/auth/modules/ehvd/test/attributes/EhvdFirstnameAttributeBuilderTest.java b/id/server/modules/moa-id-module-ehvd_integration/src/test/java/at/gv/egovernment/moa/id/auth/modules/ehvd/test/attributes/EhvdFirstnameAttributeBuilderTest.java
new file mode 100644
index 000000000..66f1b5028
--- /dev/null
+++ b/id/server/modules/moa-id-module-ehvd_integration/src/test/java/at/gv/egovernment/moa/id/auth/modules/ehvd/test/attributes/EhvdFirstnameAttributeBuilderTest.java
@@ -0,0 +1,47 @@
+package at.gv.egovernment.moa.id.auth.modules.ehvd.test.attributes;
+
+import static org.junit.Assert.assertEquals;
+
+import org.apache.commons.lang3.RandomStringUtils;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+import at.gv.egiz.eaaf.core.api.idp.IAttributeBuilder;
+import at.gv.egiz.eaaf.core.exceptions.AttributeBuilderException;
+import at.gv.egiz.eaaf.core.exceptions.EAAFStorageException;
+import at.gv.egovernment.moa.id.auth.modules.ehvd.ConfigurationProperties;
+import at.gv.egovernment.moa.id.auth.modules.ehvd.attributes.EhvdFirstnameAttributeBuilder;
+import at.gv.egovernment.moa.id.auth.modules.ehvd.attributes.EhvdTitelAttributeBuilder;
+import at.gv.egovernment.moa.id.auth.modules.ehvd.client.wsdl.GdaDescriptor;
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration({
+ "/test_ehvd_service_auth.beans.xml" })
+public class EhvdFirstnameAttributeBuilderTest extends AbstractEhvdAttributeBuilderTest {
+
+ @Override
+ protected String expectedAttrName() {
+ return "urn:brzgvat:attributes.ehvd.firstname";
+
+ }
+
+ @Override
+ protected IAttributeBuilder getAttributeBuilderUnderTest() {
+ return new EhvdFirstnameAttributeBuilder();
+
+ }
+
+ @Test
+ public void checkValid() throws EAAFStorageException, AttributeBuilderException {
+ final GdaDescriptor gdaInfo = new GdaDescriptor();
+ gdaInfo.setFirstname(RandomStringUtils.randomAlphabetic(5));
+
+ authData.setGenericData(ConfigurationProperties.ATTRIBUTE_URN_EHVD_PREFIX, gdaInfo);
+ assertEquals("wrong empty attr.", gdaInfo.getFirstname(),
+ getAttributeBuilderUnderTest().build(oaParam, authData, g));
+
+ }
+
+}
diff --git a/id/server/modules/moa-id-module-ehvd_integration/src/test/java/at/gv/egovernment/moa/id/auth/modules/ehvd/test/attributes/EhvdIdAttributeBuilderTest.java b/id/server/modules/moa-id-module-ehvd_integration/src/test/java/at/gv/egovernment/moa/id/auth/modules/ehvd/test/attributes/EhvdIdAttributeBuilderTest.java
new file mode 100644
index 000000000..db73f9191
--- /dev/null
+++ b/id/server/modules/moa-id-module-ehvd_integration/src/test/java/at/gv/egovernment/moa/id/auth/modules/ehvd/test/attributes/EhvdIdAttributeBuilderTest.java
@@ -0,0 +1,64 @@
+package at.gv.egovernment.moa.id.auth.modules.ehvd.test.attributes;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+
+import org.apache.commons.lang3.RandomStringUtils;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+import at.gv.egiz.eaaf.core.api.idp.IAttributeBuilder;
+import at.gv.egiz.eaaf.core.exceptions.AttributeBuilderException;
+import at.gv.egiz.eaaf.core.exceptions.EAAFStorageException;
+import at.gv.egovernment.moa.id.auth.modules.ehvd.ConfigurationProperties;
+import at.gv.egovernment.moa.id.auth.modules.ehvd.attributes.EhvdFirstnameAttributeBuilder;
+import at.gv.egovernment.moa.id.auth.modules.ehvd.attributes.EhvdIdAttributeBuilder;
+import at.gv.egovernment.moa.id.auth.modules.ehvd.attributes.EhvdSurnameAttributeBuilder;
+import at.gv.egovernment.moa.id.auth.modules.ehvd.attributes.EhvdTitelAttributeBuilder;
+import at.gv.egovernment.moa.id.auth.modules.ehvd.client.wsdl.GdaDescriptor;
+import at.gv.egovernment.moa.id.auth.modules.ehvd.client.wsdl.InstanceIdentifier;
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration({
+ "/test_ehvd_service_auth.beans.xml" })
+public class EhvdIdAttributeBuilderTest extends AbstractEhvdAttributeBuilderTest {
+
+ @Override
+ protected String expectedAttrName() {
+ return "urn:brzgvat:attributes.ehvd.id";
+
+ }
+
+ @Override
+ protected IAttributeBuilder getAttributeBuilderUnderTest() {
+ return new EhvdIdAttributeBuilder();
+
+ }
+
+ @Test
+ public void checkMissingId() throws EAAFStorageException, AttributeBuilderException {
+ final GdaDescriptor gdaInfo = new GdaDescriptor();
+ InstanceIdentifier id = new InstanceIdentifier();
+ gdaInfo.setId(id );
+
+ authData.setGenericData(ConfigurationProperties.ATTRIBUTE_URN_EHVD_PREFIX, gdaInfo);
+ assertNull("wrong empty attr.", getAttributeBuilderUnderTest().build(oaParam, authData, g));
+
+ }
+
+ @Test
+ public void checkValid() throws EAAFStorageException, AttributeBuilderException {
+ final GdaDescriptor gdaInfo = new GdaDescriptor();
+ InstanceIdentifier id = new InstanceIdentifier();
+ id.setId(RandomStringUtils.randomAlphabetic(5));
+ gdaInfo.setId(id );
+
+ authData.setGenericData(ConfigurationProperties.ATTRIBUTE_URN_EHVD_PREFIX, gdaInfo);
+ assertEquals("wrong empty attr.", id.getId(),
+ getAttributeBuilderUnderTest().build(oaParam, authData, g));
+
+ }
+
+}
diff --git a/id/server/modules/moa-id-module-ehvd_integration/src/test/java/at/gv/egovernment/moa/id/auth/modules/ehvd/test/attributes/EhvdOtherIdAttributeBuilderTest.java b/id/server/modules/moa-id-module-ehvd_integration/src/test/java/at/gv/egovernment/moa/id/auth/modules/ehvd/test/attributes/EhvdOtherIdAttributeBuilderTest.java
new file mode 100644
index 000000000..bce8924d9
--- /dev/null
+++ b/id/server/modules/moa-id-module-ehvd_integration/src/test/java/at/gv/egovernment/moa/id/auth/modules/ehvd/test/attributes/EhvdOtherIdAttributeBuilderTest.java
@@ -0,0 +1,86 @@
+//package at.gv.egovernment.moa.id.auth.modules.ehvd.test.attributes;
+//
+//import static org.junit.Assert.assertEquals;
+//import static org.junit.Assert.assertNull;
+//
+//import org.apache.commons.lang3.RandomStringUtils;
+//import org.junit.Test;
+//import org.junit.runner.RunWith;
+//import org.springframework.test.context.ContextConfiguration;
+//import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+//
+//import at.gv.egiz.eaaf.core.api.idp.IAttributeBuilder;
+//import at.gv.egiz.eaaf.core.exceptions.AttributeBuilderException;
+//import at.gv.egiz.eaaf.core.exceptions.EAAFStorageException;
+//import at.gv.egovernment.moa.id.auth.modules.ehvd.ConfigurationProperties;
+//import at.gv.egovernment.moa.id.auth.modules.ehvd.attributes.EhvdFirstnameAttributeBuilder;
+//import at.gv.egovernment.moa.id.auth.modules.ehvd.attributes.EhvdOtherIdAttributeBuilder;
+//import at.gv.egovernment.moa.id.auth.modules.ehvd.attributes.EhvdSurnameAttributeBuilder;
+//import at.gv.egovernment.moa.id.auth.modules.ehvd.attributes.EhvdTitelAttributeBuilder;
+//import at.gv.egovernment.moa.id.auth.modules.ehvd.client.wsdl.GdaDescriptor;
+//import at.gv.egovernment.moa.id.auth.modules.ehvd.client.wsdl.InstanceIdentifier;
+//
+//@RunWith(SpringJUnit4ClassRunner.class)
+//@ContextConfiguration({
+// "/test_ehvd_service_auth.beans.xml" })
+//public class EhvdOtherIdAttributeBuilderTest extends AbstractEhvdAttributeBuilderTest {
+//
+// @Override
+// protected String expectedAttrName() {
+// return "urn:brzgvat:attributes.ehvd.otherid";
+//
+// }
+//
+// @Override
+// protected IAttributeBuilder getAttributeBuilderUnderTest() {
+// return new EhvdOtherIdAttributeBuilder();
+//
+// }
+//
+// @Test
+// public void checkMissingId() throws EAAFStorageException, AttributeBuilderException {
+// final GdaDescriptor gdaInfo = new GdaDescriptor();
+// authData.setGenericData(ConfigurationProperties.ATTRIBUTE_URN_EHVD_PREFIX, gdaInfo);
+// assertNull("wrong empty attr.", getAttributeBuilderUnderTest().build(oaParam, authData, g));
+//
+// }
+//
+// @Test
+// public void checkWrongId() throws EAAFStorageException, AttributeBuilderException {
+// final GdaDescriptor gdaInfo = new GdaDescriptor();
+// gdaInfo.getOtherID().add(RandomStringUtils.randomAlphabetic(10));
+//
+// authData.setGenericData(ConfigurationProperties.ATTRIBUTE_URN_EHVD_PREFIX, gdaInfo);
+// assertNull("wrong empty attr.", getAttributeBuilderUnderTest().build(oaParam, authData, g));
+//
+// }
+//
+// @Test
+// public void checkValidRandom() throws EAAFStorageException, AttributeBuilderException {
+// String value = RandomStringUtils.randomAlphabetic(5);
+// final GdaDescriptor gdaInfo = new GdaDescriptor();
+// gdaInfo.getOtherID().add(RandomStringUtils.randomAlphabetic(10));
+// gdaInfo.getOtherID().add("1.2.40.0.34.4.18:" + value);
+//
+//
+// authData.setGenericData(ConfigurationProperties.ATTRIBUTE_URN_EHVD_PREFIX, gdaInfo);
+// assertEquals("wrong empty attr.", value,
+// getAttributeBuilderUnderTest().build(oaParam, authData, g));
+//
+// }
+//
+// @Test
+// public void checkValidBrzReal() throws EAAFStorageException, AttributeBuilderException {
+// final GdaDescriptor gdaInfo = new GdaDescriptor();
+// gdaInfo.getOtherID().add(RandomStringUtils.randomAlphabetic(10));
+// gdaInfo.getOtherID().add("1.2.40.0.34.4.18:1234-12");
+// gdaInfo.getOtherID().add("1.2.40.0.34.4.17:aabbccdd");
+//
+//
+// authData.setGenericData(ConfigurationProperties.ATTRIBUTE_URN_EHVD_PREFIX, gdaInfo);
+// assertEquals("wrong empty attr.", "1234-12",
+// getAttributeBuilderUnderTest().build(oaParam, authData, g));
+//
+// }
+//
+//}
diff --git a/id/server/modules/moa-id-module-ehvd_integration/src/test/java/at/gv/egovernment/moa/id/auth/modules/ehvd/test/attributes/EhvdSurnameAttributeBuilderTest.java b/id/server/modules/moa-id-module-ehvd_integration/src/test/java/at/gv/egovernment/moa/id/auth/modules/ehvd/test/attributes/EhvdSurnameAttributeBuilderTest.java
new file mode 100644
index 000000000..af9e60cb7
--- /dev/null
+++ b/id/server/modules/moa-id-module-ehvd_integration/src/test/java/at/gv/egovernment/moa/id/auth/modules/ehvd/test/attributes/EhvdSurnameAttributeBuilderTest.java
@@ -0,0 +1,48 @@
+package at.gv.egovernment.moa.id.auth.modules.ehvd.test.attributes;
+
+import static org.junit.Assert.assertEquals;
+
+import org.apache.commons.lang3.RandomStringUtils;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+import at.gv.egiz.eaaf.core.api.idp.IAttributeBuilder;
+import at.gv.egiz.eaaf.core.exceptions.AttributeBuilderException;
+import at.gv.egiz.eaaf.core.exceptions.EAAFStorageException;
+import at.gv.egovernment.moa.id.auth.modules.ehvd.ConfigurationProperties;
+import at.gv.egovernment.moa.id.auth.modules.ehvd.attributes.EhvdFirstnameAttributeBuilder;
+import at.gv.egovernment.moa.id.auth.modules.ehvd.attributes.EhvdSurnameAttributeBuilder;
+import at.gv.egovernment.moa.id.auth.modules.ehvd.attributes.EhvdTitelAttributeBuilder;
+import at.gv.egovernment.moa.id.auth.modules.ehvd.client.wsdl.GdaDescriptor;
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration({
+ "/test_ehvd_service_auth.beans.xml" })
+public class EhvdSurnameAttributeBuilderTest extends AbstractEhvdAttributeBuilderTest {
+
+ @Override
+ protected String expectedAttrName() {
+ return "urn:brzgvat:attributes.ehvd.surname";
+
+ }
+
+ @Override
+ protected IAttributeBuilder getAttributeBuilderUnderTest() {
+ return new EhvdSurnameAttributeBuilder();
+
+ }
+
+ @Test
+ public void checkValid() throws EAAFStorageException, AttributeBuilderException {
+ final GdaDescriptor gdaInfo = new GdaDescriptor();
+ gdaInfo.setSurname(RandomStringUtils.randomAlphabetic(5));
+
+ authData.setGenericData(ConfigurationProperties.ATTRIBUTE_URN_EHVD_PREFIX, gdaInfo);
+ assertEquals("wrong empty attr.", gdaInfo.getSurname(),
+ getAttributeBuilderUnderTest().build(oaParam, authData, g));
+
+ }
+
+}
diff --git a/id/server/modules/moa-id-module-ehvd_integration/src/test/java/at/gv/egovernment/moa/id/auth/modules/ehvd/test/attributes/EhvdTitelAttributeBuilderTest.java b/id/server/modules/moa-id-module-ehvd_integration/src/test/java/at/gv/egovernment/moa/id/auth/modules/ehvd/test/attributes/EhvdTitelAttributeBuilderTest.java
new file mode 100644
index 000000000..2863c3508
--- /dev/null
+++ b/id/server/modules/moa-id-module-ehvd_integration/src/test/java/at/gv/egovernment/moa/id/auth/modules/ehvd/test/attributes/EhvdTitelAttributeBuilderTest.java
@@ -0,0 +1,46 @@
+package at.gv.egovernment.moa.id.auth.modules.ehvd.test.attributes;
+
+import static org.junit.Assert.assertEquals;
+
+import org.apache.commons.lang3.RandomStringUtils;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+import at.gv.egiz.eaaf.core.api.idp.IAttributeBuilder;
+import at.gv.egiz.eaaf.core.exceptions.AttributeBuilderException;
+import at.gv.egiz.eaaf.core.exceptions.EAAFStorageException;
+import at.gv.egovernment.moa.id.auth.modules.ehvd.ConfigurationProperties;
+import at.gv.egovernment.moa.id.auth.modules.ehvd.attributes.EhvdTitelAttributeBuilder;
+import at.gv.egovernment.moa.id.auth.modules.ehvd.client.wsdl.GdaDescriptor;
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration({
+ "/test_ehvd_service_auth.beans.xml" })
+public class EhvdTitelAttributeBuilderTest extends AbstractEhvdAttributeBuilderTest {
+
+ @Override
+ protected String expectedAttrName() {
+ return "urn:brzgvat:attributes.ehvd.title";
+
+ }
+
+ @Override
+ protected IAttributeBuilder getAttributeBuilderUnderTest() {
+ return new EhvdTitelAttributeBuilder();
+
+ }
+
+ @Test
+ public void checkTitelValid() throws EAAFStorageException, AttributeBuilderException {
+ final GdaDescriptor gdaInfo = new GdaDescriptor();
+ gdaInfo.setTitle(RandomStringUtils.randomAlphabetic(5));
+
+ authData.setGenericData(ConfigurationProperties.ATTRIBUTE_URN_EHVD_PREFIX, gdaInfo);
+ assertEquals("wrong empty attr.", gdaInfo.getTitle(),
+ getAttributeBuilderUnderTest().build(oaParam, authData, g));
+
+ }
+
+}
diff --git a/id/server/modules/moa-id-module-ehvd_integration/src/test/java/at/gv/egovernment/moa/id/auth/modules/ehvd/test/attributes/PvpRoleAttributeBuilderTest.java b/id/server/modules/moa-id-module-ehvd_integration/src/test/java/at/gv/egovernment/moa/id/auth/modules/ehvd/test/attributes/PvpRoleAttributeBuilderTest.java
index cabd8df19..624abff5f 100644
--- a/id/server/modules/moa-id-module-ehvd_integration/src/test/java/at/gv/egovernment/moa/id/auth/modules/ehvd/test/attributes/PvpRoleAttributeBuilderTest.java
+++ b/id/server/modules/moa-id-module-ehvd_integration/src/test/java/at/gv/egovernment/moa/id/auth/modules/ehvd/test/attributes/PvpRoleAttributeBuilderTest.java
@@ -26,6 +26,7 @@ import at.gv.egiz.eaaf.core.exceptions.AttributeBuilderException;
import at.gv.egiz.eaaf.core.impl.idp.AuthenticationData;
import at.gv.egiz.eaaf.core.impl.idp.builder.SimpleStringAttributeGenerator;
import at.gv.egiz.eaaf.core.impl.idp.module.test.DummySPConfiguration;
+import at.gv.egiz.eaaf.modules.pvp2.impl.builder.PVPAttributeBuilder;
import at.gv.egovernment.moa.id.auth.modules.ehvd.attributes.PvpRoleAttributeBuilder;
import at.gv.egovernment.moa.id.data.AuthenticationRole;
import at.gv.egovernment.moa.id.data.AuthenticationRoleFactory;
@@ -51,6 +52,13 @@ public class PvpRoleAttributeBuilderTest {
}
@Test
+ public void checkAttributeRegistration() {
+ assertNotNull("Attribute: urn:oid:1.2.40.0.10.2.1.1.261.30 not registrated",
+ PVPAttributeBuilder.getAttributeBuilder("urn:oid:1.2.40.0.10.2.1.1.261.30"));
+
+ }
+
+ @Test
public void checkName() {
assertEquals("wrong attr. name", "urn:oid:1.2.40.0.10.2.1.1.261.30", toTest.getName());
@@ -69,6 +77,7 @@ public class PvpRoleAttributeBuilderTest {
}
+ @Test
public void noRoles() throws AttributeBuilderException {
IAuthData authData = generateAuthData(null);
assertNull("wrong attr. value", toTest.build(oaParam, authData, g));