Search in sources :

Example 1 with SSHRecordStoreConnection

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();
}
Also used : SSHRecordStoreConnection(com.yahoo.athenz.common.server.ssh.SSHRecordStoreConnection) SSHRecordStore(com.yahoo.athenz.common.server.ssh.SSHRecordStore) SSHCertRecord(com.yahoo.athenz.common.server.ssh.SSHCertRecord) Test(org.testng.annotations.Test)

Example 2 with SSHRecordStoreConnection

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();
}
Also used : SSHRecordStoreConnection(com.yahoo.athenz.common.server.ssh.SSHRecordStoreConnection) SSHRecordStore(com.yahoo.athenz.common.server.ssh.SSHRecordStore) SSHCertRecord(com.yahoo.athenz.common.server.ssh.SSHCertRecord) Test(org.testng.annotations.Test)

Example 3 with SSHRecordStoreConnection

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();
}
Also used : SSHRecordStoreConnection(com.yahoo.athenz.common.server.ssh.SSHRecordStoreConnection) Test(org.testng.annotations.Test)

Example 4 with SSHRecordStoreConnection

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();
}
Also used : SSHRecordStoreConnection(com.yahoo.athenz.common.server.ssh.SSHRecordStoreConnection) SSHRecordStore(com.yahoo.athenz.common.server.ssh.SSHRecordStore) SSHCertRecord(com.yahoo.athenz.common.server.ssh.SSHCertRecord) Test(org.testng.annotations.Test)

Aggregations

SSHRecordStoreConnection (com.yahoo.athenz.common.server.ssh.SSHRecordStoreConnection)4 Test (org.testng.annotations.Test)4 SSHCertRecord (com.yahoo.athenz.common.server.ssh.SSHCertRecord)3 SSHRecordStore (com.yahoo.athenz.common.server.ssh.SSHRecordStore)3