@Override public boolean apply(Rule input) { return RuleDirection.INGRESS.equals(input.getDirection()); } })), 1);
assertEquals(rule.getPortRangeMax().intValue(), 90); assertEquals(rule.getPortRangeMin().intValue(), 80); assertEquals(rule.getDirection(), RuleDirection.INGRESS); } finally { if (sgApi != null) {
public void testGetSecurityGroupRule() throws IOException, InterruptedException, URISyntaxException { MockWebServer server = mockOpenStackServer(); server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json")))); server.enqueue(addCommonHeaders( new MockResponse().setResponseCode(201).setBody(stringFromResource("/security_group_rule_get_response.json")))); try { NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides); SecurityGroupApi api = neutronApi.getSecurityGroupApi("RegionOne"); Rule rule = api.get("12345"); /* * Check request */ assertEquals(server.getRequestCount(), 2); assertAuthentication(server); assertRequest(server.takeRequest(), "GET", uriApiVersion + "/security-group-rules/12345"); /* * Check response */ assertNotNull(rule); assertEquals(rule.getDirection(), RuleDirection.EGRESS); assertEquals(rule.getEthertype(), RuleEthertype.IPV6); assertEquals(rule.getId(), "3c0e45ff-adaf-4124-b083-bf390e5482ff"); assertEquals(rule.getTenantId(), "e4f50856753b4dc6afee5fa6b9b6c550"); assertEquals(rule.getSecurityGroupId(), "85cc3048-abc3-43cc-89b3-377341426ac5"); } finally { server.shutdown(); } }
assertEquals(rule.getId(), "2bc0accf-312e-429a-956e-e4407625eb62"); assertEquals(rule.getTenantId(), "e4f50856753b4dc6afee5fa6b9b6c550"); assertEquals(rule.getDirection(), RuleDirection.INGRESS); assertEquals(rule.getPortRangeMax().intValue(), 80); assertEquals(rule.getPortRangeMin().intValue(), 80);
@Override public IpPermission apply(Rule from) { if (from.getDirection() == RuleDirection.EGRESS) return null; IpPermission.Builder builder = IpPermission.builder(); if (from.getProtocol() != null) { builder.ipProtocol(IpProtocol.fromValue(from.getProtocol().name())); } else { builder.ipProtocol(IpProtocol.TCP); } if (from.getPortRangeMin() != null) builder.fromPort(from.getPortRangeMin()); if (from.getPortRangeMax() != null) builder.toPort(from.getPortRangeMax()); if (from.getRemoteGroupId() != null) { builder.groupId(regionId + "/" + from.getRemoteGroupId()); } else if (from.getRemoteIpPrefix() != null){ builder.cidrBlock(from.getRemoteIpPrefix()); } return builder.build(); } }), Predicates.notNull()));
@Override public IpPermission apply(Rule from) { if (from.getDirection() == RuleDirection.EGRESS) return null; IpPermission.Builder builder = IpPermission.builder(); if (from.getProtocol() != null) { builder.ipProtocol(IpProtocol.fromValue(from.getProtocol().name())); } else { builder.ipProtocol(IpProtocol.TCP); } if (from.getPortRangeMin() != null) builder.fromPort(from.getPortRangeMin()); if (from.getPortRangeMax() != null) builder.toPort(from.getPortRangeMax()); if (from.getRemoteGroupId() != null) { builder.groupId(regionId + "/" + from.getRemoteGroupId()); } else if (from.getRemoteIpPrefix() != null){ builder.cidrBlock(from.getRemoteIpPrefix()); } return builder.build(); } }), Predicates.notNull()));