use of com.spotify.helios.client.tls.CertificateAndPrivateKey in project helios by spotify.
the class HttpsHandlersTest method testSshAgent.
@Test
public void testSshAgent() throws Exception {
final byte[] random = new byte[255];
new Random().nextBytes(random);
final AgentProxy proxy = mock(AgentProxy.class);
final Identity identity = mock(Identity.class);
when(identity.getKeyBlob()).thenReturn(random);
when(proxy.sign(any(Identity.class), any(byte[].class))).thenAnswer(new Answer<byte[]>() {
@Override
public byte[] answer(InvocationOnMock invocation) throws Throwable {
final byte[] bytesToSign = (byte[]) invocation.getArguments()[1];
return sha1digest(bytesToSign);
}
});
final SshAgentHttpsHandler h = new SshAgentHttpsHandler("foo", true, proxy, identity);
final CertificateAndPrivateKey pair = h.createCertificateAndPrivateKey();
assertNotNull(pair);
assertNotNull(pair.getCertificate());
assertNotNull(pair.getPrivateKey());
}
use of com.spotify.helios.client.tls.CertificateAndPrivateKey in project helios by spotify.
the class HttpsHandlersTest method testCertificateFile.
@Test
public void testCertificateFile() throws Exception {
final ClientCertificatePath clientCertificatePath = new ClientCertificatePath(Paths.get(getResource("UIDCACert.pem").getPath()), Paths.get(getResource("UIDCACert.key").getPath()));
final HttpsHandlers.CertificateFileHttpsHandler h = new HttpsHandlers.CertificateFileHttpsHandler("foo", true, clientCertificatePath);
final CertificateAndPrivateKey pair = h.createCertificateAndPrivateKey();
assertNotNull(pair);
assertNotNull(pair.getCertificate());
assertNotNull(pair.getPrivateKey());
}
Aggregations