2 * Copyright (C) 2015 IBM, Inc.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
9 package org.opendaylight.neutron.e2etest;
11 import java.io.OutputStreamWriter;
13 import java.lang.Thread;
15 import java.net.HttpURLConnection;
18 import org.junit.Assert;
20 public class NeutronSecurityRuleTests {
23 public NeutronSecurityRuleTests(String base) {
27 public void securityRule_collection_get_test() {
28 String url = base + "/security-group-rules";
29 ITNeutronE2E.test_fetch(url, "Security Rule Collection GET failed");
32 public void singleton_sr_create_test() {
33 String url = base + "/security-group-rules";
34 String content = " {\"security_group_rule\": " +
35 "{\"remote_group_id\": null, \"direction\": \"ingress\", " +
36 "\"remote_ip_prefix\": null, \"protocol\": \"tcp\", " +
37 "\"ethertype\": \"IPv6\", \"tenant_id\": " +
38 "\"00f340c7c3b34ab7be1fc690c05a0275\", \"port_range_max\": 77, " +
39 "\"port_range_min\": 77, " +
40 "\"id\": \"9b4be7fa-e56e-40fb-9516-1f0fa9185669\", " +
41 "\"security_group_id\": " +
42 "\"b60490fe-60a5-40be-af63-1d641381b784\"}}";
43 ITNeutronE2E.test_create(url, content, "Security Rule Singleton Post Failed");
46 public void multiple_sr_create_test() {
47 String url = base + "/security-group-rules";
48 String content = " {\"security_group_rules\": [" +
50 " \"id\": \"35fb0f34-c8d3-416d-a205-a2c75f7b8e22\"," +
51 " \"direction\": \"egress\"," +
52 " \"ethertype\": \"IPv6\"," +
53 " \"security_group_id\": \"70f1b157-e79b-44dc-85a8-7de0fc9f2aab\"," +
54 " \"tenant_id\": \"2640ee2ac2474bf3906e482047204fcb\"" +
57 " \"id\": \"63814eed-bc12-4fe4-8b17-2af178224c71\"," +
58 " \"direction\": \"egress\"," +
59 " \"ethertype\": \"IPv4\"," +
60 " \"security_group_id\": \"70f1b157-e79b-44dc-85a8-7de0fc9f2aab\"," +
61 " \"tenant_id\": \"2640ee2ac2474bf3906e482047204fcb\"" +
64 " \"id\": \"ccb9823e-559b-4d84-b656-2739f8e56d89\"," +
65 " \"direction\": \"ingress\"," +
66 " \"ethertype\": \"IPv6\"," +
67 " \"remote_group_id\": \"70f1b157-e79b-44dc-85a8-7de0fc9f2aab\"," +
68 " \"security_group_id\": \"70f1b157-e79b-44dc-85a8-7de0fc9f2aab\"," +
69 " \"tenant_id\": \"2640ee2ac2474bf3906e482047204fcb\"" +
72 " \"id\": \"fbc3f809-7378-40a4-822f-7a70f6ccba98\"," +
73 " \"direction\": \"ingress\"," +
74 " \"ethertype\": \"IPv4\"," +
75 " \"remote_group_id\": \"70f1b157-e79b-44dc-85a8-7de0fc9f2aab\"," +
76 " \"security_group_id\": \"70f1b157-e79b-44dc-85a8-7de0fc9f2aab\"," +
77 " \"tenant_id\": \"2640ee2ac2474bf3906e482047204fcb\"" +
80 ITNeutronE2E.test_create(url, content, "Security Rule Multiple Post Failed");
83 public void sr_element_get_test() {
84 String url = base + "/security-group-rules/9b4be7fa-e56e-40fb-9516-1f0fa9185669";
85 ITNeutronE2E.test_fetch(url, true, "Security Rule Element Get Failed");
88 public void sr_delete_test() {
89 String url = base + "/security-group-rules/9b4be7fa-e56e-40fb-9516-1f0fa9185669";
90 ITNeutronE2E.test_delete(url, "Security Rule Delete Failed");
93 public void sr_element_negative_get_test() {
94 String url = base + "/security-group-rules/9b4be7fa-e56e-40fb-9516-1f0fa9185669";
95 ITNeutronE2E.test_fetch(url, false, "Security Rule Element Negative Get Failed");
98 public void bug4043_ipv4_test() {
99 String url = base + "/security-group-rules";
100 String content = " {\"security_group_rule\": " +
101 "{\"remote_group_id\": null, \"direction\": \"ingress\", " +
102 "\"remote_ip_prefix\": \"10.10.10.10/16\", \"protocol\": \"tcp\", " +
103 "\"ethertype\": \"IPv4\", \"tenant_id\": " +
104 "\"00f340c7c3b34ab7be1fc690c05a0275\", \"port_range_max\": 77, " +
105 "\"port_range_min\": 77, " +
106 "\"id\": \"01234567-0123-0123-0123-01234567890a\", " +
107 "\"security_group_id\": " +
108 "\"b60490fe-60a5-40be-af63-1d641381b784\"}}";
109 ITNeutronE2E.test_create(url, content, "Security Rule bug4043 IPv4 Failed");
111 url = url + "/01234567-0123-0123-0123-01234567890a";
112 ITNeutronE2E.test_delete(url, "Security Rule Delete Failed");
115 public void bug4043_ipv6_test() {
116 String url = base + "/security-group-rules";
117 String content = " {\"security_group_rule\": " +
118 "{\"remote_group_id\": null, \"direction\": \"ingress\", " +
119 "\"remote_ip_prefix\": \"fe80::1/10\", \"protocol\": \"tcp\", " +
120 "\"ethertype\": \"IPv6\", \"tenant_id\": " +
121 "\"00f340c7c3b34ab7be1fc690c05a0275\", \"port_range_max\": 77, " +
122 "\"port_range_min\": 77, " +
123 "\"id\": \"01234567-0123-0123-0123-01234567890a\", " +
124 "\"security_group_id\": " +
125 "\"b60490fe-60a5-40be-af63-1d641381b784\"}}";
126 ITNeutronE2E.test_create(url, content, "Security Rule Bug4043 IPv6 Failed");
128 url = url + "/01234567-0123-0123-0123-01234567890a";
129 ITNeutronE2E.test_delete(url, "Security Rule Delete Failed");
132 public static void runTests(String base) {
133 NeutronSecurityRuleTests securityRule_tester = new NeutronSecurityRuleTests(base);
134 securityRule_tester.securityRule_collection_get_test();
135 securityRule_tester.singleton_sr_create_test();
136 securityRule_tester.multiple_sr_create_test();
137 securityRule_tester.sr_element_get_test();
138 securityRule_tester.sr_delete_test();
139 securityRule_tester.sr_element_negative_get_test();
140 securityRule_tester.bug4043_ipv4_test();
141 securityRule_tester.bug4043_ipv6_test();