public IterableWithMarker<SecurityGroup> expected() { return IterableWithMarkers.from( ImmutableSet.<SecurityGroup>builder() .add( SecurityGroup.builder() .ec2SecurityGroup( EC2SecurityGroup.builder() .status("authorized") .name("myec2securitygroup") .ownerId("054794666394") .build()) .description("default") .ipRange(IPRange.builder().cidrIp("127.0.0.1/30").status("authorized").build()) .ownerId("621567473609") .name("default") .vpcId("vpc-1ab2c3d4") .build()) .add( SecurityGroup.builder() .description("My new DBSecurityGroup") .ipRange( IPRange.builder().cidrIp("192.168.1.1/24").status("authorized").build()) .ownerId("621567473609") .name("mydbsecuritygroup") .vpcId("vpc-1ab2c3d5") .build()) .add( SecurityGroup.builder() .description("My new DBSecurityGroup") .ownerId("621567473609") .name("mydbsecuritygroup4") .vpcId("vpc-1ab2c3d6") .build()) .build()); }
@Test(dependsOnMethods = "testCreateSecurityGroup") protected void testAuthorizeIPRange() { securityGroup = api().authorizeIngressToIPRange(SECURITYGROUP, "0.0.0.0/0"); assertTrue(ipRangesAuthorized.apply(securityGroup), securityGroup.toString()); securityGroup = api().get(securityGroup.getName()); Logger.getAnonymousLogger().info("ip range authorized: " + securityGroup); }
public void testCreateSecurityGroup() { SecurityGroup newSecurityGroup = api().createWithNameAndDescription(SECURITYGROUP, "jclouds"); securityGroup = newSecurityGroup; Logger.getAnonymousLogger().info("created securityGroup: " + securityGroup); assertEquals(securityGroup.getName(), SECURITYGROUP); assertEquals(securityGroup.getDescription(), "jclouds"); checkSecurityGroup(newSecurityGroup); }
static void checkSecurityGroup(SecurityGroup securityGroup) { checkNotNull( securityGroup.getName(), "Name cannot be null for a SecurityGroup: %s", securityGroup); checkNotNull( securityGroup.getDescription(), "Description cannot be null for a SecurityGroup: %s", securityGroup); checkNotNull( securityGroup.getOwnerId(), "OwnerId cannot be null for a SecurityGroup: %s", securityGroup); checkNotNull( securityGroup.getVpcId(), "VpcId cannot be null for a SecurityGroup: %s", securityGroup); for (EC2SecurityGroup security : securityGroup.getEC2SecurityGroups()) { checkEC2SecurityGroup(security); } }
@Test protected void testDescribeSecurityGroups() { IterableWithMarker<SecurityGroup> response = api().list().get(0); for (SecurityGroup securityGroup : response) { checkSecurityGroup(securityGroup); } if (Iterables.size(response) > 0) { SecurityGroup securityGroup = response.iterator().next(); Assert.assertEquals(api().get(securityGroup.getName()), securityGroup); } // Test with a Marker, even if it's null response = api().list(ListSecurityGroupsOptions.Builder.afterMarker(response.nextMarker().orNull())); for (SecurityGroup securityGroup : response) { checkSecurityGroup(securityGroup); } }
@Test(dependsOnMethods = "testRevokeIPRange") public void testDeleteSecurityGroup() { api().delete(securityGroup.getName()); // TODO block and determine the state of a deleted securityGroup Logger.getAnonymousLogger().info("securityGroup deleted: " + securityGroup); }