use of com.yahoo.athenz.zts.InstanceIdentity in project athenz by yahoo.
the class InstanceCertManagerTest method testGenerateSshIdentity.
@Test
public void testGenerateSshIdentity() {
String sshCsr = "{\"csr\":\"csr\",\"certtype\":\"host\"}";
CertSigner certSigner = Mockito.mock(com.yahoo.athenz.common.server.cert.CertSigner.class);
Mockito.when(certSigner.generateSSHCertificate(sshCsr)).thenReturn("ssh-cert");
Mockito.when(certSigner.getSSHCertificate(ZTSConsts.ZTS_SSH_HOST)).thenReturn("ssh-host");
Mockito.when(certSigner.getSSHCertificate(ZTSConsts.ZTS_SSH_USER)).thenReturn("ssh-user");
InstanceCertManager instanceManager = new InstanceCertManager(null, certSigner);
InstanceIdentity identity = new InstanceIdentity().setName("athenz.service");
boolean result = instanceManager.generateSshIdentity(identity, sshCsr, "host");
assertTrue(result);
assertEquals(identity.getSshCertificate(), "ssh-cert");
assertEquals(identity.getSshCertificateSigner(), "ssh-host");
}
use of com.yahoo.athenz.zts.InstanceIdentity in project athenz by yahoo.
the class InstanceCertManagerTest method testGenerateSshIdentityNullCertError.
@Test
public void testGenerateSshIdentityNullCertError() {
String sshCsr = "{\"csr\":\"csr\",\"certtype\":\"host\"}";
CertSigner certSigner = Mockito.mock(com.yahoo.athenz.common.server.cert.CertSigner.class);
Mockito.when(certSigner.generateSSHCertificate(sshCsr)).thenReturn(null);
Mockito.when(certSigner.getSSHCertificate(ZTSConsts.ZTS_SSH_HOST)).thenReturn("ssh-host");
Mockito.when(certSigner.getSSHCertificate(ZTSConsts.ZTS_SSH_USER)).thenReturn("ssh-user");
InstanceCertManager instanceManager = new InstanceCertManager(null, certSigner);
InstanceIdentity identity = new InstanceIdentity().setName("athenz.service");
boolean result = instanceManager.generateSshIdentity(identity, sshCsr, "host");
assertFalse(result);
}
use of com.yahoo.athenz.zts.InstanceIdentity in project athenz by yahoo.
the class InstanceCertManagerTest method testGenerateIdentityEmptyCert.
@Test
public void testGenerateIdentityEmptyCert() {
CertSigner certSigner = Mockito.mock(com.yahoo.athenz.common.server.cert.CertSigner.class);
Mockito.when(certSigner.generateX509Certificate(Mockito.<String>any(), Mockito.any(), Mockito.anyInt())).thenReturn("");
InstanceCertManager instanceManager = new InstanceCertManager(null, certSigner);
InstanceIdentity identity = instanceManager.generateIdentity("csr", "cn", null, 0);
assertNull(identity);
}
use of com.yahoo.athenz.zts.InstanceIdentity in project athenz by yahoo.
the class InstanceCertManagerTest method testGenerateSshIdentityInvalidSsh.
@Test
public void testGenerateSshIdentityInvalidSsh() {
InstanceIdentity identity = new InstanceIdentity().setName("athenz.service");
InstanceCertManager instanceManager = new InstanceCertManager(null, null);
boolean result = instanceManager.generateSshIdentity(identity, "{\"csr\":\"csr\"}", null);
assertFalse(result);
}
use of com.yahoo.athenz.zts.InstanceIdentity in project athenz by yahoo.
the class InstanceCertManagerTest method testGenerateIdentityNullCert.
@Test
public void testGenerateIdentityNullCert() {
CertSigner certSigner = Mockito.mock(com.yahoo.athenz.common.server.cert.CertSigner.class);
Mockito.when(certSigner.generateX509Certificate(Mockito.<String>any(), Mockito.any(), Mockito.anyInt())).thenReturn(null);
InstanceCertManager instanceManager = new InstanceCertManager(null, certSigner);
InstanceIdentity identity = instanceManager.generateIdentity("csr", "cn", null, 0);
assertNull(identity);
}
Aggregations