Check Perm Instance ending in colon 67/46767/1
authorInstrumental <jonathan.gathman@att.com>
Tue, 8 May 2018 19:33:18 +0000 (14:33 -0500)
committerInstrumental <jonathan.gathman@att.com>
Wed, 9 May 2018 11:05:32 +0000 (06:05 -0500)
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>
auth-client/pom.xml
auth/auth-service/src/test/java/org/onap/aaf/auth/service/validation/test/JU_ServiceValidator.java
auth/sample/local/org.osaaf.aaf.p12
cadi/aaf/src/main/java/org/onap/aaf/cadi/cm/PlaceArtifactInKeystore.java
cadi/aaf/src/test/java/org/onap/aaf/cadi/cm/test/JU_ArtifactDir.java
cadi/aaf/src/test/java/org/onap/aaf/cadi/cm/test/JU_PlaceArtifactInKeystore.java
cadi/core/src/test/java/org/onap/aaf/cadi/lur/test/JU_LocalLur.java
cadi/core/src/test/resources/output_key [deleted file]
cadi/core/test/output_key [deleted file]

index 9f0bef7..789e24e 100644 (file)
                        <plugin>
                                <groupId>org.apache.maven.plugins</groupId>
                                <artifactId>maven-deploy-plugin</artifactId>
-                               <version>2.5</version>
                                <configuration>
                                        <skip>false</skip>
                                </configuration>
                        <plugin>
                                <groupId>org.sonatype.plugins</groupId>
                                <artifactId>nexus-staging-maven-plugin</artifactId>
-                               <version>1.6.7</version>
                                <extensions>true</extensions>
                                <configuration>
                                        <nexusUrl>${nexusproxy}</nexusUrl>
                        <plugin>
                                <groupId>org.jacoco</groupId>
                                <artifactId>jacoco-maven-plugin</artifactId>
-                               <version>0.7.7.201606060606</version>
                                <configuration>
                                        <dumpOnExit>true</dumpOnExit>
                                        <includes>
index a0e5bfa..f304fcc 100644 (file)
@@ -53,6 +53,18 @@ public class JU_ServiceValidator {
                assertTrue(validator.errs().equals("ERR_Security\n"));
 
        }
+       
+       @Test
+       public void permInstance() {
+               assertFalse(validator.permInstance("hello").err());
+               assertFalse(validator.permInstance("hello32").err());
+               assertFalse(validator.permInstance("hello-32").err());
+               assertFalse(validator.permInstance(":asdf:*:sdf*:sdk").err());
+               assertFalse(validator.permInstance(":asdf:*:sdf*:sdk*").err());
+               // Perms may not end in ":"
+               assertTrue(validator.permInstance(":").err());
+               assertTrue(validator.permInstance(":hello:").err());
+       }
 
        @Test
        public void permOkNull() {
index f40a755..1e1ce69 100644 (file)
Binary files a/auth/sample/local/org.osaaf.aaf.p12 and b/auth/sample/local/org.osaaf.aaf.p12 differ
index 9360e02..2b498d4 100644 (file)
@@ -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;
        }
 
 }
index 855c26f..dbddd57 100644 (file)
 
 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 {
index 02054cb..d146f63 100644 (file)
@@ -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));
                }
 
index fd8e357..50933f4 100644 (file)
@@ -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 (file)
index 9d94dcb..0000000
+++ /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 (file)
index 353fabd..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-g6wDq10CsnMUE0HB18N2UsrFri27TBG05Z1JzrvNSPUhIphFcv7gst-eHKvfbgffKF-rs9Zkjd5F
-3FZDci9MlG4vhwrXHXLgo6DXEVH4FsfT5MP__E3yrnuGOcDI4kWUFdni3xG48PXNcT_xQoPb6JRO
-dI3PiRRhgpvxuIL8O6iptFRoEilywvb8ySRFJA1XkRxCq-btzSpAHdMkBF-YnwMQYASveKXUddgo
-Ab6Rvn6u8cDVWTIvmlEQe2el6dcKOOeMc5Ipc0AXsTLpGmhMVySEeyzKysHk0c1BiGxTulqZQcHP
-L9uDFMxqL_GBwQOM4Xfu5wD_Dh1zNoKIpPta1AORjqlaUFOEsVWIn5oOKnimz4aNOjUku7tj3OKi
-c-AsphXLIpmodQD4uZBynwhIjuNcJ3-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