use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.InstanceMetadataType.GATEWAY in project cloudbreak by hortonworks.
the class ClusterRequestToClusterConverterTest method testConvertWithCloudStorageDetails.
@Test
public void testConvertWithCloudStorageDetails() {
// GIVEN
ClusterV4Request request = getRequest("cluster-with-cloud-storage.json");
given(gatewayV4RequestToGatewayConverter.convert(request.getGateway())).willReturn(new Gateway());
given(cloudStorageConverter.requestToFileSystem(request.getCloudStorage())).willReturn(new FileSystem());
given(cloudStorageValidationUtil.isCloudStorageConfigured(request.getCloudStorage())).willReturn(true);
Blueprint blueprint = new Blueprint();
blueprint.setStackType(StackType.HDP.name());
given(blueprintService.getByNameForWorkspaceAndLoadDefaultsIfNecessary(eq("my-blueprint"), any())).willReturn(blueprint);
// WHEN
Cluster result = ThreadBasedUserCrnProvider.doAs(TEST_USER_CRN, () -> underTest.convert(request));
// THEN
assertAllFieldsNotNull(result, Arrays.asList("stack", "blueprint", "creationStarted", "creationFinished", "upSince", "statusReason", "clusterManagerIp", "additionalFileSystem", "rdsConfigs", "attributes", "uptime", "ambariSecurityMasterKey", "proxyConfigCrn", "extendedBlueprintText", "environmentCrn", "variant", "description", "databaseServerCrn", "fqdn", "configStrategy", "customConfigurations"));
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.InstanceMetadataType.GATEWAY in project cloudbreak by hortonworks.
the class ClusterToClusterV4ResponseConverterTest method testConvert.
@Test
public void testConvert() {
// GIVEN
getSource().setConfigStrategy(ConfigStrategy.NEVER_APPLY);
getSource().setBlueprint(new Blueprint());
getSource().setExtendedBlueprintText("asdf");
getSource().setFqdn("some.fqdn");
getSource().setCertExpirationState(CertExpirationState.HOST_CERT_EXPIRING);
given(stackUtil.extractClusterManagerIp(any(Stack.class))).willReturn("10.0.0.1");
given(stackUtil.extractClusterManagerAddress(any(Stack.class))).willReturn("some.fqdn");
Cluster source = getSource();
TestUtil.setSecretField(Cluster.class, "cloudbreakAmbariUser", source, "user", "secret/path");
TestUtil.setSecretField(Cluster.class, "cloudbreakAmbariPassword", source, "pass", "secret/path");
TestUtil.setSecretField(Cluster.class, "dpAmbariUser", source, "user", "secret/path");
TestUtil.setSecretField(Cluster.class, "dpAmbariPassword", source, "pass", "secret/path");
when(stringToSecretResponseConverter.convert("secret/path")).thenReturn(new SecretResponse("kv", "pass"));
when(blueprintToBlueprintV4ResponseConverter.convert(getSource().getBlueprint())).thenReturn(new BlueprintV4Response());
when(serviceEndpointCollector.getManagerServerUrl(any(Cluster.class), anyString())).thenReturn("http://server/");
given(proxyConfigDtoService.getByCrn(anyString())).willReturn(ProxyConfig.builder().withCrn("crn").withName("name").build());
// WHEN
ClusterV4Response result = underTest.convert(source);
// THEN
assertEquals(1L, (long) result.getId());
assertEquals(getSource().getExtendedBlueprintText(), result.getExtendedBlueprintText());
assertEquals(CertExpirationState.HOST_CERT_EXPIRING, result.getCertExpirationState());
List<String> skippedFields = Lists.newArrayList("customContainers", "cm", "creationFinished", "cloudStorage", "gateway", "customConfigurationsName", "customConfigurationsCrn");
assertAllFieldsNotNull(result, skippedFields);
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.InstanceMetadataType.GATEWAY in project cloudbreak by hortonworks.
the class ClusterRequestToGatewayConverterTest method testConvertNewTopologies.
@Test
public void testConvertNewTopologies() {
GatewayV4Request source = new GatewayV4Request();
GatewayTopologyV4Request topology1 = new GatewayTopologyV4Request();
topology1.setTopologyName("topology1");
source.setTopologies(Collections.singletonList(topology1));
Gateway result = underTest.convert(source);
assertFalse(result.getTopologies().isEmpty());
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.InstanceMetadataType.GATEWAY in project cloudbreak by hortonworks.
the class ClusterRequestToGatewayConverterTest method testConvertSsoType.
@Test
public void testConvertSsoType() {
GatewayV4Request source = new GatewayV4Request();
source.setTopologies(getTopologies());
Gateway result = underTest.convert(source);
assertEquals(SSOType.NONE, result.getSsoType());
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.InstanceMetadataType.GATEWAY in project cloudbreak by hortonworks.
the class ClusterRequestToGatewayConverterTest method testConvertBasicProperties.
@Test
public void testConvertBasicProperties() {
GatewayV4Request source = new GatewayV4Request();
source.setPath(PATH);
source.setSsoProvider(SSO_PROVIDER);
source.setSsoType(SSOType.SSO_PROVIDER);
source.setTokenCert(TOKEN_CERT);
source.setGatewayType(GatewayType.CENTRAL);
source.setTopologies(getTopologies());
Gateway result = underTest.convert(source);
assertEquals(SSOType.SSO_PROVIDER, result.getSsoType());
assertEquals(TOKEN_CERT, result.getTokenCert());
assertEquals(GatewayType.CENTRAL, result.getGatewayType());
}
Aggregations