use of com.yahoo.athenz.common.server.ssh.SSHRecordStoreConnection 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.SSHRecordStoreConnection 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.SSHRecordStoreConnection in project athenz by yahoo.
the class DynamoDBSSHRecordStoreTest method testGetConnection.
@Test
public void testGetConnection() {
DynamoDBSSHRecordStore store = new DynamoDBSSHRecordStore(dbClient, "Athenz-ZTS-Table", null);
SSHRecordStoreConnection dbConn = store.getConnection();
assertNotNull(dbConn);
// empty methods
store.setOperationTimeout(10);
store.clearConnections();
}
use of com.yahoo.athenz.common.server.ssh.SSHRecordStoreConnection in project athenz by yahoo.
the class InstanceCertManagerTest method testInsertSSHCertRecord.
@Test
public void testInsertSSHCertRecord() {
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);
when(certConnection.insertSSHCertRecord(ArgumentMatchers.isA(SSHCertRecord.class))).thenReturn(true);
instance.setSSHStore(certStore);
SSHCertRecord sshCertRecord = new SSHCertRecord();
assertTrue(instance.updateSSHCertRecord(sshCertRecord, false));
instance.shutdown();
}
Aggregations