aboutsummaryrefslogtreecommitdiff
path: root/modules/authmodule_id-austria/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'modules/authmodule_id-austria/src/test')
-rw-r--r--modules/authmodule_id-austria/src/test/java/at/asitplus/eidas/specific/modules/auth/idaustria/test/builder/attributes/SpRequiredAttributersAttributeBuilderTest.java72
-rw-r--r--modules/authmodule_id-austria/src/test/java/at/asitplus/eidas/specific/modules/auth/idaustria/test/task/ReceiveAuthnResponseTaskTest.java24
-rw-r--r--modules/authmodule_id-austria/src/test/java/at/asitplus/eidas/specific/modules/auth/idaustria/test/task/RequestIdAustriaSystemTaskTest.java72
3 files changed, 131 insertions, 37 deletions
diff --git a/modules/authmodule_id-austria/src/test/java/at/asitplus/eidas/specific/modules/auth/idaustria/test/builder/attributes/SpRequiredAttributersAttributeBuilderTest.java b/modules/authmodule_id-austria/src/test/java/at/asitplus/eidas/specific/modules/auth/idaustria/test/builder/attributes/SpRequiredAttributersAttributeBuilderTest.java
new file mode 100644
index 00000000..2fe420df
--- /dev/null
+++ b/modules/authmodule_id-austria/src/test/java/at/asitplus/eidas/specific/modules/auth/idaustria/test/builder/attributes/SpRequiredAttributersAttributeBuilderTest.java
@@ -0,0 +1,72 @@
+package at.asitplus.eidas.specific.modules.auth.idaustria.test.builder.attributes;
+
+import static org.junit.Assert.assertEquals;
+
+import java.util.List;
+
+import org.apache.commons.lang3.RandomStringUtils;
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.internal.util.collections.Sets;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+import at.asitplus.eidas.specific.core.config.ServiceProviderConfiguration;
+import at.asitplus.eidas.specific.modules.auth.idaustria.builder.attributes.SpRequiredAttributersAttributeBuilder;
+import at.gv.egiz.eaaf.core.api.data.PvpAttributeDefinitions;
+import at.gv.egiz.eaaf.core.api.idp.IAttributeBuilder;
+import at.gv.egiz.eaaf.core.exceptions.AttributeBuilderException;
+import at.gv.egiz.eaaf.core.impl.idp.auth.attributes.AbstractAttributeBuilderTest;
+import at.gv.egiz.eaaf.core.impl.idp.module.test.DummyConfiguration;
+import at.gv.egiz.eaaf.core.impl.utils.KeyValueUtils;
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration(locations = {
+ "/spring/SpringTest-context_basic_mapConfig.xml",
+ "/spring/SpringTest-context_basic_test.xml",
+})
+public class SpRequiredAttributersAttributeBuilderTest extends AbstractAttributeBuilderTest {
+
+private final IAttributeBuilder attrBuilder = new SpRequiredAttributersAttributeBuilder();
+
+ @Test
+ public void attributeName() {
+ Assert.assertEquals("Wrong attribute name",
+ "urn:eidgvat:attributes.RequiredAttributes", attrBuilder.getName());
+
+ }
+
+ @Test
+ public void checkEmptyAttribute() {
+ String value = attrBuilder.buildEmpty(gen);
+ Assert.assertNull("Attr. not null", value);
+
+ }
+
+ @Test
+ public void withWrongSpConfig() throws AttributeBuilderException, Exception {
+ String value = attrBuilder.build(spConfig, buildAuthData(), gen);
+ Assert.assertNull("Attr. not null", value);
+
+ }
+
+ @Test
+ public void withAttributeValue() throws AttributeBuilderException, Exception {
+ ServiceProviderConfiguration sp = new ServiceProviderConfiguration(spConfigMap, new DummyConfiguration());
+ sp.setRequestedAttributes(Sets.newSet(
+ "aabbccdd",
+ RandomStringUtils.randomAlphanumeric(10),
+ PvpAttributeDefinitions.BIRTHDATE_NAME));
+
+
+ String value = attrBuilder.build(sp, buildAuthData(), gen);
+
+ List<String> elements = KeyValueUtils.getListOfCsvValues(value);
+ assertEquals("wrong number of attributes", sp.getRequestedAttributes().size(), elements.size());
+ sp.getRequestedAttributes().forEach(
+ el -> elements.contains(el));
+
+ }
+
+}
diff --git a/modules/authmodule_id-austria/src/test/java/at/asitplus/eidas/specific/modules/auth/idaustria/test/task/ReceiveAuthnResponseTaskTest.java b/modules/authmodule_id-austria/src/test/java/at/asitplus/eidas/specific/modules/auth/idaustria/test/task/ReceiveAuthnResponseTaskTest.java
index c452fe22..c3be6dad 100644
--- a/modules/authmodule_id-austria/src/test/java/at/asitplus/eidas/specific/modules/auth/idaustria/test/task/ReceiveAuthnResponseTaskTest.java
+++ b/modules/authmodule_id-austria/src/test/java/at/asitplus/eidas/specific/modules/auth/idaustria/test/task/ReceiveAuthnResponseTaskTest.java
@@ -36,7 +36,6 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
-import at.asitplus.eidas.specific.core.MsEidasNodeConstants;
import at.asitplus.eidas.specific.core.config.ServiceProviderConfiguration;
import at.asitplus.eidas.specific.core.test.config.dummy.MsConnectorDummyConfigMap;
import at.asitplus.eidas.specific.modules.auth.idaustria.IdAustriaAuthConstants;
@@ -542,14 +541,14 @@ public class ReceiveAuthnResponseTaskTest {
assertTrue("eidProcess flag", session.isEidProcess());
assertFalse("useMandate flag", session.isMandateUsed());
- checkAttributeInSession(session,PvpAttributeDefinitions.GIVEN_NAME_NAME, "Max");
- checkAttributeInSession(session,PvpAttributeDefinitions.PRINCIPAL_NAME_NAME, "Mustermann");
- checkAttributeInSession(session,PvpAttributeDefinitions.BIRTHDATE_NAME, "1940-01-01");
- checkAttributeInSession(session,PvpAttributeDefinitions.EID_CITIZEN_EIDAS_QAA_LEVEL_NAME, "http://eidas.europa.eu/LoA/high");
- checkAttributeInSession(session,PvpAttributeDefinitions.EID_ISSUING_NATION_NAME, "AT");
+ checkAttributeInSession(session, PvpAttributeDefinitions.GIVEN_NAME_NAME, "Max");
+ checkAttributeInSession(session, PvpAttributeDefinitions.PRINCIPAL_NAME_NAME, "Mustermann");
+ checkAttributeInSession(session, PvpAttributeDefinitions.BIRTHDATE_NAME, "1940-01-01");
+ checkAttributeInSession(session, PvpAttributeDefinitions.EID_CITIZEN_EIDAS_QAA_LEVEL_NAME, "http://eidas.europa.eu/LoA/high");
+ checkAttributeInSession(session, PvpAttributeDefinitions.EID_ISSUING_NATION_NAME, "AT");
//pre-generated eIDAS identifer
- checkAttributeInSession(session, MsEidasNodeConstants.ATTR_EIDAS_PERSONAL_IDENTIFIER, "QVGm48cqcM4UcyhDTNGYmVdrIoY=");
+ checkAttributeInSession(session, PvpAttributeDefinitions.BPK_NAME, "AT+XX:QVGm48cqcM4UcyhDTNGYmVdrIoY=");
}
@@ -587,7 +586,7 @@ public class ReceiveAuthnResponseTaskTest {
checkAttributeInSession(session,PvpAttributeDefinitions.BIRTHDATE_NAME, "1940-01-01");
checkAttributeInSession(session,PvpAttributeDefinitions.EID_ISSUING_NATION_NAME, "AT");
- checkAttributeInSession(session,MsEidasNodeConstants.ATTR_EIDAS_PERSONAL_IDENTIFIER, "QVGm48cqcM4UcyhDTNGYmVdrIoY=");
+ checkAttributeInSession(session,PvpAttributeDefinitions.BPK_NAME, "AT+CC:QVGm48cqcM4UcyhDTNGYmVdrIoY=");
}
@@ -625,7 +624,7 @@ public class ReceiveAuthnResponseTaskTest {
checkAttributeInSession(session,PvpAttributeDefinitions.EID_ISSUING_NATION_NAME, "AT");
//pre-generated eIDAS identifer
- checkAttributeInSession(session,MsEidasNodeConstants.ATTR_EIDAS_PERSONAL_IDENTIFIER, "QVGm48cqcasfasfsafsafdM4UcyhDTNGYmVdrIoY=");
+ checkAttributeInSession(session,PvpAttributeDefinitions.BPK_NAME, "QVGm48cqcasfasfsafsafdM4UcyhDTNGYmVdrIoY=");
}
@@ -663,7 +662,7 @@ public class ReceiveAuthnResponseTaskTest {
checkAttributeInSession(session,PvpAttributeDefinitions.EID_ISSUING_NATION_NAME, "AT");
//pre-generated eIDAS identifer
- checkAttributeInSession(session,MsEidasNodeConstants.ATTR_EIDAS_PERSONAL_IDENTIFIER, "QVGm48cqcasfasfsafsafdM4UcyhDTNGYmVdrIoY=");
+ checkAttributeInSession(session,PvpAttributeDefinitions.BPK_NAME, "AT+AB:QVGm48cqcasfasfsafsafdM4UcyhDTNGYmVdrIoY=");
}
@@ -708,7 +707,7 @@ public class ReceiveAuthnResponseTaskTest {
checkAttributeInSession(session, PvpAttributeDefinitions.MANDATE_LEG_PER_SOURCE_PIN_TYPE_NAME, "urn:publicid:gv.at:baseid+XERSB");
//pre-generated eIDAS identifer
- checkAttributeInSession(session, MsEidasNodeConstants.ATTR_EIDAS_PERSONAL_IDENTIFIER, "QVGm48cqcM4UcyhDTNGYmVdrIoY=");
+ checkAttributeInSession(session, PvpAttributeDefinitions.BPK_NAME, "AT+XX:QVGm48cqcM4UcyhDTNGYmVdrIoY=");
assertNull("find nat. person bpk for mandator", session.getGenericDataFromSession(
PvpAttributeDefinitions.MANDATE_NAT_PER_BPK_NAME, String.class));
@@ -758,8 +757,7 @@ public class ReceiveAuthnResponseTaskTest {
//pre-generated eIDAS identifer
- checkAttributeInSession(session, MsEidasNodeConstants.ATTR_EIDAS_PERSONAL_IDENTIFIER,
- "QVGm48cqcM4UcyhDTNGYmVdrIoY=");
+ checkAttributeInSession(session, PvpAttributeDefinitions.BPK_NAME, "AT+XX:QVGm48cqcM4UcyhDTNGYmVdrIoY=");
}
diff --git a/modules/authmodule_id-austria/src/test/java/at/asitplus/eidas/specific/modules/auth/idaustria/test/task/RequestIdAustriaSystemTaskTest.java b/modules/authmodule_id-austria/src/test/java/at/asitplus/eidas/specific/modules/auth/idaustria/test/task/RequestIdAustriaSystemTaskTest.java
index f6ffc729..1feb684d 100644
--- a/modules/authmodule_id-austria/src/test/java/at/asitplus/eidas/specific/modules/auth/idaustria/test/task/RequestIdAustriaSystemTaskTest.java
+++ b/modules/authmodule_id-austria/src/test/java/at/asitplus/eidas/specific/modules/auth/idaustria/test/task/RequestIdAustriaSystemTaskTest.java
@@ -18,6 +18,7 @@ import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
+import org.mockito.internal.util.collections.Sets;
import org.opensaml.core.xml.config.XMLObjectProviderRegistrySupport;
import org.opensaml.core.xml.schema.XSString;
import org.opensaml.core.xml.util.XMLObjectSupport;
@@ -41,6 +42,7 @@ import at.asitplus.eidas.specific.modules.msproxyservice.protocol.ProxyServicePe
import at.gv.egiz.eaaf.core.api.data.EaafConfigConstants;
import at.gv.egiz.eaaf.core.api.data.EaafConstants;
import at.gv.egiz.eaaf.core.api.data.ExtendedPvpAttributeDefinitions.SpMandateModes;
+import at.gv.egiz.eaaf.core.api.data.PvpAttributeDefinitions;
import at.gv.egiz.eaaf.core.api.gui.IVelocityGuiBuilderConfiguration;
import at.gv.egiz.eaaf.core.api.idp.process.ExecutionContext;
import at.gv.egiz.eaaf.core.api.storage.ITransactionStorage;
@@ -213,7 +215,7 @@ public class RequestIdAustriaSystemTaskTest {
//validate state
final EaafRequestedAttributes reqAttr = validate();
- Assert.assertEquals("#Req Attribute", 4, reqAttr.getAttributes().size());
+ Assert.assertEquals("#Req Attribute", 5, reqAttr.getAttributes().size());
Assert.assertEquals("Wrong req attr.", "urn:eidgvat:attributes.eidas.uniqueId",
reqAttr.getAttributes().get(0).getName());
@@ -246,15 +248,15 @@ public class RequestIdAustriaSystemTaskTest {
((XSString)reqAttr.getAttributes().get(2).getAttributeValues().get(0)).getValue());
Assert.assertEquals("Wrong req attr.", "urn:eidgvat:attributes.ServiceProviderMandateType",
- reqAttr.getAttributes().get(3).getName());
- Assert.assertNotNull("Req. Attr value element", reqAttr.getAttributes().get(3).getAttributeValues());
+ reqAttr.getAttributes().get(4).getName());
+ Assert.assertNotNull("Req. Attr value element", reqAttr.getAttributes().get(4).getAttributeValues());
Assert.assertEquals("#Req. Attr value", 1,
- reqAttr.getAttributes().get(3).getAttributeValues().size());
+ reqAttr.getAttributes().get(4).getAttributeValues().size());
org.springframework.util.Assert.isInstanceOf(XSString.class,
- reqAttr.getAttributes().get(3).getAttributeValues().get(0), "Wrong requested Attributes Value type");
+ reqAttr.getAttributes().get(4).getAttributeValues().get(0), "Wrong requested Attributes Value type");
Assert.assertEquals("Req. Attr. Value",
pendingReq.getServiceProviderConfiguration(ServiceProviderConfiguration.class).getMandateMode().getMode(),
- ((XSString)reqAttr.getAttributes().get(3).getAttributeValues().get(0)).getValue());
+ ((XSString)reqAttr.getAttributes().get(4).getAttributeValues().get(0)).getValue());
}
@@ -275,33 +277,55 @@ public class RequestIdAustriaSystemTaskTest {
LightRequest eidasReq = eidasRequestBuilder.build();
pendingReq.setEidasRequest(eidasReq);
+ oaParam.setRequestedAttributes(Sets.newSet(
+ "aabbccdd",
+ RandomStringUtils.randomAlphanumeric(10),
+ PvpAttributeDefinitions.BIRTHDATE_NAME));
+
//execute test
task.execute(pendingReq, executionContext);
//validate state
final EaafRequestedAttributes reqAttr = validate();
- Assert.assertEquals("#Req Attribute", 6, reqAttr.getAttributes().size());
+ Assert.assertEquals("#Req Attribute", 7, reqAttr.getAttributes().size());
- Assert.assertEquals("Wrong req attr.", "urn:eidgvat:attributes.ServiceProviderFriendlyName",
+
+ Assert.assertEquals("Wrong req attr.", "urn:eidgvat:attributes.RequiredAttributes",
reqAttr.getAttributes().get(3).getName());
- Assert.assertNotNull("Req. Attr value element", reqAttr.getAttributes().get(1).getAttributeValues());
+ Assert.assertNotNull("Req. Attr value element", reqAttr.getAttributes().get(3).getAttributeValues());
Assert.assertEquals("#Req. Attr value", 1,
reqAttr.getAttributes().get(3).getAttributeValues().size());
org.springframework.util.Assert.isInstanceOf(XSString.class,
reqAttr.getAttributes().get(3).getAttributeValues().get(0), "Wrong requested Attributes Value type");
- Assert.assertEquals("Req. Attr. Value", eidasReq.getProviderName(),
+
+ List<String> reqProfiles = KeyValueUtils.getListOfCsvValues(
((XSString)reqAttr.getAttributes().get(3).getAttributeValues().get(0)).getValue());
+ reqProfiles.stream().forEach(
+ el -> assertTrue("missing IDA attribute: " + el, oaParam.getRequestedAttributes().contains(el)));
- Assert.assertEquals("Wrong req attr.", "urn:eidgvat:attributes.ServiceProviderUniqueId",
+
+ Assert.assertEquals("Wrong req attr.", "urn:eidgvat:attributes.ServiceProviderFriendlyName",
reqAttr.getAttributes().get(4).getName());
- Assert.assertNotNull("Req. Attr value element", reqAttr.getAttributes().get(1).getAttributeValues());
+ Assert.assertNotNull("Req. Attr value element", reqAttr.getAttributes().get(4).getAttributeValues());
Assert.assertEquals("#Req. Attr value", 1,
reqAttr.getAttributes().get(4).getAttributeValues().size());
org.springframework.util.Assert.isInstanceOf(XSString.class,
reqAttr.getAttributes().get(4).getAttributeValues().get(0), "Wrong requested Attributes Value type");
- Assert.assertEquals("Req. Attr. Value", eidasReq.getRequesterId(),
+ Assert.assertEquals("Req. Attr. Value", eidasReq.getProviderName(),
((XSString)reqAttr.getAttributes().get(4).getAttributeValues().get(0)).getValue());
+ Assert.assertEquals("Wrong req attr.", "urn:eidgvat:attributes.ServiceProviderUniqueId",
+ reqAttr.getAttributes().get(5).getName());
+ Assert.assertNotNull("Req. Attr value element", reqAttr.getAttributes().get(5).getAttributeValues());
+ Assert.assertEquals("#Req. Attr value", 1,
+ reqAttr.getAttributes().get(5).getAttributeValues().size());
+ org.springframework.util.Assert.isInstanceOf(XSString.class,
+ reqAttr.getAttributes().get(5).getAttributeValues().get(0), "Wrong requested Attributes Value type");
+ Assert.assertEquals("Req. Attr. Value", eidasReq.getRequesterId(),
+ ((XSString)reqAttr.getAttributes().get(5).getAttributeValues().get(0)).getValue());
+
+
+
}
@Test
@@ -330,31 +354,31 @@ public class RequestIdAustriaSystemTaskTest {
//validate state
final EaafRequestedAttributes reqAttr = validate();
- Assert.assertEquals("#Req Attribute", 7, reqAttr.getAttributes().size());
+ Assert.assertEquals("#Req Attribute", 8, reqAttr.getAttributes().size());
Assert.assertEquals("Wrong req attr.", "urn:eidgvat:attributes.ServiceProviderMandateProfiles",
- reqAttr.getAttributes().get(5).getName());
- Assert.assertNotNull("Req. Attr value element", reqAttr.getAttributes().get(1).getAttributeValues());
+ reqAttr.getAttributes().get(6).getName());
+ Assert.assertNotNull("Req. Attr value element", reqAttr.getAttributes().get(6).getAttributeValues());
Assert.assertEquals("#Req. Attr value", 1,
- reqAttr.getAttributes().get(5).getAttributeValues().size());
+ reqAttr.getAttributes().get(6).getAttributeValues().size());
org.springframework.util.Assert.isInstanceOf(XSString.class,
- reqAttr.getAttributes().get(5).getAttributeValues().get(0), "Wrong requested Attributes Value type");
+ reqAttr.getAttributes().get(6).getAttributeValues().get(0), "Wrong requested Attributes Value type");
List<String> reqProfiles = KeyValueUtils.getListOfCsvValues(
- ((XSString)reqAttr.getAttributes().get(5).getAttributeValues().get(0)).getValue());
+ ((XSString)reqAttr.getAttributes().get(6).getAttributeValues().get(0)).getValue());
reqProfiles.stream().forEach(el -> assertTrue("missing profile: " + el, mandateProfiles.contains(el)));
Assert.assertEquals("Wrong req attr.", "urn:eidgvat:attributes.ServiceProviderMandateType",
- reqAttr.getAttributes().get(6).getName());
- Assert.assertNotNull("Req. Attr value element", reqAttr.getAttributes().get(6).getAttributeValues());
+ reqAttr.getAttributes().get(7).getName());
+ Assert.assertNotNull("Req. Attr value element", reqAttr.getAttributes().get(7).getAttributeValues());
Assert.assertEquals("#Req. Attr value", 1,
- reqAttr.getAttributes().get(6).getAttributeValues().size());
+ reqAttr.getAttributes().get(7).getAttributeValues().size());
org.springframework.util.Assert.isInstanceOf(XSString.class,
- reqAttr.getAttributes().get(6).getAttributeValues().get(0), "Wrong requested Attributes Value type");
+ reqAttr.getAttributes().get(7).getAttributeValues().get(0), "Wrong requested Attributes Value type");
Assert.assertEquals("Req. Attr. Value",
SpMandateModes.LEGAL_FORCE.getMode(),
- ((XSString)reqAttr.getAttributes().get(6).getAttributeValues().get(0)).getValue());
+ ((XSString)reqAttr.getAttributes().get(7).getAttributeValues().get(0)).getValue());
}