@Test(groups = "live", dependsOnMethods = "testUpdateFirewall") public void testPatchFirewall() { FirewallOptions firewall = new FirewallOptions() .name(FIREWALL_NAME) .network(getNetworkUrl(FIREWALL_NETWORK_NAME)) .allowedRules(ImmutableList.of(Firewall.Rule.create("tcp", ImmutableList.of("22")), Firewall.Rule.create("tcp", ImmutableList.of("23")))) .addSourceRange("10.0.0.0/8") .addSourceTag("tag1") .addTargetTag("tag2"); assertOperationDoneSuccessfully(api().update(FIREWALL_NAME, firewall)); }
@Test(groups = "live", dependsOnMethods = "testPatchFirewall") public void testGetFirewall() { FirewallOptions patchedFirewall = new FirewallOptions() .name(FIREWALL_NAME) .network(getNetworkUrl(FIREWALL_NETWORK_NAME)) .allowedRules(ImmutableList.of(Firewall.Rule.create("tcp", ImmutableList.of("22")), Firewall.Rule.create("tcp", ImmutableList.of("23")))) .addSourceRange("10.0.0.0/8") .addSourceTag("tag1") .addTargetTag("tag2"); Firewall firewall = api().get(FIREWALL_NAME); assertNotNull(firewall); assertFirewallEquals(firewall, patchedFirewall); }
@Test(groups = "live", dependsOnMethods = "testInsertFirewall") public void testUpdateFirewall() { FirewallOptions firewall = new FirewallOptions() .name(FIREWALL_NAME) .network(getNetworkUrl(FIREWALL_NETWORK_NAME)) .addSourceRange("10.0.0.0/8") .addSourceTag("tag1") .addTargetTag("tag2") .allowedRules(ImmutableList.of(Firewall.Rule.create("tcp", ImmutableList.of("23")))); assertOperationDoneSuccessfully(api().update(FIREWALL_NAME, firewall)); }
@Test(groups = "live") public void testInsertFirewall() { // need to insert the network first assertOperationDoneSuccessfully(api.networks().createLegacy(FIREWALL_NETWORK_NAME, IPV4_RANGE)); FirewallOptions firewall = new FirewallOptions() .addAllowedRule(Firewall.Rule.create("tcp", ImmutableList.of("22"))) .addSourceRange("10.0.0.0/8") .addSourceTag("tag1") .addTargetTag("tag2"); assertOperationDoneSuccessfully( api().createInNetwork(FIREWALL_NAME, getNetworkUrl(FIREWALL_NETWORK_NAME), firewall)); }
public void insert() throws Exception { server.enqueue(jsonResponse("/operation.json")); FirewallOptions options = new FirewallOptions() .addAllowedRule(Firewall.Rule.create("tcp", ImmutableList.of("22", "23-24"))) .addSourceTag("tag1") .addSourceRange("10.0.1.0/32") .addTargetTag("tag2"); assertEquals(firewallApi().createInNetwork("myfw", URI.create(url("/projects/party/global/networks/default")), options), new ParseOperationTest().expected(url("/projects"))); assertSent(server, "POST", "/projects/party/global/firewalls", stringFromResource("/firewall_insert.json")); }
public void update() throws Exception { server.enqueue(jsonResponse("/operation.json")); FirewallOptions options = new FirewallOptions() .name("myfw") .network(URI.create(url("/projects/party/global/networks/default"))) .addAllowedRule(Firewall.Rule.create("tcp", ImmutableList.of("22", "23-24"))) .addSourceTag("tag1") .addSourceRange("10.0.1.0/32") .addTargetTag("tag2"); assertEquals(firewallApi().update("myfw", options), new ParseOperationTest().expected(url("/projects"))); assertSent(server, "PUT", "/projects/party/global/firewalls/myfw", stringFromResource("/firewall_insert.json")); }
public void patch() throws Exception { server.enqueue(jsonResponse("/operation.json")); FirewallOptions options = new FirewallOptions() .name("myfw") .network(URI.create(url("/projects/party/global/networks/default"))) .addAllowedRule(Firewall.Rule.create("tcp", ImmutableList.of("22", "23-24"))) .addSourceTag("tag1") .addSourceRange("10.0.1.0/32") .addTargetTag("tag2"); assertEquals(firewallApi().patch("myfw", options), new ParseOperationTest().expected(url("/projects"))); assertSent(server, "PATCH", "/projects/party/global/firewalls/myfw", stringFromResource("/firewall_insert.json")); }