use of com.yahoo.athenz.common.server.ssh.SSHRecordStore in project athenz by yahoo.
the class FileSSHRecordStoreTest method testFileSSHRecordStoreFactory.
@Test
public void testFileSSHRecordStoreFactory() {
System.setProperty(ZTSConsts.ZTS_PROP_SSH_FILE_STORE_PATH, "/tmp");
FileSSHRecordStoreFactory factory = new FileSSHRecordStoreFactory();
SSHRecordStore store = factory.create(null);
assertNotNull(store);
System.clearProperty(ZTSConsts.ZTS_PROP_SSH_FILE_STORE_PATH);
}
use of com.yahoo.athenz.common.server.ssh.SSHRecordStore in project athenz by yahoo.
the class JDBCSSHRecordStoreFactoryTest method testCreate.
@Test
public void testCreate() {
System.setProperty(ZTSConsts.ZTS_PROP_SSH_JDBC_STORE, "jdbc:mysql://localhost");
System.setProperty(ZTSConsts.ZTS_PROP_SSH_JDBC_USER, "user");
System.setProperty(ZTSConsts.ZTS_PROP_SSH_JDBC_PASSWORD, "password");
PrivateKeyStore keyStore = Mockito.mock(PrivateKeyStore.class);
Mockito.doReturn("password").when(keyStore).getApplicationSecret("jdbc", "password");
JDBCSSHRecordStoreFactory factory = new JDBCSSHRecordStoreFactory();
SSHRecordStore store = factory.create(keyStore);
assertNotNull(store);
}
use of com.yahoo.athenz.common.server.ssh.SSHRecordStore in project athenz by yahoo.
the class InstanceCertManagerTest method testUpdateSSHCertRecord.
@Test
public void testUpdateSSHCertRecord() {
InstanceCertManager instance = new InstanceCertManager(null, null, null, true, null);
instance.setSSHSigner(null);
SSHRecordStore certStore = Mockito.mock(SSHRecordStore.class);
SSHRecordStoreConnection certConnection = Mockito.mock(SSHRecordStoreConnection.class);
when(certStore.getConnection()).thenReturn(certConnection);
instance.setSSHStore(certStore);
// when record is null, we get success all the time
assertTrue(instance.updateSSHCertRecord(null, true));
// now let's set our mock object to return success
// and pass a real object
when(certConnection.updateSSHCertRecord(ArgumentMatchers.isA(SSHCertRecord.class))).thenReturn(true);
SSHCertRecord sshCertRecord = new SSHCertRecord();
assertTrue(instance.updateSSHCertRecord(sshCertRecord, true));
instance.shutdown();
}
use of com.yahoo.athenz.common.server.ssh.SSHRecordStore in project athenz by yahoo.
the class InstanceCertManagerTest method testUpdateSSHCertRecordException.
@Test
public void testUpdateSSHCertRecordException() {
InstanceCertManager instance = new InstanceCertManager(null, null, null, true, null);
SSHRecordStore certStore = Mockito.mock(SSHRecordStore.class);
SSHRecordStoreConnection certConnection = Mockito.mock(SSHRecordStoreConnection.class);
when(certStore.getConnection()).thenReturn(certConnection);
when(certConnection.updateSSHCertRecord(any())).thenThrow(new RuntimeException("Fail to update"));
instance.setSSHStore(certStore);
SSHCertRecord sshCertRecord = new SSHCertRecord();
assertFalse(instance.updateSSHCertRecord(sshCertRecord, true));
instance.shutdown();
}
use of com.yahoo.athenz.common.server.ssh.SSHRecordStore in project athenz by yahoo.
the class DynamoDBSSHRecordStoreFactoryTest method testCreate.
@Test
public void testCreate() {
System.setProperty(ZTSConsts.ZTS_PROP_SSH_DYNAMODB_TABLE_NAME, "Athenz-ZTS-Table");
PrivateKeyStore keyStore = Mockito.mock(PrivateKeyStore.class);
TestDynamoDBSSHRecordStoreFactory factory = new TestDynamoDBSSHRecordStoreFactory();
SSHRecordStore store = factory.create(keyStore);
assertNotNull(store);
}
Aggregations