use of com.sequenceiq.cloudbreak.cloud.aws.CloudFormationTemplateBuilder.RDSModelContext in project cloudbreak by hortonworks.
the class CloudFormationTemplateBuilderDBTest method buildTestWhenNoSecurityGroupAndNoPortAndMultipleCidr.
@ParameterizedTest(name = "{0}")
@MethodSource("templatesPathDataProvider")
void buildTestWhenNoSecurityGroupAndNoPortAndMultipleCidr(String templatePath) throws IOException {
// GIVEN
String awsCloudFormationTemplate = factoryBean.getObject().getTemplate(templatePath, "UTF-8").toString();
// WHEN
RDSModelContext modelContext = new RDSModelContext().withNetworkCidrs(List.of(CIDR_1, CIDR_2)).withTemplate(awsCloudFormationTemplate);
String result = cloudFormationTemplateBuilder.build(modelContext);
// THEN
assertThat(JsonUtil.isValid(result)).overridingErrorMessage("Invalid JSON: " + result).isTrue();
assertThat(result).doesNotContain("\"PortParameter\": {");
assertThat(result).doesNotContain("\"DBParameterGroupNameParameter\": {");
assertThat(result).doesNotContain("\"DBParameterGroupFamilyParameter\": {");
assertThat(result).doesNotContain("\"VPCSecurityGroupsParameter\": {");
assertThat(result).contains("\"DBSecurityGroupNameParameter\": {");
assertThat(result).contains("\"VPCIdParameter\": {");
assertThat(result).contains("\"VPCSecurityGroup\": {");
assertThat(result).contains("\"FromPort\": 5432,");
assertThat(result).contains("\"ToPort\" : 5432,");
assertThat(result).doesNotContain("\"FromPort\": { \"Ref\": \"PortParameter\" },");
assertThat(result).doesNotContain("\"ToPort\" : { \"Ref\": \"PortParameter\" },");
assertThat(result).contains(String.format("\"CidrIp\" : \"%s\"", CIDR_1));
assertThat(result).contains(String.format("\"CidrIp\" : \"%s\"", CIDR_2));
assertThat(result).doesNotContain("\"DBParameterGroup\": {");
assertThat(result).doesNotContain("\"DBParameterGroupName\": { \"Ref\": \"DBParameterGroup\" },");
assertThat(result).doesNotContain("\"Port\": { \"Ref\": \"PortParameter\" },");
assertThat(result).doesNotContain("\"VPCSecurityGroups\": { \"Ref\": \"VPCSecurityGroupsParameter\" }");
assertThat(result).contains("\"VPCSecurityGroups\": [{ \"Ref\": \"VPCSecurityGroup\" }]");
assertThat(result).doesNotContain("\"CreatedDBParameterGroup\": { \"Value\": { \"Ref\": \"DBParameterGroup\" } },");
}
use of com.sequenceiq.cloudbreak.cloud.aws.CloudFormationTemplateBuilder.RDSModelContext in project cloudbreak by hortonworks.
the class CloudFormationTemplateBuilderDBTest method buildTestWhenHavingSecurityGroupAndNoPortAndUsingSslEnforcementAndWithSslCertificateIdentifier.
@ParameterizedTest(name = "{0}")
@MethodSource("templatesPathDataProvider")
void buildTestWhenHavingSecurityGroupAndNoPortAndUsingSslEnforcementAndWithSslCertificateIdentifier(String templatePath) throws IOException {
// GIVEN
String awsCloudFormationTemplate = factoryBean.getObject().getTemplate(templatePath, "UTF-8").toString();
// WHEN
RDSModelContext modelContext = new RDSModelContext().withHasSecurityGroup(true).withUseSslEnforcement(true).withSslCertificateIdentifierDefined(true).withTemplate(awsCloudFormationTemplate);
String result = cloudFormationTemplateBuilder.build(modelContext);
// THEN
assertThat(JsonUtil.isValid(result)).overridingErrorMessage("Invalid JSON: " + result).isTrue();
assertThat(result).doesNotContain("\"PortParameter\": {");
assertThat(result).contains("\"DBParameterGroupNameParameter\": {");
assertThat(result).contains("\"DBParameterGroupFamilyParameter\": {");
assertThat(result).contains("\"SslCertificateIdentifierParameter\": {");
assertThat(result).contains("\"VPCSecurityGroupsParameter\": {");
assertThat(result).doesNotContain("\"DBSecurityGroupNameParameter\": {");
assertThat(result).doesNotContain("\"VPCIdParameter\": {");
assertThat(result).doesNotContain("\"VPCSecurityGroup\": {");
assertThat(result).doesNotContain("\"FromPort\"");
assertThat(result).doesNotContain("\"ToPort\"");
assertThat(result).doesNotContain("\"CidrIp\" :");
assertThat(result).contains("\"DBParameterGroup\": {");
assertThat(result).contains("\"Parameters\": { \"rds.force_ssl\": \"1\" },");
assertThat(result).contains("\"DBParameterGroupName\": { \"Ref\": \"DBParameterGroup\" },");
assertThat(result).contains("\"CACertificateIdentifier\": { \"Ref\": \"SslCertificateIdentifierParameter\" },");
assertThat(result).doesNotContain("\"Port\": { \"Ref\": \"PortParameter\" },");
assertThat(result).contains("\"VPCSecurityGroups\": { \"Ref\": \"VPCSecurityGroupsParameter\" }");
assertThat(result).doesNotContain("\"VPCSecurityGroups\": [{ \"Ref\": \"VPCSecurityGroup\" }]");
assertThat(result).contains("\"CreatedDBParameterGroup\": { \"Value\": { \"Ref\": \"DBParameterGroup\" } },");
}
Aggregations