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();
}
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());
}
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);
}
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);
}
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);
}
Aggregations