builder.ipProtocol(IpProtocol.TCP);
builder.fromPort(22);
builder.toPort(40);
builder.cidrBlock("0.0.0.0/0");
IpPermission perm = builder.build();
SecurityGroupExtension extension = requestsSendResponses(requestResponseMap.build()).getSecurityGroupExtension().get();
SecurityGroupBuilder groupBuilder = new SecurityGroupBuilder();
groupBuilder.id("us-east-1/sg-3c6ef654");
groupBuilder.providerId("sg-3c6ef654");
groupBuilder.name("jclouds#some-group");
groupBuilder.location(new LocationBuilder()
.scope(LocationScope.REGION)
.id(region)
.description("region")
.build());
SecurityGroup origGroup = groupBuilder.build();
SecurityGroup newGroup = extension.addIpPermission(perm, origGroup);
assertEquals(1, newGroup.getIpPermissions().size());
IpPermission newPerm = Iterables.getOnlyElement(newGroup.getIpPermissions());
assertNotNull(newPerm);
assertEquals(IpProtocol.TCP, newPerm.getIpProtocol());
assertEquals(22, newPerm.getFromPort());
assertEquals(40, newPerm.getToPort());
assertEquals(1, newPerm.getCidrBlocks().size());
assertTrue(newPerm.getCidrBlocks().contains("0.0.0.0/0"));
}