summaryrefslogtreecommitdiff
path: root/eaaf_core/src/test
diff options
context:
space:
mode:
authorThomas <>2021-04-19 18:58:31 +0200
committerThomas <>2021-04-19 18:58:31 +0200
commit3cd52ab38e4d57b6f056dbf47897d80f419522df (patch)
tree9813d26b85c950e01a180b2e8240ad3e9dd62ff8 /eaaf_core/src/test
parent9e072b7105c4353ea4a193e03efd00f2f63d824c (diff)
downloadEAAF-Components-3cd52ab38e4d57b6f056dbf47897d80f419522df.tar.gz
EAAF-Components-3cd52ab38e4d57b6f056dbf47897d80f419522df.tar.bz2
EAAF-Components-3cd52ab38e4d57b6f056dbf47897d80f419522df.zip
refactor DateOfBirth in IAuthData and all implementations because DateOfBirth from SZR has not be a valid Date object
Diffstat (limited to 'eaaf_core/src/test')
-rw-r--r--eaaf_core/src/test/java/at/gv/egiz/eaaf/core/impl/idp/auth/AuthenticationDataBuilderTest.java2
-rw-r--r--eaaf_core/src/test/java/at/gv/egiz/eaaf/core/impl/idp/auth/attributes/BirthdayAttrBuilderTest.java2
-rw-r--r--eaaf_core/src/test/java/at/gv/egiz/eaaf/core/impl/idp/auth/data/AuthenticationDataTest.java85
3 files changed, 87 insertions, 2 deletions
diff --git a/eaaf_core/src/test/java/at/gv/egiz/eaaf/core/impl/idp/auth/AuthenticationDataBuilderTest.java b/eaaf_core/src/test/java/at/gv/egiz/eaaf/core/impl/idp/auth/AuthenticationDataBuilderTest.java
index 33bd1010..19054634 100644
--- a/eaaf_core/src/test/java/at/gv/egiz/eaaf/core/impl/idp/auth/AuthenticationDataBuilderTest.java
+++ b/eaaf_core/src/test/java/at/gv/egiz/eaaf/core/impl/idp/auth/AuthenticationDataBuilderTest.java
@@ -307,7 +307,7 @@ public class AuthenticationDataBuilderTest {
throw new Exception("GivenName wrong");
}
- if (!authData.getFormatedDateOfBirth().equals("1973-06-04")) {
+ if (!authData.getDateOfBirth().equals("1973-06-04")) {
throw new Exception("DateOfBirth wrong");
}
diff --git a/eaaf_core/src/test/java/at/gv/egiz/eaaf/core/impl/idp/auth/attributes/BirthdayAttrBuilderTest.java b/eaaf_core/src/test/java/at/gv/egiz/eaaf/core/impl/idp/auth/attributes/BirthdayAttrBuilderTest.java
index 21cf71a9..f155b3b4 100644
--- a/eaaf_core/src/test/java/at/gv/egiz/eaaf/core/impl/idp/auth/attributes/BirthdayAttrBuilderTest.java
+++ b/eaaf_core/src/test/java/at/gv/egiz/eaaf/core/impl/idp/auth/attributes/BirthdayAttrBuilderTest.java
@@ -29,7 +29,7 @@ public class BirthdayAttrBuilderTest extends AbstractAttributeBuilderTest {
final DateFormat format =
new SimpleDateFormat(PvpAttributeDefinitions.BIRTHDATE_FORMAT_PATTERN);
Assert.assertEquals("Birthday does NOT match", authData.getDateOfBirth(),
- format.parse(value));
+ value);
} catch (final Exception e) {
Assert.assertTrue("Attr. builder has an exception", e == null);
diff --git a/eaaf_core/src/test/java/at/gv/egiz/eaaf/core/impl/idp/auth/data/AuthenticationDataTest.java b/eaaf_core/src/test/java/at/gv/egiz/eaaf/core/impl/idp/auth/data/AuthenticationDataTest.java
new file mode 100644
index 00000000..9d99b158
--- /dev/null
+++ b/eaaf_core/src/test/java/at/gv/egiz/eaaf/core/impl/idp/auth/data/AuthenticationDataTest.java
@@ -0,0 +1,85 @@
+package at.gv.egiz.eaaf.core.impl.idp.auth.data;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+
+import org.apache.commons.lang3.RandomStringUtils;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.BlockJUnit4ClassRunner;
+
+import at.gv.egiz.eaaf.core.impl.idp.AuthenticationData;
+
+@RunWith(BlockJUnit4ClassRunner.class)
+public class AuthenticationDataTest {
+
+ @Test
+ public void formatedDateButNotSet() {
+ AuthenticationData authData = new AuthenticationData();
+ assertNull("formatedDateOfBirth", authData.getDateOfBirthFormated("dd/MM/yyy"));
+
+ }
+
+ @Test
+ public void formatedDateButInvalidPattern() {
+ AuthenticationData authData = new AuthenticationData();
+ authData.setDateOfBirth("1940-01-01");
+ assertNull("formatedDateOfBirth", authData.getDateOfBirthFormated("aa-bb-cccc"));
+
+ }
+
+ @Test
+ public void validDateStatic() {
+ AuthenticationData authData = new AuthenticationData();
+
+ String date = "1940-01-01";
+ authData.setDateOfBirth(date);
+
+ assertNotNull("birthday", authData.getDateOfBirth());
+ assertEquals("birthday attribute", date,
+ authData.getDateOfBirth());
+ assertEquals("birthday attribute", "01/01/1940",
+ authData.getDateOfBirthFormated("dd/MM/yyy"));
+
+ }
+
+
+ @Test
+ public void validButNotUsal() {
+ AuthenticationData authData = new AuthenticationData();
+ authData.setDateOfBirth("1970-00-00");
+
+ assertNotNull("birthday", authData.getDateOfBirth());
+ assertEquals("birthday attribute", "1970-00-00",
+ authData.getDateOfBirth());
+ assertNull("formatedDateOfBirth", authData.getDateOfBirthFormated("dd/MM/yyy"));
+
+ }
+
+ @Test
+ public void invalidDate() {
+ AuthenticationData authData = new AuthenticationData();
+ authData.setDateOfBirth("1970/00/00");
+
+ assertNull("birthday", authData.getDateOfBirth());
+ assertNull("formatedDateOfBirth", authData.getDateOfBirthFormated("dd/MM/yyy"));
+
+ }
+
+
+ @Test
+ public void validDateRandom() {
+ AuthenticationData authData = new AuthenticationData();
+
+ String date = RandomStringUtils.randomNumeric(4) + "-" + RandomStringUtils.randomNumeric(2)
+ + "-" + RandomStringUtils.randomNumeric(2);
+ authData.setDateOfBirth(date);
+
+ assertNotNull("birthday", authData.getDateOfBirth());
+ assertEquals("birthday attribute", date,
+ authData.getDateOfBirth());
+
+ }
+
+}