Search in sources :

Example 16 with SecretResponse

use of com.sequenceiq.cloudbreak.service.secret.model.SecretResponse in project cloudbreak by hortonworks.

the class DatabaseServerConfigToDatabaseServerV4ResponseConverterTest method testConversionWhenUserManaged.

@Test
public void testConversionWhenUserManaged() {
    DatabaseServerConfig server = new DatabaseServerConfig();
    server.setId(1L);
    server.setResourceCrn(TestData.getTestCrn(RESOURCE_TYPE_DATABASE_SERVER, RESOURCE_ID));
    server.setName(RESOURCE_ID);
    server.setDescription("mine not yours");
    server.setHost(HOST);
    server.setPort(PORT);
    server.setDatabaseVendor(DatabaseVendor.POSTGRES);
    initializeSecrets(server);
    server.setCreationDate(System.currentTimeMillis());
    server.setEnvironmentId(ENVIRONMENT_ID);
    server.setResourceStatus(ResourceStatus.USER_MANAGED);
    when(stringToSecretResponseConverter.convert(anyString())).thenReturn(new SecretResponse());
    DatabaseServerV4Response response = converter.convert(server);
    verify(stringToSecretResponseConverter, times(2)).convert(anyString());
    assertThat(response).isNotNull();
    assertThat(response.getResourceStatus()).isEqualTo(server.getResourceStatus());
    assertThat(response.getStatus()).isEqualTo(Status.AVAILABLE);
    assertThat(response.getStatusReason()).isNull();
}
Also used : SecretResponse(com.sequenceiq.cloudbreak.service.secret.model.SecretResponse) DatabaseServerV4Response(com.sequenceiq.redbeams.api.endpoint.v4.databaseserver.responses.DatabaseServerV4Response) DatabaseServerConfig(com.sequenceiq.redbeams.domain.DatabaseServerConfig) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 17 with SecretResponse

use of com.sequenceiq.cloudbreak.service.secret.model.SecretResponse in project cloudbreak by hortonworks.

the class DatabaseServerConfigToDatabaseServerV4ResponseConverterTest method testConversion.

@Test
public void testConversion() {
    DatabaseServerConfig server = new DatabaseServerConfig();
    server.setId(1L);
    server.setResourceCrn(TestData.getTestCrn(RESOURCE_TYPE_DATABASE_SERVER, RESOURCE_ID));
    server.setName(RESOURCE_ID);
    server.setDescription("mine not yours");
    server.setHost(HOST);
    server.setPort(PORT);
    server.setDatabaseVendor(DatabaseVendor.POSTGRES);
    initializeSecrets(server);
    server.setCreationDate(System.currentTimeMillis());
    server.setEnvironmentId(ENVIRONMENT_ID);
    server.setClusterCrn("myclustercrn");
    server.setResourceStatus(ResourceStatus.SERVICE_MANAGED);
    DBStack dbStack = new DBStack();
    initDBStackStatus(dbStack);
    server.setDbStack(dbStack);
    when(stringToSecretResponseConverter.convert(anyString())).thenReturn(new SecretResponse());
    DatabaseServerV4Response response = converter.convert(server);
    verify(stringToSecretResponseConverter, times(2)).convert(anyString());
    assertThat(response).isNotNull();
    assertThat(response.getId()).isEqualTo(server.getId());
    assertThat(response.getCrn()).isEqualTo(server.getResourceCrn().toString());
    assertThat(response.getName()).isEqualTo(server.getName());
    assertThat(response.getDescription()).isEqualTo(server.getDescription());
    assertThat(response.getHost()).isEqualTo(server.getHost());
    assertThat(response.getPort()).isEqualTo(server.getPort());
    assertThat(response.getDatabaseVendor()).isEqualTo(server.getDatabaseVendor().databaseType());
    assertThat(response.getDatabaseVendorDisplayName()).isEqualTo(server.getDatabaseVendor().displayName());
    assertThat(response.getConnectionUserName()).isNotNull();
    assertThat(response.getConnectionPassword()).isNotNull();
    assertThat(response.getCreationDate()).isEqualTo(server.getCreationDate());
    assertThat(response.getEnvironmentCrn()).isEqualTo(server.getEnvironmentId());
    assertThat(response.getClusterCrn()).isEqualTo(server.getClusterCrn());
    assertThat(response.getResourceStatus()).isEqualTo(server.getResourceStatus());
    assertThat(response.getStatus()).isEqualTo(dbStack.getStatus());
    assertThat(response.getStatusReason()).isEqualTo(dbStack.getStatusReason());
}
Also used : SecretResponse(com.sequenceiq.cloudbreak.service.secret.model.SecretResponse) DatabaseServerV4Response(com.sequenceiq.redbeams.api.endpoint.v4.databaseserver.responses.DatabaseServerV4Response) DatabaseServerConfig(com.sequenceiq.redbeams.domain.DatabaseServerConfig) DBStack(com.sequenceiq.redbeams.domain.stack.DBStack) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 18 with SecretResponse

