use of com.sequenceiq.cloudbreak.api.model.SecurityGroupRequest in project cloudbreak by hortonworks.
the class SecurityGroupV2RequestToSecurityGroupRequestConverter method convert.
@Override
public SecurityGroupRequest convert(SecurityGroupV2Request source) {
SecurityGroupRequest entity = new SecurityGroupRequest();
entity.setName(missingResourceNameGenerator.generateName(APIResourceType.SECURITY_GROUP));
entity.setSecurityGroupId(source.getSecurityGroupId());
if (source.getSecurityRules() != null) {
entity.setSecurityRules(source.getSecurityRules());
}
return entity;
}
use of com.sequenceiq.cloudbreak.api.model.SecurityGroupRequest 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);
}
Aggregations