Search in sources :

Example 1 with SSHRecordStore

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

Example 2 with SSHRecordStore

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

Example 3 with SSHRecordStore

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();
}
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 4 with SSHRecordStore

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();
}
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 5 with SSHRecordStore

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

Aggregations

SSHRecordStore (com.yahoo.athenz.common.server.ssh.SSHRecordStore)8 Test (org.testng.annotations.Test)8 SSHCertRecord (com.yahoo.athenz.common.server.ssh.SSHCertRecord)3 SSHRecordStoreConnection (com.yahoo.athenz.common.server.ssh.SSHRecordStoreConnection)3 PrivateKeyStore (com.yahoo.athenz.auth.PrivateKeyStore)2 FileSSHRecordStoreFactory (com.yahoo.athenz.zts.cert.impl.FileSSHRecordStoreFactory)1