HttpResponse getWithRuleResponse = HttpResponse.builder().statusCode(200)
.payload(payloadFromResource("/getsecuritygroupresponse_extension_byid_with_group.json"))
.build();
SecurityGroupExtension extension = orderedRequestsSendResponses(
ImmutableList.of(addRule, queryAsyncJobResultAuthorizeIngress, getWithRule),
ImmutableList.of(addRuleResponse, queryAsyncJobResultAuthorizeIngressResponse, getWithRuleResponse)
).getSecurityGroupExtension().get();
IpPermission.Builder builder = IpPermission.builder();
builder.ipProtocol(IpProtocol.TCP);
builder.fromPort(22);
builder.toPort(22);
builder.tenantIdGroupNamePair("adrian", "adriancole");
IpPermission perm = builder.build();
SecurityGroup origGroup = new SecurityGroupBuilder().id("13").build();
SecurityGroup newGroup = extension.addIpPermission(perm, origGroup);
assertEquals(1, newGroup.getIpPermissions().size());
IpPermission newPerm = Iterables.getOnlyElement(newGroup.getIpPermissions());