use of com.sequenceiq.cloudbreak.service.secret.domain.Secret in project cloudbreak by hortonworks.
the class RdsViewTest method testCreateRdsViewWithRdsViewWithoutCluster.
@Test
public void testCreateRdsViewWithRdsViewWithoutCluster() {
RdsConfigWithoutCluster rdsView = Mockito.mock(RdsConfigWithoutCluster.class);
when(rdsView.isArchived()).thenReturn(true);
when(rdsView.getConnectionDriver()).thenReturn("driver");
when(rdsView.getConnectionURL()).thenReturn("jdbc:mysql://ranger-mysql.cmseikcocinw.us-east-1.rds.amazonaws.com:3306/ranger");
when(rdsView.getConnectionPassword()).thenReturn(new Secret("pass"));
when(rdsView.getConnectionUserName()).thenReturn(new Secret("username"));
when(rdsView.getConnectorJarUrl()).thenReturn("jarurl");
when(rdsView.getCreationDate()).thenReturn(1L);
when(rdsView.getDatabaseEngine()).thenReturn(DatabaseVendor.MYSQL);
when(rdsView.getDeletionTimestamp()).thenReturn(2L);
when(rdsView.getDescription()).thenReturn("desc");
when(rdsView.getId()).thenReturn(-1L);
when(rdsView.getName()).thenReturn("name");
when(rdsView.getSslMode()).thenReturn(RdsSslMode.ENABLED);
when(rdsView.getType()).thenReturn("type");
RdsView underTest = new RdsView(rdsView, "ssl-path");
assertThat(underTest.getClusterManagerVendor()).isEqualTo("mysql");
assertThat(underTest.getConnectionString()).isEqualTo("jdbc:mysql://ranger-mysql.cmseikcocinw.us-east-1.rds.amazonaws.com:3306/ranger?sslmode=verify-full&sslrootcert=ssl-path");
assertThat(underTest.getConnectionUserName()).isEqualTo("username");
assertThat(underTest.getHostWithPortWithJdbc()).isEqualTo("jdbc:mysql://ranger-mysql.cmseikcocinw.us-east-1.rds.amazonaws.com:3306");
assertThat(underTest.getHost()).isEqualTo("ranger-mysql.cmseikcocinw.us-east-1.rds.amazonaws.com");
assertThat(underTest.getConnectionDriver()).isEqualTo("driver");
assertThat(underTest.getConnectionPassword()).isEqualTo("pass");
assertThat(underTest.getConnectionURL()).isEqualTo("jdbc:mysql://ranger-mysql.cmseikcocinw.us-east-1.rds.amazonaws.com:3306/ranger?sslmode=verify-full&sslrootcert=ssl-path");
assertThat(underTest.getDatabaseEngine()).isEqualTo("mysql");
assertThat(underTest.getDatabaseType()).isEqualTo("mysql");
assertThat(underTest.getDatabaseVendor()).isEqualTo(DatabaseVendor.MYSQL);
assertThat(underTest.getDatabaseName()).isEqualTo("ranger");
assertThat(underTest.getFancyName()).isEqualTo("MySQL / MariaDB");
assertThat(underTest.getLowerCaseDatabaseEngine()).isEqualTo("mysql");
assertThat(underTest.getName()).isEqualTo("ranger");
assertThat(underTest.getPassword()).isEqualTo("pass");
assertThat(underTest.getPort()).isEqualTo("3306");
assertThat(underTest.getSslCertificateFilePath()).isEqualTo("ssl-path");
assertThat(underTest.getSubprotocol()).isEqualTo("mysql");
assertThat(underTest.getUserName()).isEqualTo("username");
assertThat(underTest.getVendor()).isEqualTo("mysql");
assertThat(underTest.getWithoutJDBCPrefix()).isEqualTo("ranger-mysql.cmseikcocinw.us-east-1.rds.amazonaws.com:3306/ranger?sslmode=verify-full&sslrootcert=ssl-path");
assertThat(underTest.isUseSsl()).isEqualTo(true);
}
use of com.sequenceiq.cloudbreak.service.secret.domain.Secret in project cloudbreak by hortonworks.
the class ClusterProxyServiceTest method gatewaySecurityConfig.
private SecurityConfig gatewaySecurityConfig() {
SecurityConfig securityConfig = new SecurityConfig();
ReflectionTestUtils.setField(securityConfig, "clientKey", new Secret("clientKey", vaultSecretString("clientKey")));
ReflectionTestUtils.setField(securityConfig, "clientCert", new Secret("clientCert", vaultSecretString("clientCert")));
return securityConfig;
}
use of com.sequenceiq.cloudbreak.service.secret.domain.Secret in project cloudbreak by hortonworks.
the class ClusterProxyServiceTest method testCluster.
private Cluster testCluster() {
Cluster cluster = new Cluster();
cluster.setId(CLUSTER_ID);
cluster.setCloudbreakUser("cloudbreak");
ReflectionTestUtils.setField(cluster, "cloudbreakAmbariPassword", new Secret("cbpassword", vaultSecretString("cbpassword")));
cluster.setDpUser("cmmgmt");
ReflectionTestUtils.setField(cluster, "dpAmbariPassword", new Secret("dppassword", vaultSecretString("dppassword")));
return cluster;
}
use of com.sequenceiq.cloudbreak.service.secret.domain.Secret in project cloudbreak by hortonworks.
the class ClusterProxyServiceTest method testStackWithInvalidSecret.
private Stack testStackWithInvalidSecret() throws JsonProcessingException {
Stack stack = testStack();
ReflectionTestUtils.setField(stack.getCluster(), "cloudbreakAmbariPassword", new Secret("cbpassword", "invalid-vault-string"));
ReflectionTestUtils.setField(stack.getCluster(), "cloudbreakClusterManagerPassword", new Secret("cbpassword", "invalid-vault-string"));
ReflectionTestUtils.setField(stack.getCluster(), "dpClusterManagerPassword", new Secret("cbpassword", "invalid-vault-string"));
ReflectionTestUtils.setField(stack.getCluster(), "cloudbreakClusterManagerPassword", new Secret("cbpassword", "invalid-vault-string"));
return stack;
}
use of com.sequenceiq.cloudbreak.service.secret.domain.Secret in project cloudbreak by hortonworks.
the class FreeIpaClientFactoryTest method getFreeIpaClientForStackShouldReturnClientWhenStackStatusIsValid.
@Test
void getFreeIpaClientForStackShouldReturnClientWhenStackStatusIsValid() throws FreeIpaClientException {
Stack stack = createStack();
stack.setGatewayport(80);
FreeIpa freeIpa = new FreeIpa();
freeIpa.setAdminPassword(new Secret("", ""));
when(freeIpaService.findByStack(stack)).thenReturn(freeIpa);
when(stackService.getByIdWithListsInTransaction(stack.getId())).thenReturn(stack);
when(tlsSecurityService.buildTLSClientConfig(any(), any(), any())).thenReturn(new HttpClientConfig(FREEIPP_FQDN));
Status unreachableState = Status.AVAILABLE;
StackStatus stackStatus = new StackStatus(stack, unreachableState, "The FreeIPA instance is reachable.", DetailedStackStatus.AVAILABLE);
stack.setStackStatus(stackStatus);
when(clusterProxyService.isCreateConfigForClusterProxy(stack)).thenReturn(false);
FreeIpaClientException exception = Assertions.assertThrows(FreeIpaClientException.class, () -> underTest.getFreeIpaClientForStack(stack));
verify(clusterProxyService, times(1)).isCreateConfigForClusterProxy(stack);
verify(tlsSecurityService, times(1)).buildTLSClientConfig(any(), any(), any());
Assertions.assertEquals(FreeIpaClientException.class, exception.getCause().getClass());
}
Aggregations