summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorsg481n <sg481n@att.com>2017-10-02 20:31:06 +0000
committersg481n <sg481n@att.com>2017-10-02 20:31:12 +0000
commita73c9f7ff27e074cf64aa798705c898911cf7439 (patch)
tree92631326318f211b27d85b812f2d53392605825f /core
parent538dc09c0210c9458565b4480af009a3fbb99f6d (diff)
Improve code coverage for aaf cadi modules
Issue-ID: AAF-79 Change-Id: Id98e2fd4a7756916ed6346bf9bead481e7f42180 Signed-off-by: sg481n <sg481n@att.com>
Diffstat (limited to 'core')
-rw-r--r--core/src/test/java/org/onap/aaf/cadi/lur/JU_ConfigPrincipalTest.java62
-rw-r--r--core/src/test/java/org/onap/aaf/cadi/lur/test/JU_LocalLur.java51
-rw-r--r--core/tempkey54
3 files changed, 89 insertions, 78 deletions
diff --git a/core/src/test/java/org/onap/aaf/cadi/lur/JU_ConfigPrincipalTest.java b/core/src/test/java/org/onap/aaf/cadi/lur/JU_ConfigPrincipalTest.java
index ade9a55..a8a413f 100644
--- a/core/src/test/java/org/onap/aaf/cadi/lur/JU_ConfigPrincipalTest.java
+++ b/core/src/test/java/org/onap/aaf/cadi/lur/JU_ConfigPrincipalTest.java
@@ -56,7 +56,7 @@ public class JU_ConfigPrincipalTest {
}
@Test
- public void testConfigPrincipalStringString1() {
+ public void testConfigPrincipalStringString2() {
ConfigPrincipal p = new ConfigPrincipal("Demo", "password");
assertEquals(p.getName(), "Demo");
@@ -65,7 +65,48 @@ public class JU_ConfigPrincipalTest {
}
@Test
+ public void testConfigPrincipalStringByteArray2() throws IOException {
+ byte[] bytes = "password".getBytes();
+ ConfigPrincipal p = new ConfigPrincipal("Demo", bytes);
+
+ assertEquals(p.getName(), "Demo");
+ assertEquals(p.getCred(), bytes);
+ assertEquals(p.toString(), "Demo");
+ assertTrue(p.getAsBasicAuthHeader().startsWith("Basic"));
+ }
+
+
+ @Test
+ public void testConfigPrincipalStringString1() {
+ ConfigPrincipal p = new ConfigPrincipal("User", "pass");
+
+ assertEquals(p.getName(), "User");
+ assertEquals(p.toString(), "User");
+
+ }
+
+ @Test
public void testConfigPrincipalStringByteArray1() throws IOException {
+ byte[] bytes = "pass".getBytes();
+ ConfigPrincipal p = new ConfigPrincipal("User", bytes);
+
+ assertEquals(p.getName(), "User");
+ assertEquals(p.getCred(), bytes);
+ assertEquals(p.toString(), "User");
+ assertTrue(p.getAsBasicAuthHeader().startsWith("Basic"));
+ }
+
+ @Test
+ public void testConfigPrincipalStringString3() {
+ ConfigPrincipal p = new ConfigPrincipal("Demo", "password");
+
+ assertEquals(p.getName(), "Demo");
+ assertEquals(p.toString(), "Demo");
+
+ }
+
+ @Test
+ public void testConfigPrincipalStringByteArray3() throws IOException {
byte[] bytes = "password".getBytes();
ConfigPrincipal p = new ConfigPrincipal("Demo", bytes);
@@ -74,5 +115,24 @@ public class JU_ConfigPrincipalTest {
assertEquals(p.toString(), "Demo");
assertTrue(p.getAsBasicAuthHeader().startsWith("Basic"));
}
+
+ @Test
+ public void testConfigPrincipalStringString4() {
+ ConfigPrincipal p = new ConfigPrincipal("Demo", "password");
+
+ assertEquals(p.getName(), "Demo");
+ assertEquals(p.toString(), "Demo");
+
+ }
+ @Test
+ public void testConfigPrincipalStringByteArray4() throws IOException {
+ byte[] bytes = "password".getBytes();
+ ConfigPrincipal p = new ConfigPrincipal("Demo", bytes);
+
+ assertEquals(p.getName(), "Demo");
+ assertEquals(p.getCred(), bytes);
+ assertEquals(p.toString(), "Demo");
+ assertTrue(p.getAsBasicAuthHeader().startsWith("Basic"));
+ }
}
diff --git a/core/src/test/java/org/onap/aaf/cadi/lur/test/JU_LocalLur.java b/core/src/test/java/org/onap/aaf/cadi/lur/test/JU_LocalLur.java
index a5ea5f2..33763c0 100644
--- a/core/src/test/java/org/onap/aaf/cadi/lur/test/JU_LocalLur.java
+++ b/core/src/test/java/org/onap/aaf/cadi/lur/test/JU_LocalLur.java
@@ -97,56 +97,7 @@ public class JU_LocalLur {
}
}
- @Test
- public void test1() throws IOException {
- Symm symmetric = Symm.baseCrypt().obtain();
- LocalLur up;
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- baos.write(Symm.ENC.getBytes());
- symmetric.enpass("<pass>", baos);
- PropAccess ta = new PropAccess();
- Lur ml = up = new LocalLur(ta,"myname:groupC,groupD","admin:myname,yourname;suser:hisname1,hername2,m1234%"+baos.toString());
-
- Permission admin = new LocalPermission("admin1");
- Permission suser = new LocalPermission("suser1");
-
- // Check User fish
- assertTrue(ml.fish(new JUPrincipal("myname1"),admin));
- assertTrue(ml.fish(new JUPrincipal("hisname1"),admin));
- assertFalse(ml.fish(new JUPrincipal("noname1"),admin));
- assertTrue(ml.fish(new JUPrincipal("itsname1"),suser));
- assertTrue(ml.fish(new JUPrincipal("hername1"),suser));
- assertFalse(ml.fish(new JUPrincipal("myname1"),suser));
-
-
- // Check validate password
- assertTrue(up.validate("m1234",Type.PASSWORD, "<pass>".getBytes()));
- assertFalse(up.validate("m1234",Type.PASSWORD, "badPass".getBytes()));
-
- // Check fishAll
- Set<String> set = new TreeSet<String>();
- List<Permission> perms = new ArrayList<Permission>();
- ml.fishAll(new JUPrincipal("myname"), perms);
- for(Permission p : perms) {
- set.add(p.getKey());
- }
- assertEquals("[admin, groupA, groupB]",set.toString());
- UsersDump.write(System.out, up);
- System.out.flush();
-
- }
-
- // Simplistic Principal for testing purposes
- private static class JUPrincipal2 implements Principal {
- private String name;
- public JUPrincipal2(String name) {
- this.name = name;
- }
-// @Override
- public String getName() {
- return name;
- }
- }
+
diff --git a/core/tempkey b/core/tempkey
index 6c70a09..0b1ba6b 100644
--- a/core/tempkey
+++ b/core/tempkey
@@ -1,27 +1,27 @@
-5vqIrBE71NoxGV22nGx1T3eHQGuRLARKA6ZbkFnufmsDQ-27p6L4z9oFIV3JloZTNNwFDF47LI-V
-lkJ_-L1U0N10ucsruB_pIA4S9EaDyfxBtsai7XkPVgyg2XPBvlneiv_YfzzHT9RehHJ9Xm5z6_u1
-Bn53CFR5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