Search in sources :

Example 6 with Secret

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);
}
Also used : Secret(com.sequenceiq.cloudbreak.service.secret.domain.Secret) RdsConfigWithoutCluster(com.sequenceiq.cloudbreak.domain.view.RdsConfigWithoutCluster) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 7 with Secret

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;
}
Also used : VaultSecret(com.sequenceiq.cloudbreak.service.secret.vault.VaultSecret) Secret(com.sequenceiq.cloudbreak.service.secret.domain.Secret) SecurityConfig(com.sequenceiq.cloudbreak.domain.SecurityConfig)

Example 8 with Secret

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;
}
Also used : VaultSecret(com.sequenceiq.cloudbreak.service.secret.vault.VaultSecret) Secret(com.sequenceiq.cloudbreak.service.secret.domain.Secret) Cluster(com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster)

Example 9 with Secret

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;
}
Also used : VaultSecret(com.sequenceiq.cloudbreak.service.secret.vault.VaultSecret) Secret(com.sequenceiq.cloudbreak.service.secret.domain.Secret) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack)

Example 10 with Secret

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());
}
Also used : Secret(com.sequenceiq.cloudbreak.service.secret.domain.Secret) StackStatus(com.sequenceiq.freeipa.entity.StackStatus) InstanceStatus(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.instance.InstanceStatus) Status(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.Status) DetailedStackStatus(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.DetailedStackStatus) HttpClientConfig(com.sequenceiq.cloudbreak.client.HttpClientConfig) FreeIpa(com.sequenceiq.freeipa.entity.FreeIpa) StackStatus(com.sequenceiq.freeipa.entity.StackStatus) DetailedStackStatus(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.DetailedStackStatus) FreeIpaClientException(com.sequenceiq.freeipa.client.FreeIpaClientException) Stack(com.sequenceiq.freeipa.entity.Stack) Test(org.junit.jupiter.api.Test)

Aggregations

Secret (com.sequenceiq.cloudbreak.service.secret.domain.Secret)37 Test (org.junit.Test)11 Field (java.lang.reflect.Field)8 Test (org.junit.jupiter.api.Test)8 Stack (com.sequenceiq.freeipa.entity.Stack)7 SecretProxy (com.sequenceiq.cloudbreak.service.secret.domain.SecretProxy)5 SecretOperationException (com.sequenceiq.cloudbreak.service.secret.SecretOperationException)4 SecretResponse (com.sequenceiq.cloudbreak.service.secret.model.SecretResponse)4 VaultSecret (com.sequenceiq.cloudbreak.service.secret.vault.VaultSecret)4 HostKeytabRequest (com.sequenceiq.freeipa.api.v1.kerberosmgmt.model.HostKeytabRequest)4 HostKeytabResponse (com.sequenceiq.freeipa.api.v1.kerberosmgmt.model.HostKeytabResponse)4 FreeIpaClient (com.sequenceiq.freeipa.client.FreeIpaClient)4 Host (com.sequenceiq.freeipa.client.model.Host)4 KeytabCache (com.sequenceiq.freeipa.entity.KeytabCache)4 HttpClientConfig (com.sequenceiq.cloudbreak.client.HttpClientConfig)3 DetailedStackStatus (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.DetailedStackStatus)3 Status (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.Status)3 InstanceStatus (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.instance.InstanceStatus)3 RoleRequest (com.sequenceiq.freeipa.api.v1.kerberosmgmt.model.RoleRequest)3 FreeIpaClientException (com.sequenceiq.freeipa.client.FreeIpaClientException)3