summaryrefslogtreecommitdiffstats
path: root/cadi
diff options
context:
space:
mode:
authorInstrumental <jonathan.gathman@att.com>2018-05-08 14:33:18 -0500
committerInstrumental <jonathan.gathman@att.com>2018-05-09 06:05:32 -0500
commitde038d3a92e1f13fac72ca53b52676fe223556a7 (patch)
tree8676a1d3f1168dd5432297fb492016112ca2866c /cadi
parent34f6446e97199cb5aaefd1369d9faaf297a9b6bf (diff)
Check Perm Instance ending in colon
Issue-ID: AAF-269 Change-Id: I5422c0f119a53284ddc25eb7b99a8a6b09d3dd39 Signed-off-by: Instrumental <jonathan.gathman@att.com> Fix broken JUnits Issue-ID: AAF-270 Change-Id: I91e5d24b0e0610b10dcd12e90813e9ea00af1812 Signed-off-by: Instrumental <jonathan.gathman@att.com>
Diffstat (limited to 'cadi')
-rw-r--r--cadi/aaf/src/main/java/org/onap/aaf/cadi/cm/PlaceArtifactInKeystore.java5
-rw-r--r--cadi/aaf/src/test/java/org/onap/aaf/cadi/cm/test/JU_ArtifactDir.java20
-rw-r--r--cadi/aaf/src/test/java/org/onap/aaf/cadi/cm/test/JU_PlaceArtifactInKeystore.java7
-rw-r--r--cadi/core/src/test/java/org/onap/aaf/cadi/lur/test/JU_LocalLur.java16
-rw-r--r--cadi/core/src/test/resources/output_key1
-rw-r--r--cadi/core/test/output_key27
6 files changed, 33 insertions, 43 deletions
diff --git a/cadi/aaf/src/main/java/org/onap/aaf/cadi/cm/PlaceArtifactInKeystore.java b/cadi/aaf/src/main/java/org/onap/aaf/cadi/cm/PlaceArtifactInKeystore.java
index 9360e02f..2b498d4f 100644
--- a/cadi/aaf/src/main/java/org/onap/aaf/cadi/cm/PlaceArtifactInKeystore.java
+++ b/cadi/aaf/src/main/java/org/onap/aaf/cadi/cm/PlaceArtifactInKeystore.java
@@ -125,17 +125,16 @@ public class PlaceArtifactInKeystore extends ArtifactDir {
char[] truststorePassArray = trustStorePass.toCharArray();
jks.load(null,truststorePassArray); // load in
- // Add Trusted Certificates
+ // Add Trusted Certificates, but PKCS12 doesn't support
for(int i=0; i<trustCAs.length;++i) {
jks.setCertificateEntry("ca_" + arti.getCa() + '_' + i, trustCAs[i]);
}
// Write out
write(fks,Chmod.to644,jks,truststorePassArray);
-
+ return true;
} catch (Exception e) {
throw new CadiException(e);
}
- return false;
}
}
diff --git a/cadi/aaf/src/test/java/org/onap/aaf/cadi/cm/test/JU_ArtifactDir.java b/cadi/aaf/src/test/java/org/onap/aaf/cadi/cm/test/JU_ArtifactDir.java
index 855c26f3..dbddd57a 100644
--- a/cadi/aaf/src/test/java/org/onap/aaf/cadi/cm/test/JU_ArtifactDir.java
+++ b/cadi/aaf/src/test/java/org/onap/aaf/cadi/cm/test/JU_ArtifactDir.java
@@ -21,9 +21,11 @@
package org.onap.aaf.cadi.cm.test;
-import static org.junit.Assert.*;
-import static org.hamcrest.CoreMatchers.*;
-import static org.mockito.Mockito.*;
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+import static org.mockito.Mockito.when;
import java.io.File;
import java.io.IOException;
@@ -34,9 +36,11 @@ import java.security.cert.CertificateException;
import java.util.ArrayList;
import java.util.List;
-import org.junit.*;
-import org.mockito.*;
-
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
import org.onap.aaf.cadi.CadiException;
import org.onap.aaf.cadi.cm.ArtifactDir;
import org.onap.aaf.cadi.util.Chmod;
@@ -125,12 +129,12 @@ public class JU_ArtifactDir {
}
- @Test(expected = CadiException.class)
+ @Test
public void throwsTest() throws CadiException {
ArtifactDirStud artiDir = new ArtifactDirStud();
when(artiMock.getDir()).thenReturn(dirName);
when(artiMock.getNs()).thenReturn(nsName);
- artiDir.place(transMock, certInfoMock, artiMock, "machine");
+ assertTrue(artiDir.place(transMock, certInfoMock, artiMock, "machine"));
}
private class ArtifactDirStud extends ArtifactDir {
diff --git a/cadi/aaf/src/test/java/org/onap/aaf/cadi/cm/test/JU_PlaceArtifactInKeystore.java b/cadi/aaf/src/test/java/org/onap/aaf/cadi/cm/test/JU_PlaceArtifactInKeystore.java
index 02054cbf..d146f631 100644
--- a/cadi/aaf/src/test/java/org/onap/aaf/cadi/cm/test/JU_PlaceArtifactInKeystore.java
+++ b/cadi/aaf/src/test/java/org/onap/aaf/cadi/cm/test/JU_PlaceArtifactInKeystore.java
@@ -53,6 +53,7 @@ public class JU_PlaceArtifactInKeystore {
@Mock private CertInfo certInfoMock;
@Mock private Artifact artiMock;
+ private static final String caName = "onap";
private static final String dirName = "src/test/resources/artifacts";
private static final String nsName = "org.onap.test";
private static final String mechID = "m12345";
@@ -77,6 +78,7 @@ public class JU_PlaceArtifactInKeystore {
when(certInfoMock.getChallenge()).thenReturn(luggagePassword);
when(certInfoMock.getCerts()).thenReturn(certs);
+ when(artiMock.getCa()).thenReturn(caName);
when(artiMock.getDir()).thenReturn(dirName);
when(artiMock.getNs()).thenReturn(nsName);
when(artiMock.getMechid()).thenReturn(mechID);
@@ -94,12 +96,13 @@ public class JU_PlaceArtifactInKeystore {
@Test
public void test() throws CadiException {
- PlaceArtifactInKeystore placer = new PlaceArtifactInKeystore("pkcs12");
+ // Note: PKCS12 can't be tested in JDK 7 and earlier. Can't handle Trusting Certificates.
+ PlaceArtifactInKeystore placer = new PlaceArtifactInKeystore("jks");
certs.add(x509String);
certs.add(x509Chain);
assertThat(placer.place(transMock, certInfoMock, artiMock, "machine"), is(true));
- for (String ext : new String[] {"chal", "keyfile", "pkcs12", "props", "trust.pkcs12"}) {
+ for (String ext : new String[] {"chal", "keyfile", "jks", "props", "trust.jks"}) {
assertThat(new File(dirName + '/' + nsName + '.' + ext).exists(), is(true));
}
diff --git a/cadi/core/src/test/java/org/onap/aaf/cadi/lur/test/JU_LocalLur.java b/cadi/core/src/test/java/org/onap/aaf/cadi/lur/test/JU_LocalLur.java
index fd8e3575..50933f4e 100644
--- a/cadi/core/src/test/java/org/onap/aaf/cadi/lur/test/JU_LocalLur.java
+++ b/cadi/core/src/test/java/org/onap/aaf/cadi/lur/test/JU_LocalLur.java
@@ -47,12 +47,24 @@ public class JU_LocalLur {
@Test
public void test() throws IOException {
- Symm symmetric = Symm.baseCrypt().obtain();
+ final Symm symmetric = Symm.baseCrypt().obtain();
LocalLur up;
ByteArrayOutputStream baos = new ByteArrayOutputStream();
baos.write(Symm.ENC.getBytes());
symmetric.enpass("<pass>", baos);
- PropAccess ta = new PropAccess();
+ PropAccess ta = new PropAccess() {
+ @Override
+ public String decrypt(String encrypted, boolean anytext) throws IOException {
+ return symmetric.depass(encrypted);
+ }
+
+ @Override
+ public String encrypt(String unencrypted) throws IOException {
+ return symmetric.enpass(unencrypted);
+ }
+
+ };
+
Lur ml = up = new LocalLur(ta,"myname:groupA,groupB","admin:myname,yourname;suser:hisname,hername,m1234%"+baos.toString());
diff --git a/cadi/core/src/test/resources/output_key b/cadi/core/src/test/resources/output_key
deleted file mode 100644
index 9d94dcbd..00000000
--- a/cadi/core/src/test/resources/output_key
+++ /dev/null
@@ -1 +0,0 @@
-QRSTUVWXYZabcdef \ No newline at end of file
diff --git a/cadi/core/test/output_key b/cadi/core/test/output_key
deleted file mode 100644
index 353fabd2..00000000
--- a/cadi/core/test/output_key
+++ /dev/null
@@ -1,27 +0,0 @@
-g6wDq10CsnMUE0HB18N2UsrFri27TBG05Z1JzrvNSPUhIphFcv7gst-eHKvfbgffKF-rs9Zkjd5F
-3FZDci9MlG4vhwrXHXLgo6DXEVH4FsfT5MP__E3yrnuGOcDI4kWUFdni3xG48PXNcT_xQoPb6JRO
-dI3PiRRhgpvxuIL8O6iptFRoEilywvb8ySRFJA1XkRxCq-btzSpAHdMkBF-YnwMQYASveKXUddgo
-Ab6Rvn6u8cDVWTIvmlEQe2el6dcKOOeMc5Ipc0AXsTLpGmhMVySEeyzKysHk0c1BiGxTulqZQcHP
-L9uDFMxqL_GBwQOM4Xfu5wD_Dh1zNoKIpPta1AORjqlaUFOEsV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