aboutsummaryrefslogtreecommitdiff
path: root/id/server/modules/moa-id-module-ehvd_integration/src/test/java/at/gv/egovernment/moa/id/auth/modules/ehvd/test/utils/AuthenticationRoleFactoryTest.java
diff options
context:
space:
mode:
Diffstat (limited to 'id/server/modules/moa-id-module-ehvd_integration/src/test/java/at/gv/egovernment/moa/id/auth/modules/ehvd/test/utils/AuthenticationRoleFactoryTest.java')
-rw-r--r--id/server/modules/moa-id-module-ehvd_integration/src/test/java/at/gv/egovernment/moa/id/auth/modules/ehvd/test/utils/AuthenticationRoleFactoryTest.java65
1 files changed, 65 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/utils/AuthenticationRoleFactoryTest.java b/id/server/modules/moa-id-module-ehvd_integration/src/test/java/at/gv/egovernment/moa/id/auth/modules/ehvd/test/utils/AuthenticationRoleFactoryTest.java
new file mode 100644
index 000000000..6d39b926e
--- /dev/null
+++ b/id/server/modules/moa-id-module-ehvd_integration/src/test/java/at/gv/egovernment/moa/id/auth/modules/ehvd/test/utils/AuthenticationRoleFactoryTest.java
@@ -0,0 +1,65 @@
+package at.gv.egovernment.moa.id.auth.modules.ehvd.test.utils;
+
+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.egovernment.moa.id.data.AuthenticationRole;
+import at.gv.egovernment.moa.id.data.AuthenticationRoleFactory;
+
+@RunWith(BlockJUnit4ClassRunner.class)
+public class AuthenticationRoleFactoryTest {
+
+ @Test
+ public void simpleRole() {
+ String role = RandomStringUtils.randomAlphabetic(5);
+
+ AuthenticationRole toCheck = AuthenticationRoleFactory.buildFormPVPole(role);
+
+ assertEquals("wrong role name", role, toCheck.getRoleName());
+ assertEquals("wrong raw role", role, toCheck.getRawRoleString());
+ assertNull("wrong role attr", toCheck.getParams());
+
+ }
+
+ @Test
+ public void complexeRoleEmptyParams() {
+ String role = RandomStringUtils.randomAlphabetic(5);
+ String fullRole = role + "()";
+
+ AuthenticationRole toCheck = AuthenticationRoleFactory.buildFormPVPole(fullRole);
+
+ assertEquals("wrong role name", role, toCheck.getRoleName());
+ assertEquals("wrong raw role", fullRole, toCheck.getRawRoleString());
+ assertNull("wrong role attr", toCheck.getParams());
+
+ }
+
+ @Test
+ public void complexeRoleWithParams() {
+ String p1 = RandomStringUtils.randomAlphabetic(5);
+ String v1 = RandomStringUtils.randomAlphabetic(5);
+ String p2 = RandomStringUtils.randomAlphabetic(5);
+ String v2 = RandomStringUtils.randomAlphabetic(5);
+
+ String role = RandomStringUtils.randomAlphabetic(5);
+ String fullRole = role + "(\""
+ + p1 + "\"=\"" + v1 + "\","
+ + p2 + "\"=\"" + v2 + "\""
+ +")";
+
+ AuthenticationRole toCheck = AuthenticationRoleFactory.buildFormPVPole(fullRole);
+
+ assertEquals("wrong role name", role, toCheck.getRoleName());
+ assertEquals("wrong raw role", fullRole, toCheck.getRawRoleString());
+ assertNotNull("wrong role attr", toCheck.getParams());
+ assertEquals("wrong param size", 2, toCheck.getParams().size());
+
+ }
+
+}