summaryrefslogtreecommitdiffstats
path: root/auth/auth-certman
diff options
context:
space:
mode:
Diffstat (limited to 'auth/auth-certman')
-rw-r--r--auth/auth-certman/src/main/java/org/onap/aaf/auth/cm/AAF_CM.java26
-rw-r--r--auth/auth-certman/src/main/java/org/onap/aaf/auth/cm/LocalCAImpl.java26
-rw-r--r--auth/auth-certman/src/main/java/org/onap/aaf/auth/cm/ca/CA.java4
-rw-r--r--auth/auth-certman/src/main/java/org/onap/aaf/auth/cm/mapper/Mapper1_0.java30
-rw-r--r--auth/auth-certman/src/main/java/org/onap/aaf/auth/cm/mapper/Mapper2_0.java22
-rw-r--r--auth/auth-certman/src/main/java/org/onap/aaf/auth/cm/service/CMService.java22
-rw-r--r--auth/auth-certman/src/main/java/org/onap/aaf/auth/cm/validation/CertmanValidator.java18
-rw-r--r--auth/auth-certman/src/test/java/org/onap/aaf/auth/cm/JU_AAF_CM.java306
-rw-r--r--auth/auth-certman/src/test/java/org/onap/aaf/auth/cm/api/JU_API_Artifact.java2
-rw-r--r--auth/auth-certman/src/test/java/org/onap/aaf/auth/cm/ca/JU_X509ChainTest.java50
-rw-r--r--auth/auth-certman/src/test/java/org/onap/aaf/auth/cm/ca/JU_X509ChainWithIssuerTest.java52
-rw-r--r--auth/auth-certman/src/test/java/org/onap/aaf/auth/cm/data/JU_CertReqTest.java44
-rw-r--r--auth/auth-certman/src/test/java/org/onap/aaf/auth/cm/data/JU_CertRespTest.java188
13 files changed, 395 insertions, 395 deletions
diff --git a/auth/auth-certman/src/main/java/org/onap/aaf/auth/cm/AAF_CM.java b/auth/auth-certman/src/main/java/org/onap/aaf/auth/cm/AAF_CM.java
index aa5c1daf..cf912fa4 100644
--- a/auth/auth-certman/src/main/java/org/onap/aaf/auth/cm/AAF_CM.java
+++ b/auth/auth-certman/src/main/java/org/onap/aaf/auth/cm/AAF_CM.java
@@ -73,7 +73,7 @@ import com.datastax.driver.core.Cluster;
public class AAF_CM extends AbsService<AuthzEnv, AuthzTrans> {
private static final String USER_PERMS = "userPerms";
- private static final String CM_ALLOW_TMP = "cm_allow_tmp";
+ private static final String CM_ALLOW_TMP = "cm_allow_tmp";
private static final Map<String,CA> certAuths = new TreeMap<>();
public static Facade1_0 facade1_0; // this is the default Facade
public static Facade1_0 facade1_0_XML; // this is the XML Facade
@@ -87,7 +87,7 @@ public class AAF_CM extends AbsService<AuthzEnv, AuthzTrans> {
//Added for junits
public CMService getService() {
- return null;
+ return null;
}
/**
* Construct AuthzAPI with all the Context Supporting Routes that Authz needs
@@ -112,7 +112,7 @@ public class AAF_CM extends AbsService<AuthzEnv, AuthzTrans> {
// Check for allowing /tmp in Properties
String allowTmp = env.getProperty(CM_ALLOW_TMP);
if("true".equalsIgnoreCase(allowTmp)) {
- CertmanValidator.allowTmp();
+ CertmanValidator.allowTmp();
}
@@ -150,10 +150,10 @@ public class AAF_CM extends AbsService<AuthzEnv, AuthzTrans> {
pinst[2]= aafEnv;
pinst[3] = multiParams;
try {
- CA ca = cons.newInstance(pinst);
+ CA ca = cons.newInstance(pinst);
certAuths.put(ca.getName(),ca);
} catch (InvocationTargetException e) {
- access.log(e, "Loading", segs[0]);
+ access.log(e, "Loading", segs[0]);
}
}
}
@@ -165,7 +165,7 @@ public class AAF_CM extends AbsService<AuthzEnv, AuthzTrans> {
service = getService();
if(service == null) {
- service = new CMService(trans, this);
+ service = new CMService(trans, this);
}
// note: Service knows how to shutdown Cluster on Shutdown, etc. See Constructor
facade1_0 = FacadeFactory.v1_0(this,trans, service,Data.TYPE.JSON); // Default Facade
@@ -254,14 +254,14 @@ public class AAF_CM extends AbsService<AuthzEnv, AuthzTrans> {
Log4JLogIt logIt = new Log4JLogIt(args, "cm");
PropAccess propAccess = new PropAccess(logIt,args);
try {
- new JettyServiceStarter<AuthzEnv,AuthzTrans>(
- new AAF_CM(new AuthzEnv(propAccess)),true)
- .start();
- } catch (Exception e) {
- propAccess.log(e);
- }
+ new JettyServiceStarter<AuthzEnv,AuthzTrans>(
+ new AAF_CM(new AuthzEnv(propAccess)),true)
+ .start();
+ } catch (Exception e) {
+ propAccess.log(e);
+ }
} catch (APIException e) {
- e.printStackTrace(System.err);
+ e.printStackTrace(System.err);
}
}
}
diff --git a/auth/auth-certman/src/main/java/org/onap/aaf/auth/cm/LocalCAImpl.java b/auth/auth-certman/src/main/java/org/onap/aaf/auth/cm/LocalCAImpl.java
index 632e719e..d32b67a3 100644
--- a/auth/auth-certman/src/main/java/org/onap/aaf/auth/cm/LocalCAImpl.java
+++ b/auth/auth-certman/src/main/java/org/onap/aaf/auth/cm/LocalCAImpl.java
@@ -31,18 +31,18 @@ import org.onap.aaf.misc.env.Trans;
public class LocalCAImpl extends CA {
- protected LocalCAImpl(Access access, String caName, String env) throws IOException, CertException {
- super(access, caName, env);
- // TODO Auto-generated constructor stub
- }
-
- public LocalCAImpl(Access access, final String name, final String env, final String[][] params) throws IOException, CertException {
- super(access, name, env);
- }
+ protected LocalCAImpl(Access access, String caName, String env) throws IOException, CertException {
+ super(access, caName, env);
+ // TODO Auto-generated constructor stub
+ }
+
+ public LocalCAImpl(Access access, final String name, final String env, final String[][] params) throws IOException, CertException {
+ super(access, name, env);
+ }
- @Override
- public X509andChain sign(Trans trans, CSRMeta csrmeta) throws IOException, CertException {
- // TODO Auto-generated method stub
- return null;
- }
+ @Override
+ public X509andChain sign(Trans trans, CSRMeta csrmeta) throws IOException, CertException {
+ // TODO Auto-generated method stub
+ return null;
+ }
} \ No newline at end of file
diff --git a/auth/auth-certman/src/main/java/org/onap/aaf/auth/cm/ca/CA.java b/auth/auth-certman/src/main/java/org/onap/aaf/auth/cm/ca/CA.java
index 26b4e2aa..ab304629 100644
--- a/auth/auth-certman/src/main/java/org/onap/aaf/auth/cm/ca/CA.java
+++ b/auth/auth-certman/src/main/java/org/onap/aaf/auth/cm/ca/CA.java
@@ -72,7 +72,7 @@ public abstract class CA {
this.name = caName;
this.env = env;
this.env_tag = env==null || env.isEmpty()?false:
- Boolean.parseBoolean(access.getProperty(CM_CA_ENV_TAG, Boolean.FALSE.toString()));
+ Boolean.parseBoolean(access.getProperty(CM_CA_ENV_TAG, Boolean.FALSE.toString()));
permNS=null;
String prefix = CM_CA_PREFIX + name;
permType = access.getProperty(prefix + ".perm_type",null);
@@ -195,7 +195,7 @@ public abstract class CA {
}
public boolean shouldAddEnvTag() {
- return env_tag;
+ return env_tag;
}
public String getEnv() {
diff --git a/auth/auth-certman/src/main/java/org/onap/aaf/auth/cm/mapper/Mapper1_0.java b/auth/auth-certman/src/main/java/org/onap/aaf/auth/cm/mapper/Mapper1_0.java
index 22243ae4..82639e21 100644
--- a/auth/auth-certman/src/main/java/org/onap/aaf/auth/cm/mapper/Mapper1_0.java
+++ b/auth/auth-certman/src/main/java/org/onap/aaf/auth/cm/mapper/Mapper1_0.java
@@ -223,10 +223,10 @@ public class Mapper1_0 implements Mapper<BaseRequest,CertInfo,Artifacts,Error> {
data.mechid = trim(arti.getMechid());
data.machine = trim(arti.getMachine());
if(arti.getType()!=null) {
- Set<String> ss = data.type(true);
- for(String t : arti.getType()) {
- ss.add(trim(t));
- }
+ Set<String> ss = data.type(true);
+ for(String t : arti.getType()) {
+ ss.add(trim(t));
+ }
}
data.ca = trim(arti.getCa());
data.dir = trim(arti.getDir());
@@ -240,9 +240,9 @@ public class Mapper1_0 implements Mapper<BaseRequest,CertInfo,Artifacts,Error> {
data.sponsor = (arti.getSponsor());
if(arti.getSans()!=null) {
Set<String> ls = data.sans(true);
- for(String t : arti.getSans()) {
- ls.add(trim(t));
- }
+ for(String t : arti.getSans()) {
+ ls.add(trim(t));
+ }
}
data.expires = null;
ladd.add(data);
@@ -266,13 +266,13 @@ public class Mapper1_0 implements Mapper<BaseRequest,CertInfo,Artifacts,Error> {
a.setCa(trim(arti.ca));
a.setDir(trim(arti.dir));
for(String t : arti.type(false)) {
- a.getType().add(trim(t));
+ a.getType().add(trim(t));
}
a.setOsUser(trim(arti.os_user));
a.setRenewDays(arti.renewDays);
a.setNotification(trim(arti.notify));
for(String t : arti.sans(false)) {
- a.getSans().add(trim(t));
+ a.getSans().add(trim(t));
}
artis.getArtifact().add(a);
}
@@ -285,10 +285,10 @@ public class Mapper1_0 implements Mapper<BaseRequest,CertInfo,Artifacts,Error> {
private String trim(String s) {
- if(s==null) {
- return s;
- } else {
- return s.trim();
- }
- }
+ if(s==null) {
+ return s;
+ } else {
+ return s.trim();
+ }
+ }
} \ No newline at end of file
diff --git a/auth/auth-certman/src/main/java/org/onap/aaf/auth/cm/mapper/Mapper2_0.java b/auth/auth-certman/src/main/java/org/onap/aaf/auth/cm/mapper/Mapper2_0.java
index 53388f67..283c828a 100644
--- a/auth/auth-certman/src/main/java/org/onap/aaf/auth/cm/mapper/Mapper2_0.java
+++ b/auth/auth-certman/src/main/java/org/onap/aaf/auth/cm/mapper/Mapper2_0.java
@@ -212,9 +212,9 @@ public class Mapper2_0 implements Mapper<BaseRequest,CertInfo,Artifacts,Error> {
data.machine = trim(arti.getMachine());
if(arti.getType()!=null) {
Set<String> ss = data.type(true);
- for(String t : arti.getType()) {
- ss.add(t.trim());
- }
+ for(String t : arti.getType()) {
+ ss.add(t.trim());
+ }
}
data.type(true).addAll(arti.getType());
data.ca = trim(arti.getCa());
@@ -231,7 +231,7 @@ public class Mapper2_0 implements Mapper<BaseRequest,CertInfo,Artifacts,Error> {
if(arti.getSans()!=null) {
Set<String> ss = data.sans(true);
for(String s : arti.getSans()) {
- ss.add(s.trim());
+ ss.add(s.trim());
}
}
ladd.add(data);
@@ -240,14 +240,14 @@ public class Mapper2_0 implements Mapper<BaseRequest,CertInfo,Artifacts,Error> {
}
private String trim(String s) {
- if(s==null) {
- return s;
- } else {
- return s.trim();
- }
- }
+ if(s==null) {
+ return s;
+ } else {
+ return s.trim();
+ }
+ }
- /* (non-Javadoc)
+ /* (non-Javadoc)
* @see org.onap.aaf.auth.cm.mapper.Mapper#fromArtifacts(org.onap.aaf.auth.layer.test.Result)
*/
@Override
diff --git a/auth/auth-certman/src/main/java/org/onap/aaf/auth/cm/service/CMService.java b/auth/auth-certman/src/main/java/org/onap/aaf/auth/cm/service/CMService.java
index 26b3a22a..48fe8d81 100644
--- a/auth/auth-certman/src/main/java/org/onap/aaf/auth/cm/service/CMService.java
+++ b/auth/auth-certman/src/main/java/org/onap/aaf/auth/cm/service/CMService.java
@@ -89,8 +89,8 @@ public class CMService {
private final CredDAO credDAO;
private final ArtiDAO artiDAO;
private AAF_CM certManager;
- private Boolean allowIgnoreIPs;
- private Boolean alwaysIgnoreIPs;
+ private Boolean allowIgnoreIPs;
+ private Boolean alwaysIgnoreIPs;
// @SuppressWarnings("unchecked")
public CMService(final AuthzTrans trans, AAF_CM certman) throws APIException, IOException {
@@ -113,12 +113,12 @@ public class CMService {
);
alwaysIgnoreIPs = Boolean.valueOf(certman.access.getProperty(Config.CM_ALWAYS_IGNORE_IPS, "false"));
if(alwaysIgnoreIPs) {
- trans.env().access().log(Level.INIT, "DNS Evaluation for Cert Creation is turned off with " + Config.CM_ALWAYS_IGNORE_IPS );
+ trans.env().access().log(Level.INIT, "DNS Evaluation for Cert Creation is turned off with " + Config.CM_ALWAYS_IGNORE_IPS );
} else {
- allowIgnoreIPs = Boolean.valueOf(certman.access.getProperty(Config.CM_ALLOW_IGNORE_IPS, "false"));
- if(allowIgnoreIPs) {
- trans.env().access().log(Level.INIT, "Allowing DNS Evaluation to be turned off with <ns>.certman|<ca name>|"+IGNORE_IPS);
- }
+ allowIgnoreIPs = Boolean.valueOf(certman.access.getProperty(Config.CM_ALLOW_IGNORE_IPS, "false"));
+ if(allowIgnoreIPs) {
+ trans.env().access().log(Level.INIT, "Allowing DNS Evaluation to be turned off with <ns>.certman|<ca name>|"+IGNORE_IPS);
+ }
}
}
@@ -147,11 +147,11 @@ public class CMService {
boolean ignoreIPs;
if(alwaysIgnoreIPs) {
- ignoreIPs=true;
+ ignoreIPs=true;
} else if(allowIgnoreIPs) {
- ignoreIPs = trans.fish(new AAFPermission(mechNS,CERTMAN, ca.getName(), IGNORE_IPS));
+ ignoreIPs = trans.fish(new AAFPermission(mechNS,CERTMAN, ca.getName(), IGNORE_IPS));
} else {
- ignoreIPs = false;
+ ignoreIPs = false;
}
@@ -185,7 +185,7 @@ public class CMService {
} else {
if (!ignoreIPs) {
- for (String cn : req.value.fqdns) {
+ for (String cn : req.value.fqdns) {
try {
InetAddress[] ias = InetAddress.getAllByName(cn);
Set<String> potentialSanNames = new HashSet<>();
diff --git a/auth/auth-certman/src/main/java/org/onap/aaf/auth/cm/validation/CertmanValidator.java b/auth/auth-certman/src/main/java/org/onap/aaf/auth/cm/validation/CertmanValidator.java
index 5835b31f..cdd501ce 100644
--- a/auth/auth-certman/src/main/java/org/onap/aaf/auth/cm/validation/CertmanValidator.java
+++ b/auth/auth-certman/src/main/java/org/onap/aaf/auth/cm/validation/CertmanValidator.java
@@ -48,13 +48,13 @@ public class CertmanValidator extends Validator{
private static final String MUST_HAVE_AT_LEAST = " must have at least ";
private static final String IS_NULL = " is null.";
private static final String ARTIFACTS_MUST_HAVE_AT_LEAST = "Artifacts must have at least ";
- private static final Pattern ALPHA_NUM = Pattern.compile("[a-zA-Z0-9]*");
-
- private static boolean disallowTmp = true;
- public static void allowTmp() {
- disallowTmp=false;
- }
-
+ private static final Pattern ALPHA_NUM = Pattern.compile("[a-zA-Z0-9]*");
+
+ private static boolean disallowTmp = true;
+ public static void allowTmp() {
+ disallowTmp=false;
+ }
+
public CertmanValidator nullBlankMin(String name, List<String> list, int min) {
if (list==null) {
msg(name + IS_NULL);
@@ -80,7 +80,7 @@ public class CertmanValidator extends Validator{
for (ArtiDAO.Data a : list) {
allRequired(a);
if(disallowTmp && a.dir!=null && a.dir.startsWith("/tmp")) {
- msg("Certificates may not be deployed into /tmp directory (they will be removed at a random time by O/S)");
+ msg("Certificates may not be deployed into /tmp directory (they will be removed at a random time by O/S)");
}
}
}
@@ -106,7 +106,7 @@ public class CertmanValidator extends Validator{
nullOrBlank(MACHINE, a.machine);
nullOrBlank("ca",a.ca);
nullOrBlank("dir",a.dir);
- match("NS must be dot separated AlphaNumeric",a.ns,NAME_CHARS);
+ match("NS must be dot separated AlphaNumeric",a.ns,NAME_CHARS);
match("O/S User must be AlphaNumeric",a.os_user,ALPHA_NUM);
// Note: AppName, Notify & Sponsor are currently not required
}
diff --git a/auth/auth-certman/src/test/java/org/onap/aaf/auth/cm/JU_AAF_CM.java b/auth/auth-certman/src/test/java/org/onap/aaf/auth/cm/JU_AAF_CM.java
index 1bee730a..9f7497e0 100644
--- a/auth/auth-certman/src/test/java/org/onap/aaf/auth/cm/JU_AAF_CM.java
+++ b/auth/auth-certman/src/test/java/org/onap/aaf/auth/cm/JU_AAF_CM.java
@@ -63,163 +63,163 @@ import org.powermock.modules.junit4.PowerMockRunner;
@PrepareForTest(FacadeFactory.class)
public class JU_AAF_CM {
- @Mock
- AuthzEnv env;
-
- BasicEnv baseEnv;
-
- @Mock
- PropAccess access;
-
- AuthzTransImpl1 trans;
-
- AAF_CMImpl rosettaObj = null;
-
- @Before
- public void setUp() {
- initMocks(this);
-
- try {
- Mockito.doReturn(access).when(env).access();
- Mockito.doReturn("test.test").when(access).getProperty(Config.AAF_ROOT_NS,"org.osaaf.aaf");
- Properties props=new Properties();
- Mockito.doReturn(props).when(access).getProperties();
- props.setProperty("cm_ca.props", "test");
- Mockito.doReturn("test:2.1").when(access).getProperty(Config.AAF_LOCATOR_ENTRIES, null);
- Mockito.doReturn("test").when(access).getProperty("https.protocols","TLSv1.1,TLSv1.2");
- Mockito.doReturn("test").when(env).getProperty("cm_ca.props.perm_type",null);
- Mockito.doReturn("test").when(env).getProperty("cm_ca.props.baseSubject",null);
- Mockito.doReturn("10").when(env).getProperty("CACHE_CLEAN_INTERVAL","60000");
- Mockito.doReturn("10").when(env).getProperty("CACHE_HIGH_COUNT","5000");
- trans = new AuthzTransImpl1(env);
- Mockito.doReturn(trans).when(env).newTrans();
-// Mockito.doReturn("test").when(trans).getProperty("cm_ca.props.baseSubject",null);
-// Mockito.doReturn(Mockito.mock(TimeTaken.class)).when(trans).start("Clear Reset Deque",8);
-
- Mockito.doReturn("TLSv1.1").when(access).getProperty("cadi_protocols","test");
- Mockito.doReturn("https://www.google.com").when(access).getProperty(Config.AAF_URL,null);
- Mockito.doReturn("test").when(env).getProperty(Config.AAF_ENV);
- Mockito.doReturn("10").when(env).getProperty(Config.CADI_LATITUDE);
- Mockito.doReturn("10").when(env).getProperty(Config.CADI_LONGITUDE);
- Mockito.doReturn("org.onap.aaf.auth.cm.LocalCAImpl,test;test").when(env).getProperty("cm_ca.props");
- Mockito.doReturn("google.com").when(env).getProperty("cassandra.clusters",null);
-// Mockito.doReturn(Mockito.mock(AuthzTransImpl.class)).when(env).newTrans();
- Mockito.doReturn(Mockito.mock(LogTarget.class)).when(env).init();
- AAF_CM tempObj = Mockito.mock(AAF_CM.class);
- Field envField = tempObj.getClass().getField("env");
- Field modifiersField = Field.class.getDeclaredField("modifiers");
- modifiersField.setAccessible(true);
- modifiersField.setInt(envField, envField.getModifiers() & ~Modifier.FINAL);
- envField.setAccessible(true);
- envField.set(tempObj, env);
- RosettaDF rosettaObjTemp = Mockito.mock(RosettaDF.class);
- Mockito.doReturn(rosettaObjTemp).when(rosettaObjTemp).in(Data.TYPE.JSON);
- Mockito.doReturn(rosettaObjTemp).when(env).newDataFactory(aaf.v2_0.Error.class);
- Mockito.doReturn(rosettaObjTemp).when(env).newDataFactory(certman.v1_0.CertificateRequest.class);
- Mockito.doReturn(rosettaObjTemp).when(env).newDataFactory(certman.v1_0.CertificateRenew.class);
- Mockito.doReturn(rosettaObjTemp).when(env).newDataFactory(certman.v1_0.CertificateDrop.class);
- Mockito.doReturn(rosettaObjTemp).when(env).newDataFactory(certman.v1_0.CertInfo.class);
- Mockito.doReturn(rosettaObjTemp).when(env).newDataFactory(certman.v1_0.Artifacts.class);
- Mockito.doReturn(Data.TYPE.XML).when(rosettaObjTemp).getOutType();
+ @Mock
+ AuthzEnv env;
+
+ BasicEnv baseEnv;
+
+ @Mock
+ PropAccess access;
+
+ AuthzTransImpl1 trans;
+
+ AAF_CMImpl rosettaObj = null;
+
+ @Before
+ public void setUp() {
+ initMocks(this);
+
+ try {
+ Mockito.doReturn(access).when(env).access();
+ Mockito.doReturn("test.test").when(access).getProperty(Config.AAF_ROOT_NS,"org.osaaf.aaf");
+ Properties props=new Properties();
+ Mockito.doReturn(props).when(access).getProperties();
+ props.setProperty("cm_ca.props", "test");
+ Mockito.doReturn("test:2.1").when(access).getProperty(Config.AAF_LOCATOR_ENTRIES, null);
+ Mockito.doReturn("test").when(access).getProperty("https.protocols","TLSv1.1,TLSv1.2");
+ Mockito.doReturn("test").when(env).getProperty("cm_ca.props.perm_type",null);
+ Mockito.doReturn("test").when(env).getProperty("cm_ca.props.baseSubject",null);
+ Mockito.doReturn("10").when(env).getProperty("CACHE_CLEAN_INTERVAL","60000");
+ Mockito.doReturn("10").when(env).getProperty("CACHE_HIGH_COUNT","5000");
+ trans = new AuthzTransImpl1(env);
+ Mockito.doReturn(trans).when(env).newTrans();
+// Mockito.doReturn("test").when(trans).getProperty("cm_ca.props.baseSubject",null);
+// Mockito.doReturn(Mockito.mock(TimeTaken.class)).when(trans).start("Clear Reset Deque",8);
+
+ Mockito.doReturn("TLSv1.1").when(access).getProperty("cadi_protocols","test");
+ Mockito.doReturn("https://www.google.com").when(access).getProperty(Config.AAF_URL,null);
+ Mockito.doReturn("test").when(env).getProperty(Config.AAF_ENV);
+ Mockito.doReturn("10").when(env).getProperty(Config.CADI_LATITUDE);
+ Mockito.doReturn("10").when(env).getProperty(Config.CADI_LONGITUDE);
+ Mockito.doReturn("org.onap.aaf.auth.cm.LocalCAImpl,test;test").when(env).getProperty("cm_ca.props");
+ Mockito.doReturn("google.com").when(env).getProperty("cassandra.clusters",null);
+// Mockito.doReturn(Mockito.mock(AuthzTransImpl.class)).when(env).newTrans();
+ Mockito.doReturn(Mockito.mock(LogTarget.class)).when(env).init();
+ AAF_CM tempObj = Mockito.mock(AAF_CM.class);
+ Field envField = tempObj.getClass().getField("env");
+ Field modifiersField = Field.class.getDeclaredField("modifiers");
+ modifiersField.setAccessible(true);
+ modifiersField.setInt(envField, envField.getModifiers() & ~Modifier.FINAL);
+ envField.setAccessible(true);
+ envField.set(tempObj, env);
+ RosettaDF rosettaObjTemp = Mockito.mock(RosettaDF.class);
+ Mockito.doReturn(rosettaObjTemp).when(rosettaObjTemp).in(Data.TYPE.JSON);
+ Mockito.doReturn(rosettaObjTemp).when(env).newDataFactory(aaf.v2_0.Error.class);
+ Mockito.doReturn(rosettaObjTemp).when(env).newDataFactory(certman.v1_0.CertificateRequest.class);
+ Mockito.doReturn(rosettaObjTemp).when(env).newDataFactory(certman.v1_0.CertificateRenew.class);
+ Mockito.doReturn(rosettaObjTemp).when(env).newDataFactory(certman.v1_0.CertificateDrop.class);
+ Mockito.doReturn(rosettaObjTemp).when(env).newDataFactory(certman.v1_0.CertInfo.class);
+ Mockito.doReturn(rosettaObjTemp).when(env).newDataFactory(certman.v1_0.Artifacts.class);
+ Mockito.doReturn(Data.TYPE.XML).when(rosettaObjTemp).getOutType();
- Facade1_0 facadeObj = Mockito.mock(Facade1_0.class);
- PowerMockito.mockStatic(FacadeFactory.class);
- FacadeFactory factObj = PowerMockito.mock(FacadeFactory.class);
- PowerMockito.when(factObj.v1_0(tempObj,trans, null,Data.TYPE.JSON)).thenReturn(facadeObj);
-
-// Mockito.doReturn(Mockito.mock(Mapper.class)).when(facadeObj).mapper();
+ Facade1_0 facadeObj = Mockito.mock(Facade1_0.class);
+ PowerMockito.mockStatic(FacadeFactory.class);
+ FacadeFactory factObj = PowerMockito.mock(FacadeFactory.class);
+ PowerMockito.when(factObj.v1_0(tempObj,trans, null,Data.TYPE.JSON)).thenReturn(facadeObj);
+
+// Mockito.doReturn(Mockito.mock(Mapper.class)).when(facadeObj).mapper();
-
- rosettaObj = new AAF_CMImpl(env);
- } catch (Exception e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- assertTrue(e instanceof NullPointerException);
- }
- }
-
- @Test
- public void testTestCA() {
- CA obj = rosettaObj.getCA("props");
- assertTrue(obj instanceof CA);
- }
-
-// @Test
-// public void testRoute() {
-// try {
-// rosettaObj.route(null, "", null, null);
-// } catch (Exception e) {
-// // TODO Auto-generated catch block
-// e.printStackTrace();
-// }
-//// System.out.println(obj);
-//// assertTrue(obj instanceof CA);
-// }
-
- @Test
- public void testFilters() {
- try {
- Filter[] obj = rosettaObj._filters(new Object[] {"props"});
- System.out.println(obj);
- } catch (CadiException | LocatorException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- assertTrue(e.getMessage().contains("Error initializing Context: TLS"));
- }
-// assertTrue(obj instanceof CA);
- }
-
- class AAF_CMImpl extends AAF_CM{
+
+ rosettaObj = new AAF_CMImpl(env);
+ } catch (Exception e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ assertTrue(e instanceof NullPointerException);
+ }
+ }
+
+ @Test
+ public void testTestCA() {
+ CA obj = rosettaObj.getCA("props");
+ assertTrue(obj instanceof CA);
+ }
+
+// @Test
+// public void testRoute() {
+// try {
+// rosettaObj.route(null, "", null, null);
+// } catch (Exception e) {
+// // TODO Auto-generated catch block
+// e.printStackTrace();
+// }
+//// System.out.println(obj);
+//// assertTrue(obj instanceof CA);
+// }
+
+ @Test
+ public void testFilters() {
+ try {
+ Filter[] obj = rosettaObj._filters(new Object[] {"props"});
+ System.out.println(obj);
+ } catch (CadiException | LocatorException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ assertTrue(e.getMessage().contains("Error initializing Context: TLS"));
+ }
+// assertTrue(obj instanceof CA);
+ }
+
+ class AAF_CMImpl extends AAF_CM{
- public AAF_CMImpl(AuthzEnv env) throws Exception {
- super(env);
- // TODO Auto-generated constructor stub
- }
-
- @Override
- public synchronized AAFConHttp aafCon() throws CadiException, LocatorException {
- return Mockito.mock(AAFConHttp.class);
- }
-
- public CMService getService() {
- return Mockito.mock(CMService.class);
- }
-
- @Override
- public void route(HttpMethods meth, String path, API api, Code code) throws Exception {
-
- }
- }
-
-
-
- class AuthzTransImpl1 extends AuthzTransImpl{
+ public AAF_CMImpl(AuthzEnv env) throws Exception {
+ super(env);
+ // TODO Auto-generated constructor stub
+ }
+
+ @Override
+ public synchronized AAFConHttp aafCon() throws CadiException, LocatorException {
+ return Mockito.mock(AAFConHttp.class);
+ }
+
+ public CMService getService() {
+ return Mockito.mock(CMService.class);
+ }
+
+ @Override
+ public void route(HttpMethods meth, String path, API api, Code code) throws Exception {
+
+ }
+ }
+
+
+
+ class AuthzTransImpl1 extends AuthzTransImpl{
- public AuthzTransImpl1(AuthzEnv env) {
- super(env);
- // TODO Auto-generated constructor stub
- }
+ public AuthzTransImpl1(AuthzEnv env) {
+ super(env);
+ // TODO Auto-generated constructor stub
+ }
- @Override
- protected TimeTaken newTimeTaken(String name, int flag, Object ... values) {
- // TODO Auto-generated method stub
- TimeTaken tt= new TimeTaken("nameTest", Env.XML) {
-
- @Override
- public void output(StringBuilder sb) {
- // TODO Auto-generated method stub
-
- }
- };
- return tt;
- }
-
- @Override
- public Metric auditTrail(int indent, StringBuilder sb, int ... flag) {
- return null;
- }
-
- }
-
+ @Override
+ protected TimeTaken newTimeTaken(String name, int flag, Object ... values) {
+ // TODO Auto-generated method stub
+ TimeTaken tt= new TimeTaken("nameTest", Env.XML) {
+
+ @Override
+ public void output(StringBuilder sb) {
+ // TODO Auto-generated method stub
+
+ }
+ };
+ return tt;
+ }
+
+ @Override
+ public Metric auditTrail(int indent, StringBuilder sb, int ... flag) {
+ return null;
+ }
+
+ }
+
}
diff --git a/auth/auth-certman/src/test/java/org/onap/aaf/auth/cm/api/JU_API_Artifact.java b/auth/auth-certman/src/test/java/org/onap/aaf/auth/cm/api/JU_API_Artifact.java
index 4ef85aa2..31ee0727 100644
--- a/auth/auth-certman/src/test/java/org/onap/aaf/auth/cm/api/JU_API_Artifact.java
+++ b/auth/auth-certman/src/test/java/org/onap/aaf/auth/cm/api/JU_API_Artifact.java
@@ -69,7 +69,7 @@ public class JU_API_Artifact {
@Test
public void placeholder() {
- Assert.assertTrue(true);
+ Assert.assertTrue(true);
}
/*
diff --git a/auth/auth-certman/src/test/java/org/onap/aaf/auth/cm/ca/JU_X509ChainTest.java b/auth/auth-certman/src/test/java/org/onap/aaf/auth/cm/ca/JU_X509ChainTest.java
index 06ea9e6e..4c6f7585 100644
--- a/auth/auth-certman/src/test/java/org/onap/aaf/auth/cm/ca/JU_X509ChainTest.java
+++ b/auth/auth-certman/src/test/java/org/onap/aaf/auth/cm/ca/JU_X509ChainTest.java
@@ -39,34 +39,34 @@ import org.onap.aaf.cadi.configure.CertException;
public class JU_X509ChainTest {
- @Mock
- X509Certificate x509;
+ @Mock
+ X509Certificate x509;
- @Mock
- X509ChainWithIssuer orig;
- @Mock
- Principal subject;
- @Mock
- Reader reader;
- @Mock
- X509Certificate cert;
+ @Mock
+ X509ChainWithIssuer orig;
+ @Mock
+ Principal subject;
+ @Mock
+ Reader reader;
+ @Mock
+ X509Certificate cert;
- @Before
- public void setUp() throws Exception {
- initMocks(this);
- // when(subject.get)
- // when(x509.getSubjectDN()).thenReturn(subject);
- when(cert.getEncoded()).thenReturn("x509".getBytes());
- }
+ @Before
+ public void setUp() throws Exception {
+ initMocks(this);
+ // when(subject.get)
+ // when(x509.getSubjectDN()).thenReturn(subject);
+ when(cert.getEncoded()).thenReturn("x509".getBytes());
+ }
- @Test
- public void test() throws IOException, CertException {
- Certificate[] certs = { x509 };
- X509andChain x509Chain = new X509andChain(cert, new ArrayList<String>());
- x509Chain.addTrustChainEntry(cert);
+ @Test
+ public void test() throws IOException, CertException {
+ Certificate[] certs = { x509 };
+ X509andChain x509Chain = new X509andChain(cert, new ArrayList<String>());
+ x509Chain.addTrustChainEntry(cert);
- assertNotNull(x509Chain.getX509());
- assertEquals(2, x509Chain.getTrustChain().length);
- }
+ assertNotNull(x509Chain.getX509());
+ assertEquals(2, x509Chain.getTrustChain().length);
+ }
}
diff --git a/auth/auth-certman/src/test/java/org/onap/aaf/auth/cm/ca/JU_X509ChainWithIssuerTest.java b/auth/auth-certman/src/test/java/org/onap/aaf/auth/cm/ca/JU_X509ChainWithIssuerTest.java
index 7b6afce7..dbae3fcd 100644
--- a/auth/auth-certman/src/test/java/org/onap/aaf/auth/cm/ca/JU_X509ChainWithIssuerTest.java
+++ b/auth/auth-certman/src/test/java/org/onap/aaf/auth/cm/ca/JU_X509ChainWithIssuerTest.java
@@ -39,36 +39,36 @@ import org.onap.aaf.cadi.configure.CertException;
public class JU_X509ChainWithIssuerTest {
- @Mock
- X509Certificate x509;
+ @Mock
+ X509Certificate x509;
- @Mock
- X509ChainWithIssuer orig;
- @Mock
- Principal subject;
- @Mock
- Reader reader;
+ @Mock
+ X509ChainWithIssuer orig;
+ @Mock
+ Principal subject;
+ @Mock
+ Reader reader;
- @Before
- public void setUp() throws Exception {
- initMocks(this);
- // when(subject.get)
- when(x509.getSubjectDN()).thenReturn(subject);
- when(x509.getEncoded()).thenReturn("x509".getBytes());
- }
+ @Before
+ public void setUp() throws Exception {
+ initMocks(this);
+ // when(subject.get)
+ when(x509.getSubjectDN()).thenReturn(subject);
+ when(x509.getEncoded()).thenReturn("x509".getBytes());
+ }
- @Test
- public void test() throws IOException, CertException {
- X509ChainWithIssuer x509Chain = new X509ChainWithIssuer(orig, x509);
+ @Test
+ public void test() throws IOException, CertException {
+ X509ChainWithIssuer x509Chain = new X509ChainWithIssuer(orig, x509);
- assertNull(x509Chain.getIssuerDN());
- Certificate[] certs = { x509 };
- // Certificate cert = ;
- x509Chain = new X509ChainWithIssuer(certs);
- List<Reader> rdrs = new ArrayList<Reader>();
- rdrs.add(null);
+ assertNull(x509Chain.getIssuerDN());
+ Certificate[] certs = { x509 };
+ // Certificate cert = ;
+ x509Chain = new X509ChainWithIssuer(certs);
+ List<Reader> rdrs = new ArrayList<Reader>();
+ rdrs.add(null);
- x509Chain = new X509ChainWithIssuer(rdrs);
- }
+ x509Chain = new X509ChainWithIssuer(rdrs);
+ }
}
diff --git a/auth/auth-certman/src/test/java/org/onap/aaf/auth/cm/data/JU_CertReqTest.java b/auth/auth-certman/src/test/java/org/onap/aaf/auth/cm/data/JU_CertReqTest.java
index 1ab26531..8b33036f 100644
--- a/auth/auth-certman/src/test/java/org/onap/aaf/auth/cm/data/JU_CertReqTest.java
+++ b/auth/auth-certman/src/test/java/org/onap/aaf/auth/cm/data/JU_CertReqTest.java
@@ -37,26 +37,26 @@ import org.onap.aaf.cadi.configure.CertException;
public class JU_CertReqTest {
- @Mock
- CA ca;
-
- @Mock
- CSRMeta csr;
-
- @Before
- public void setUp() throws Exception {
- initMocks(this);
- when(ca.newCSRMeta()).thenReturn(csr);
- when(csr.cn()).thenReturn("cn123");
- when(csr.mechID()).thenReturn("mechId");
- }
-
- @Test
- public void testCertResp() throws IOException, GeneralSecurityException, CertException {
- CertReq req = new CertReq();
- req.certAuthority = ca;
- req.fqdns = new ArrayList<String>();
-
- assertEquals(csr, req.getCSRMeta());
- }
+ @Mock
+ CA ca;
+
+ @Mock
+ CSRMeta csr;
+
+ @Before
+ public void setUp() throws Exception {
+ initMocks(this);
+ when(ca.newCSRMeta()).thenReturn(csr);
+ when(csr.cn()).thenReturn("cn123");
+ when(csr.mechID()).thenReturn("mechId");
+ }
+
+ @Test
+ public void testCertResp() throws IOException, GeneralSecurityException, CertException {
+ CertReq req = new CertReq();
+ req.certAuthority = ca;
+ req.fqdns = new ArrayList<String>();
+
+ assertEquals(csr, req.getCSRMeta());
+ }
}
diff --git a/auth/auth-certman/src/test/java/org/onap/aaf/auth/cm/data/JU_CertRespTest.java b/auth/auth-certman/src/test/java/org/onap/aaf/auth/cm/data/JU_CertRespTest.java
index 1366e706..37519a30 100644
--- a/auth/auth-certman/src/test/java/org/onap/aaf/auth/cm/data/JU_CertRespTest.java
+++ b/auth/auth-certman/src/test/java/org/onap/aaf/auth/cm/data/JU_CertRespTest.java
@@ -43,98 +43,98 @@ import org.onap.aaf.misc.env.Trans;
public class JU_CertRespTest {
- @Mock
- CSRMeta csrMeta;
-
- @Mock(answer = Answers.RETURNS_DEEP_STUBS)
- Trans trans;
-
- @Mock
- X509Certificate x509;
-
- @Mock
- CA ca;
-
- @Before
- public void setUp() throws Exception {
- initMocks(this);
- CertDrop drop = new CertDrop();
- CertRenew renew = new CertRenew();
-
- PublicKey publicKey = new PublicKey() {
-
- @Override
- public String getFormat() {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public byte[] getEncoded() {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public String getAlgorithm() {
- // TODO Auto-generated method stub
- return null;
- }
- };
- PrivateKey privateKey = new PrivateKey() {
-
- @Override
- public String getFormat() {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public byte[] getEncoded() {
- // TODO Auto-generated method stub
- return "privatekey".getBytes();
- }
-
- @Override
- public String getAlgorithm() {
- // TODO Auto-generated method stub
- return null;
- }
- };
- KeyPair keypair = new KeyPair(publicKey, privateKey);
-
- when(csrMeta.keypair(trans)).thenReturn(keypair);
- when(csrMeta.challenge()).thenReturn("challenge");
- when(x509.getSubjectDN()).thenReturn(null);
- when(x509.getEncoded()).thenReturn("x509Certificate".getBytes());
-
- }
-
- @Test
- public void testCertResp() throws IOException, GeneralSecurityException, CertException {
- CertResp resp = new CertResp("CERT");
-
- assertEquals("CERT", resp.asCertString());
- assertEquals("", resp.challenge());
-
- String[] trustChain = { "trustChain" };
- String[] notes = { "notes" };
-
- String[] caIssureDNs = { "caIssuer" };
- String[] trustedCAs = { "trustedCAs" };
-
- when(ca.getCaIssuerDNs()).thenReturn(caIssureDNs);
- when(ca.getEnv()).thenReturn("Env");
- when(ca.getTrustedCAs()).thenReturn(trustedCAs);
-
- resp = new CertResp(trans, ca, x509, csrMeta, trustChain, notes);
-
- assertNotNull(resp.privateString());
- assertEquals("challenge", resp.challenge());
- assertEquals("notes", resp.notes()[0]);
- assertEquals("trustChain", resp.trustChain()[0]);
- assertEquals("caIssuer", resp.caIssuerDNs()[0]);
- assertEquals("trustedCAs", resp.trustCAs()[0]);
- assertEquals("Env", resp.env());
- }
+ @Mock
+ CSRMeta csrMeta;
+
+ @Mock(answer = Answers.RETURNS_DEEP_STUBS)
+ Trans trans;
+
+ @Mock
+ X509Certificate x509;
+
+ @Mock
+ CA ca;
+
+ @Before
+ public void setUp() throws Exception {
+ initMocks(this);
+ CertDrop drop = new CertDrop();
+ CertRenew renew = new CertRenew();
+
+ PublicKey publicKey = new PublicKey() {
+
+ @Override
+ public String getFormat() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public byte[] getEncoded() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public String getAlgorithm() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+ };
+ PrivateKey privateKey = new PrivateKey() {
+
+ @Override
+ public String getFormat() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public byte[] getEncoded() {
+ // TODO Auto-generated method stub
+ return "privatekey".getBytes();
+ }
+
+ @Override
+ public String getAlgorithm() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+ };
+ KeyPair keypair = new KeyPair(publicKey, privateKey);
+
+ when(csrMeta.keypair(trans)).thenReturn(keypair);
+ when(csrMeta.challenge()).thenReturn("challenge");
+ when(x509.getSubjectDN()).thenReturn(null);
+ when(x509.getEncoded()).thenReturn("x509Certificate".getBytes());
+
+ }
+
+ @Test
+ public void testCertResp() throws IOException, GeneralSecurityException, CertException {
+ CertResp resp = new CertResp("CERT");
+
+ assertEquals("CERT", resp.asCertString());
+ assertEquals("", resp.challenge());
+
+ String[] trustChain = { "trustChain" };
+ String[] notes = { "notes" };
+
+ String[] caIssureDNs = { "caIssuer" };
+ String[] trustedCAs = { "trustedCAs" };
+
+ when(ca.getCaIssuerDNs()).thenReturn(caIssureDNs);
+ when(ca.getEnv()).thenReturn("Env");
+ when(ca.getTrustedCAs()).thenReturn(trustedCAs);
+
+ resp = new CertResp(trans, ca, x509, csrMeta, trustChain, notes);
+
+ assertNotNull(resp.privateString());
+ assertEquals("challenge", resp.challenge());
+ assertEquals("notes", resp.notes()[0]);
+ assertEquals("trustChain", resp.trustChain()[0]);
+ assertEquals("caIssuer", resp.caIssuerDNs()[0]);
+ assertEquals("trustedCAs", resp.trustCAs()[0]);
+ assertEquals("Env", resp.env());
+ }
}