use of com.sequenceiq.cloudbreak.service.secret.model.SecretResponse in project cloudbreak by hortonworks.

the class KerberosMgmtVaultComponentV1Test method testGetSecretResponseForPrincipalWithHost.

@Test
public void testGetSecretResponseForPrincipalWithHost() throws Exception {
    String expectedPath = "account1/HostKeytab/serviceprincipal/12345-6789/54321-9876/host1";
    SecretResponse expectedSecretResponse = new SecretResponse();
    expectedSecretResponse.setEnginePath(ENGINE_PATH);
    expectedSecretResponse.setSecretPath(expectedPath);
    HostKeytabRequest hostKeytabRequest = new HostKeytabRequest();
    hostKeytabRequest.setEnvironmentCrn(ENVIRONMENT_ID);
    hostKeytabRequest.setClusterCrn(CLUSTER_ID);
    hostKeytabRequest.setServerHostName(HOST);
    Mockito.when(secretService.put(anyString(), anyString())).thenReturn(SECRET);
    Mockito.when(stringToSecretResponseConverter.convert(anyString())).thenReturn(expectedSecretResponse);
    Assertions.assertEquals(expectedSecretResponse, underTest.getSecretResponseForPrincipal(hostKeytabRequest, ACCOUNT, PRINCIPAL));
    Mockito.verify(secretService).put(expectedPath, PRINCIPAL);
    Mockito.verify(stringToSecretResponseConverter).convert(SECRET);
}
Also used : SecretResponse(com.sequenceiq.cloudbreak.service.secret.model.SecretResponse) HostKeytabRequest(com.sequenceiq.freeipa.api.v1.kerberosmgmt.model.HostKeytabRequest) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Test(org.junit.jupiter.api.Test)

Example 19 with SecretResponse

use of com.sequenceiq.cloudbreak.service.secret.model.SecretResponse in project cloudbreak by hortonworks.

the class KerberosMgmtVaultComponentV1Test method testGetSecretResponseForPrincipalWithService.

