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 public class NeutronSecurityRuleTests {
14 public NeutronSecurityRuleTests(String base) {
18 public void securityRule_collection_get_test() {
19 String url = base + "/security-group-rules";
20 ITNeutronE2E.test_fetch(url, "Security Rule Collection GET failed");
23 public String singleton_sr_create_test() {
24 String url = base + "/security-group-rules";
25 String content = " {\"security_group_rule\": " +
26 "{\"remote_group_id\": null, \"direction\": \"ingress\", " +
27 "\"remote_ip_prefix\": null, \"protocol\": \"tcp\", " +
28 "\"ethertype\": \"IPv6\", \"tenant_id\": " +
29 "\"00f340c7c3b34ab7be1fc690c05a0275\", \"port_range_max\": 77, " +
30 "\"port_range_min\": 77, " +
31 "\"id\": \"9b4be7fa-e56e-40fb-9516-1f0fa9185669\", " +
32 "\"security_group_id\": " +
33 "\"b60490fe-60a5-40be-af63-1d641381b784\"}}";
34 ITNeutronE2E.test_create(url, content, "Security Rule Singleton Post Failed");
38 public void singleton_sr_get_with_one_query_item_test(String createJsonString) {
39 String url = base + "/security-group-rules";
40 ITNeutronE2E.test_fetch_with_one_query_item(url, createJsonString, "security_group_rules");
43 public void multiple_sr_create_test() {
44 String url = base + "/security-group-rules";
45 String content = " {\"security_group_rules\": [" +
47 " \"id\": \"35fb0f34-c8d3-416d-a205-a2c75f7b8e22\"," +
48 " \"direction\": \"egress\"," +
49 " \"ethertype\": \"IPv6\"," +
50 " \"security_group_id\": \"70f1b157-e79b-44dc-85a8-7de0fc9f2aab\"," +
51 " \"tenant_id\": \"2640ee2ac2474bf3906e482047204fcb\"" +
54 " \"id\": \"63814eed-bc12-4fe4-8b17-2af178224c71\"," +
55 " \"direction\": \"egress\"," +
56 " \"ethertype\": \"IPv4\"," +
57 " \"security_group_id\": \"70f1b157-e79b-44dc-85a8-7de0fc9f2aab\"," +
58 " \"tenant_id\": \"2640ee2ac2474bf3906e482047204fcb\"" +
61 " \"id\": \"ccb9823e-559b-4d84-b656-2739f8e56d89\"," +
62 " \"direction\": \"ingress\"," +
63 " \"ethertype\": \"IPv6\"," +
64 " \"remote_group_id\": \"70f1b157-e79b-44dc-85a8-7de0fc9f2aab\"," +
65 " \"security_group_id\": \"70f1b157-e79b-44dc-85a8-7de0fc9f2aab\"," +
66 " \"tenant_id\": \"2640ee2ac2474bf3906e482047204fcb\"" +
69 " \"id\": \"fbc3f809-7378-40a4-822f-7a70f6ccba98\"," +
70 " \"direction\": \"ingress\"," +
71 " \"ethertype\": \"IPv4\"," +
72 " \"remote_group_id\": \"70f1b157-e79b-44dc-85a8-7de0fc9f2aab\"," +
73 " \"security_group_id\": \"70f1b157-e79b-44dc-85a8-7de0fc9f2aab\"," +
74 " \"tenant_id\": \"2640ee2ac2474bf3906e482047204fcb\"" +
77 ITNeutronE2E.test_create(url, content, "Security Rule Multiple Post Failed");
80 public void singleton_sr_modify_test() {
81 String url = base + "/security-group-rules/9b4be7fa-e56e-40fb-9516-1f0fa9185669";
82 String content = " {\"security_group_rule\": " +
83 "{\"remote_group_id\": null, \"direction\": \"egress\", " +
84 "\"remote_ip_prefix\": null, \"protocol\": \"tcp\", " +
85 "\"ethertype\": \"IPv6\", \"tenant_id\": " +
86 "\"00f340c7c3b34ab7be1fc690c05a0275\", \"port_range_max\": 77, " +
87 "\"port_range_min\": 77, " +
88 "\"id\": \"9b4be7fa-e56e-40fb-9516-1f0fa9185669\", " +
89 "\"security_group_id\": " +
90 "\"b60490fe-60a5-40be-af63-1d641381b784\"}}";
91 ITNeutronE2E.test_modify(url, content, "Security Rule Singleton Put Failed");
94 public void sr_element_get_test() {
95 String url = base + "/security-group-rules/9b4be7fa-e56e-40fb-9516-1f0fa9185669";
96 ITNeutronE2E.test_fetch(url, true, "Security Rule Element Get Failed");
99 public void sr_element_get_with_query_test() {
100 String url = base + "/security-group-rules/9b4be7fa-e56e-40fb-9516-1f0fa9185669" +
101 "?fields=id&fields=direction&fields=protocol&fields=port_range_min" +
102 "&fields=port_range_max&fields=ethertype&fields=remote_ip_prefix" +
103 "&fields=remote_group_id&fields=security_group_id&fields=tenant_id" +
104 "&fields=limit&fields=marker&fields=page_reverse";
105 ITNeutronE2E.test_fetch(url, true, "Security Rule Element Get With Query Failed");
108 public void sr_delete_test() {
109 String url = base + "/security-group-rules/9b4be7fa-e56e-40fb-9516-1f0fa9185669";
110 ITNeutronE2E.test_delete(url, "Security Rule Delete Failed");
113 public void sr_element_negative_get_test() {
114 String url = base + "/security-group-rules/9b4be7fa-e56e-40fb-9516-1f0fa9185669";
115 ITNeutronE2E.test_fetch(url, false, "Security Rule Element Negative Get Failed");
118 public void bug5478_rule_delete_negative_test() {
119 String url = base + "/security-group-rules/9b4be7fa-e56e-40fb-9516-1f0fa9185669";
120 ITNeutronE2E.test_delete_404(url, "Security Rule Delete 404 Failed");
123 public void bug4043_ipv4_test() {
124 String url = base + "/security-group-rules";
125 String content = " {\"security_group_rule\": " +
126 "{\"remote_group_id\": null, \"direction\": \"ingress\", " +
127 "\"remote_ip_prefix\": \"10.10.10.10/16\", \"protocol\": \"tcp\", " +
128 "\"ethertype\": \"IPv4\", \"tenant_id\": " +
129 "\"00f340c7c3b34ab7be1fc690c05a0275\", \"port_range_max\": 77, " +
130 "\"port_range_min\": 77, " +
131 "\"id\": \"01234567-0123-0123-0123-01234567890a\", " +
132 "\"security_group_id\": " +
133 "\"b60490fe-60a5-40be-af63-1d641381b784\"}}";
134 ITNeutronE2E.test_create(url, content, "Security Rule bug4043 IPv4 Failed");
136 url = url + "/01234567-0123-0123-0123-01234567890a";
137 ITNeutronE2E.test_delete(url, "Security Rule Delete Failed");
140 public void bug4043_ipv6_test() {
141 String url = base + "/security-group-rules";
142 String content = " {\"security_group_rule\": " +
143 "{\"remote_group_id\": null, \"direction\": \"ingress\", " +
144 "\"remote_ip_prefix\": \"fe80::1/10\", \"protocol\": \"tcp\", " +
145 "\"ethertype\": \"IPv6\", \"tenant_id\": " +
146 "\"00f340c7c3b34ab7be1fc690c05a0275\", \"port_range_max\": 77, " +
147 "\"port_range_min\": 77, " +
148 "\"id\": \"01234567-0123-0123-0123-01234567890a\", " +
149 "\"security_group_id\": " +
150 "\"b60490fe-60a5-40be-af63-1d641381b784\"}}";
151 ITNeutronE2E.test_create(url, content, "Security Rule Bug4043 IPv6 Failed");
153 url = url + "/01234567-0123-0123-0123-01234567890a";
154 ITNeutronE2E.test_delete(url, "Security Rule Delete Failed");
157 public static void runTests(String base) {
158 NeutronSecurityRuleTests securityRule_tester = new NeutronSecurityRuleTests(base);
159 String createJsonString = securityRule_tester.singleton_sr_create_test();
160 securityRule_tester.singleton_sr_get_with_one_query_item_test(createJsonString);
161 securityRule_tester.multiple_sr_create_test();
162 securityRule_tester.singleton_sr_modify_test();
163 securityRule_tester.sr_element_get_test();
164 securityRule_tester.sr_element_get_with_query_test();
165 securityRule_tester.securityRule_collection_get_test();
166 securityRule_tester.sr_delete_test();
167 securityRule_tester.sr_element_negative_get_test();
168 securityRule_tester.bug5478_rule_delete_negative_test();
169 securityRule_tester.bug4043_ipv4_test();
170 securityRule_tester.bug4043_ipv6_test();