use of com.sequenceiq.cloudbreak.api.model.SecurityRuleRequest in project cloudbreak by hortonworks.
the class SecurityGroupToSecurityGroupResponseConverterTest method testConvert.
@Test
public void testConvert() {
// GIVEN
given(conversionService.convert(any(Object.class), any(TypeDescriptor.class), any(TypeDescriptor.class))).willReturn(new ArrayList<SecurityRuleRequest>());
// WHEN
SecurityGroupResponse result = underTest.convert(getSource());
// THEN
assertAllFieldsNotNull(result, Arrays.asList("owner", "account"));
}
use of com.sequenceiq.cloudbreak.api.model.SecurityRuleRequest in project cloudbreak by hortonworks.
the class SecurityRuleToSecurityRuleRequestConverter method convert.
@Override
public SecurityRuleRequest convert(SecurityRule source) {
SecurityRuleRequest securityRuleRequest = new SecurityRuleRequest();
StringBuilder sb = new StringBuilder();
for (String portDefinition : source.getPorts()) {
sb.append(String.format("%s,", portDefinition));
}
securityRuleRequest.setPorts(sb.toString().substring(0, sb.toString().length() - 1));
securityRuleRequest.setProtocol(source.getProtocol());
securityRuleRequest.setSubnet(source.getCidr());
return securityRuleRequest;
}
use of com.sequenceiq.cloudbreak.api.model.SecurityRuleRequest in project cloudbreak by hortonworks.
the class SecurityGroupCreationTest method testSecurityGroupCreation.
@Test
@Parameters({ "name", "ports", "provider" })
public void testSecurityGroupCreation(@Optional("it-restricted-ambari") String name, @Optional("22,443,9443,8080") String ports, @Optional("MOCK") String provider) {
// GIVEN
// WHEN
SecurityGroupRequest securityGroupRequest = new SecurityGroupRequest();
securityGroupRequest.setDescription("Security group created by IT");
securityGroupRequest.setName(name);
SecurityRuleRequest securityRuleRequest = new SecurityRuleRequest("");
securityRuleRequest.setProtocol("tcp");
securityRuleRequest.setSubnet("0.0.0.0/0");
securityRuleRequest.setPorts(ports);
securityGroupRequest.setSecurityRules(Collections.singletonList(securityRuleRequest));
securityGroupRequest.setCloudPlatform(provider);
String id = getCloudbreakClient().securityGroupEndpoint().postPrivate(securityGroupRequest).getId().toString();
// THEN
Assert.assertNotNull(id);
getItContext().putContextParam(CloudbreakITContextConstants.SECURITY_GROUP_ID, id, true);
}
use of com.sequenceiq.cloudbreak.api.model.SecurityRuleRequest in project cloudbreak by hortonworks.
the class InstanceGroupV2PreparationTest method createSecurityRequest.
@BeforeMethod(dependsOnGroups = "igRequestCreation")
@Parameters({ "group", "securityRules" })
public void createSecurityRequest(String group, String securityRules) {
IntegrationTestContext itContext = getItContext();
Map<String, InstanceGroupV2Request> igMap = itContext.getContextParam(CloudbreakV2Constants.INSTANCEGROUP_MAP, Map.class);
InstanceGroupV2Request instanceGroupV2Request = igMap.get(group);
SecurityGroupV2Request securityGroupV2Request = new SecurityGroupV2Request();
List<String[]> secRules = templateAdditionHelper.parseCommaSeparatedRows(securityRules);
List<SecurityRuleRequest> secRulesRequests = Lists.newArrayList();
for (String[] secRule : secRules) {
SecurityRuleRequest securityRuleRequest = new SecurityRuleRequest();
securityRuleRequest.setProtocol(secRule[0]);
securityRuleRequest.setSubnet(secRule[1]);
securityRuleRequest.setPorts(secRule[2]);
secRulesRequests.add(securityRuleRequest);
}
securityGroupV2Request.setSecurityRules(secRulesRequests);
instanceGroupV2Request.setSecurityGroup(securityGroupV2Request);
}
use of com.sequenceiq.cloudbreak.api.model.SecurityRuleRequest in project cloudbreak by hortonworks.
the class CloudProviderHelper method rules.
List<SecurityRuleRequest> rules() {
List<SecurityRuleRequest> rules = new ArrayList<>();
SecurityRuleRequest a = new SecurityRuleRequest();
a.setSubnet("0.0.0.0/0");
a.setProtocol("tcp");
a.setPorts("22,443,8443,9443,8080");
rules.add(a);
return rules;
}
Aggregations