diff options
author | Instrumental <jonathan.gathman@att.com> | 2019-08-07 13:40:39 -0500 |
---|---|---|
committer | Instrumental <jonathan.gathman@att.com> | 2019-08-07 13:40:42 -0500 |
commit | 3d1706fcbe7f95830ff6fd23cf679ee55c6d0595 (patch) | |
tree | ff97f10380a44d9f81d536c066782af10f728687 /auth/auth-certman/src/test | |
parent | 321dce367d74092a0ba09930c3aa526abdbd5da8 (diff) |
Remove Tabs, per Jococo
Issue-ID: AAF-932
Change-Id: I3ab0ebcc082048d2d1424a58a90ea479fb005ee6
Signed-off-by: Instrumental <jonathan.gathman@att.com>
Diffstat (limited to 'auth/auth-certman/src/test')
6 files changed, 321 insertions, 321 deletions
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()); + } } |