@Test
public void testGetSecretResponseForPrincipalWithService() throws Exception {
    String expectedPath = "account1/ServiceKeytab/serviceprincipal/12345-6789/54321-9876/host1/service1";
    SecretResponse expectedSecretResponse = new SecretResponse();
    expectedSecretResponse.setEnginePath(ENGINE_PATH);
    expectedSecretResponse.setSecretPath(expectedPath);
    ServiceKeytabRequest serviceKeytabRequest = new ServiceKeytabRequest();
    serviceKeytabRequest.setEnvironmentCrn(ENVIRONMENT_ID);
    serviceKeytabRequest.setClusterCrn(CLUSTER_ID);
    serviceKeytabRequest.setServerHostName(HOST);
    serviceKeytabRequest.setServiceName(SERVICE);
    Mockito.when(secretService.put(anyString(), anyString())).thenReturn(SECRET);
    Mockito.when(stringToSecretResponseConverter.convert(anyString())).thenReturn(expectedSecretResponse);
    Assertions.assertEquals(expectedSecretResponse, underTest.getSecretResponseForPrincipal(serviceKeytabRequest, ACCOUNT, PRINCIPAL));
    Mockito.verify(secretService).put(expectedPath, PRINCIPAL);
    Mockito.verify(stringToSecretResponseConverter).convert(SECRET);
}
Also used : SecretResponse(com.sequenceiq.cloudbreak.service.secret.model.SecretResponse) ServiceKeytabRequest(com.sequenceiq.freeipa.api.v1.kerberosmgmt.model.ServiceKeytabRequest) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Test(org.junit.jupiter.api.Test)

Example 20 with SecretResponse

use of com.sequenceiq.cloudbreak.service.secret.model.SecretResponse in project cloudbreak by hortonworks.

the class KerberosMgmtVaultComponentV1Test method testGetSecretResponseForKeytabWithService.

@Test
public void testGetSecretResponseForKeytabWithService() throws Exception {
    String expectedPath = "account1/ServiceKeytab/keytab/12345-6789/54321-9876/host1/service1";
    SecretResponse expectedSecretResponse = new SecretResponse();
    expectedSecretResponse.setEnginePath(ENGINE_PATH);
    expectedSecretResponse.setSecretPath(expectedPath);
    ServiceKeytabRequest serviceKeytabRequest = new ServiceKeytabRequest();
    serviceKeytabRequest.setEnvironmentCrn(ENVIRONMENT_ID);
    serviceKeytabRequest.setClusterCrn(CLUSTER_ID);
    serviceKeytabRequest.setServerHostName(HOST);
    serviceKeytabRequest.setServiceName(SERVICE);
    Mockito.when(secretService.put(anyString(), anyString())).thenReturn(SECRET);
    Mockito.when(stringToSecretResponseConverter.convert(anyString())).thenReturn(expectedSecretResponse);
    Assertions.assertEquals(expectedSecretResponse, underTest.getSecretResponseForKeytab(serviceKeytabRequest, ACCOUNT, KEYTAB));
    Mockito.verify(secretService).put(expectedPath, KEYTAB);
    Mockito.verify(stringToSecretResponseConverter).convert(SECRET);
}
Also used : SecretResponse(com.sequenceiq.cloudbreak.service.secret.model.SecretResponse) ServiceKeytabRequest(com.sequenceiq.freeipa.api.v1.kerberosmgmt.model.ServiceKeytabRequest) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Test(org.junit.jupiter.api.Test)

Aggregations

SecretResponse (com.sequenceiq.cloudbreak.service.secret.model.SecretResponse)27 Test (org.junit.jupiter.api.Test)14 Test (org.junit.Test)8 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)8 HostKeytabRequest (com.sequenceiq.freeipa.api.v1.kerberosmgmt.model.HostKeytabRequest)6 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)6 CloudbreakServiceException (com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException)4 Secret (com.sequenceiq.cloudbreak.service.secret.domain.Secret)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 Stack (com.sequenceiq.freeipa.entity.Stack)4 CredentialResponse (com.sequenceiq.environment.api.v1.credential.model.response.CredentialResponse)3 ProxyResponse (com.sequenceiq.environment.api.v1.proxy.model.response.ProxyResponse)3 RoleRequest (com.sequenceiq.freeipa.api.v1.kerberosmgmt.model.RoleRequest)3 DatabaseServerV4Response (com.sequenceiq.redbeams.api.endpoint.v4.databaseserver.responses.DatabaseServerV4Response)3 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)2 Cluster (com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster)2 ProxyConfig (com.sequenceiq.cloudbreak.dto.ProxyConfig)2