aboutsummaryrefslogtreecommitdiff
path: root/connector/src/test/java
diff options
context:
space:
mode:
Diffstat (limited to 'connector/src/test/java')
-rw-r--r--connector/src/test/java/at/asitplus/eidas/specific/connector/test/attributes/AuthBlockAttributeBuilderTest.java97
-rw-r--r--connector/src/test/java/at/asitplus/eidas/specific/connector/test/attributes/EidasBindAttributeBuilderTest.java92
2 files changed, 189 insertions, 0 deletions
diff --git a/connector/src/test/java/at/asitplus/eidas/specific/connector/test/attributes/AuthBlockAttributeBuilderTest.java b/connector/src/test/java/at/asitplus/eidas/specific/connector/test/attributes/AuthBlockAttributeBuilderTest.java
new file mode 100644
index 00000000..50376e08
--- /dev/null
+++ b/connector/src/test/java/at/asitplus/eidas/specific/connector/test/attributes/AuthBlockAttributeBuilderTest.java
@@ -0,0 +1,97 @@
+package at.asitplus.eidas.specific.connector.test.attributes;
+
+import at.asitplus.eidas.specific.connector.attributes.AuthBlockAttributeBuilder;
+import at.gv.egiz.eaaf.core.api.idp.IAttributeBuilder;
+import at.gv.egiz.eaaf.core.api.idp.IAuthData;
+import at.gv.egiz.eaaf.core.exceptions.UnavailableAttributeException;
+import at.gv.egiz.eaaf.core.impl.idp.AuthenticationData;
+import at.gv.egiz.eaaf.core.impl.idp.auth.attributes.AbstractAttributeBuilderTest;
+import lombok.extern.slf4j.Slf4j;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.TestName;
+import org.junit.runner.RunWith;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+
+import static at.asitplus.eidas.specific.connector.attributes.AuthBlockAttributeBuilder.EID_AUTHBLOCK_SIGNED_NAME;
+import static at.asitplus.eidas.specific.modules.auth.eidas.v2.Constants.SZR_AUTHBLOCK;
+
+@Slf4j
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration("/SpringTest-context_eaaf_core.xml")
+public class AuthBlockAttributeBuilderTest extends AbstractAttributeBuilderTest {
+
+ private final String JSW =
+ "eyJhbGciOiJQUzI1NiIsIng1dCNTMjU2IjoiTjBDZUJRdzlMX1BleEt6SlhVM2w2dkF1aExGb3hkWFlIUjNSX01ubTZnRSJ9.ImF2YWFz" +
+ "YmF2Ig.dpzCcHFlISXyKEZaXgvRj0ja1cenfMuy0VKwK_rmHZLkUCb58V4X5balpQduDTyRfTyFE0zmBjm8_cmDVNOYTIG4NsEtvY" +
+ "qW4ee9JH-VpkU0w5-7HTH81R3JOd9g7XaHGPXYyUuqceZQRmkl1Vw4HSsnIAT3bb0Di0us6zmFkOPmRtbXQAym_ygGFwTVGLskUTm" +
+ "epCxmDQC7OJoIV9oqDavLySP7Ram4NHfi043uF_DmBf6csTjmQu3g2vKJWwlkD8RXDzqksozO8fLDFyVWjA8G1IcvnuHDW1nTTkuG" +
+ "_fBIU6yBZ7kQe9vtjqKiGhGa1zD-F_Lem2zsY7d7dVUvyQ";
+ private final IAttributeBuilder attrBuilde = new AuthBlockAttributeBuilder();
+
+ @Rule
+ public TestName mTestName = new TestName();
+
+ @Before
+ public void init() {
+ log.info("setting up");
+ }
+
+ @Test
+ public void okTest() {
+ log.info("starting: " + mTestName);
+ try {
+ final IAuthData authData = buildAuthData();
+ ((AuthenticationData) authData).setGenericData(SZR_AUTHBLOCK, JSW);
+
+ final String value = attrBuilde.build(spConfig, authData, gen);
+
+ Assert.assertEquals("Authblock build wrong", JSW, value);
+
+ } catch (final Exception e) {
+ Assert.assertNull("Attr. builder has an exception", e);
+ }
+ }
+
+
+ @Test
+ public void nullTest() {
+ log.info("starting: " + mTestName);
+ try {
+ final IAuthData authData = buildAuthData();
+ ((AuthenticationData) authData).setGenericData(SZR_AUTHBLOCK, null);
+
+ final String value = attrBuilde.build(spConfig, authData, gen);
+ Assert.fail("Attr. Builder provide no 'UnavailableAttributeException'");
+
+ } catch (final Exception e) {
+ Assert.assertTrue("Attr. builder provide wrong exception",
+ e instanceof UnavailableAttributeException);
+ Assert.assertEquals("Attr. name in exception does NOT match",
+ EID_AUTHBLOCK_SIGNED_NAME,
+ ((UnavailableAttributeException) e).getAttributeName());
+ }
+ }
+
+ @Test
+ public void emptyTest() {
+ log.info("starting: " + mTestName);
+ try {
+ final IAuthData authData = buildAuthData();
+ ((AuthenticationData) authData).setGenericData(SZR_AUTHBLOCK, "");
+
+ final String value = attrBuilde.build(spConfig, authData, gen);
+ Assert.fail("Attr. Builder provide no 'UnavailableAttributeException'");
+
+ } catch (final Exception e) {
+ Assert.assertTrue("Attr. builder provide wrong exception",
+ e instanceof UnavailableAttributeException);
+ Assert.assertEquals("Attr. name in exception does NOT match",
+ EID_AUTHBLOCK_SIGNED_NAME,
+ ((UnavailableAttributeException) e).getAttributeName()); }
+ }
+}
diff --git a/connector/src/test/java/at/asitplus/eidas/specific/connector/test/attributes/EidasBindAttributeBuilderTest.java b/connector/src/test/java/at/asitplus/eidas/specific/connector/test/attributes/EidasBindAttributeBuilderTest.java
new file mode 100644
index 00000000..254efb59
--- /dev/null
+++ b/connector/src/test/java/at/asitplus/eidas/specific/connector/test/attributes/EidasBindAttributeBuilderTest.java
@@ -0,0 +1,92 @@
+package at.asitplus.eidas.specific.connector.test.attributes;
+
+import at.asitplus.eidas.specific.connector.attributes.EidasBindAttributeBuilder;
+import at.gv.egiz.eaaf.core.api.data.ExtendedPvpAttributeDefinitions;
+import at.gv.egiz.eaaf.core.api.idp.IAttributeBuilder;
+import at.gv.egiz.eaaf.core.api.idp.IAuthData;
+import at.gv.egiz.eaaf.core.exceptions.UnavailableAttributeException;
+import at.gv.egiz.eaaf.core.impl.idp.AuthenticationData;
+import at.gv.egiz.eaaf.core.impl.idp.auth.attributes.AbstractAttributeBuilderTest;
+import lombok.extern.slf4j.Slf4j;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.TestName;
+import org.junit.runner.RunWith;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+import static at.asitplus.eidas.specific.modules.auth.eidas.v2.Constants.EIDAS_BIND;
+
+
+@Slf4j
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration("/SpringTest-context_eaaf_core.xml")
+public class EidasBindAttributeBuilderTest extends AbstractAttributeBuilderTest {
+
+ private final IAttributeBuilder attrBuilde = new EidasBindAttributeBuilder();
+
+ @Rule
+ public TestName mTestName = new TestName();
+
+ @Before
+ public void init() {
+ log.info("setting up");
+ }
+
+ @Test
+ public void okTest() {
+ log.info("starting: " + mTestName);
+ try {
+ final IAuthData authData = buildAuthData();
+ ((AuthenticationData) authData).setGenericData(EIDAS_BIND, "vuG8w29GT0");
+
+ final String value = attrBuilde.build(spConfig, authData, gen);
+
+ Assert.assertEquals("eDIAS bind build wrong", "vuG8w29GT0", value);
+
+ } catch (final Exception e) {
+ Assert.assertNull("Attr. builder has an exception", e);
+ }
+ }
+
+ @Test
+ public void nullTest() {
+ log.info("starting: " + mTestName);
+ try {
+ final IAuthData authData = buildAuthData();
+ ((AuthenticationData) authData).setGenericData(EIDAS_BIND, null);
+
+ final String value = attrBuilde.build(spConfig, authData, gen);
+ Assert.fail("Attr. Builder provide no 'UnavailableAttributeException'");
+
+ } catch (final Exception e) {
+ Assert.assertTrue("Attr. builder provide wrong exception",
+ e instanceof UnavailableAttributeException);
+ Assert.assertEquals("Attr. name in exception does NOT match",
+ ExtendedPvpAttributeDefinitions.EID_EIDBIND_NAME,
+ ((UnavailableAttributeException) e).getAttributeName());
+ }
+ }
+
+ @Test
+ public void emptyTest() {
+ log.info("starting: " + mTestName);
+ try {
+ final IAuthData authData = buildAuthData();
+ ((AuthenticationData) authData).setGenericData(EIDAS_BIND, "");
+
+ final String value = attrBuilde.build(spConfig, authData, gen);
+ Assert.fail("Attr. Builder provide no 'UnavailableAttributeException'");
+
+ } catch (final Exception e) {
+ Assert.assertTrue("Attr. builder provide wrong exception",
+ e instanceof UnavailableAttributeException);
+ Assert.assertEquals("Attr. name in exception does NOT match",
+ ExtendedPvpAttributeDefinitions.EID_EIDBIND_NAME,
+ ((UnavailableAttributeException) e).getAttributeName()); }
+ }
+
+
+}