Merge "Add VPNaaS related test cases"
[neutron.git] / integration / test / src / test / java / org / opendaylight / neutron / e2etest / NeutronSecurityRuleTests.java
1 /*
2  * Copyright (C) 2015 IBM, Inc.
3  *
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
7  */
8
9 package org.opendaylight.neutron.e2etest;
10
11 import java.io.OutputStreamWriter;
12
13 import java.lang.Thread;
14
15 import java.net.HttpURLConnection;
16 import java.net.URL;
17
18 import org.junit.Assert;
19
20 public class NeutronSecurityRuleTests {
21     String base;
22
23     public NeutronSecurityRuleTests(String base) {
24         this.base = base;
25     }
26
27     public void securityRule_collection_get_test() {
28         String url = base + "/security-group-rules";
29         ITNeutronE2E.test_fetch(url, "Security Rule Collection GET failed");
30     }
31
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");
44     }
45
46     public void sr_element_get_test() {
47         String url = base + "/security-group-rules/9b4be7fa-e56e-40fb-9516-1f0fa9185669";
48         ITNeutronE2E.test_fetch(url, true, "Security Rule Element Get Failed");
49     }
50
51     public void sr_delete_test() {
52         String url = base + "/security-group-rules/9b4be7fa-e56e-40fb-9516-1f0fa9185669";
53         ITNeutronE2E.test_delete(url, "Security Rule Delete Failed");
54     }
55
56     public void sr_element_negative_get_test() {
57         String url = base + "/security-group-rules/9b4be7fa-e56e-40fb-9516-1f0fa9185669";
58         ITNeutronE2E.test_fetch(url, false, "Security Rule Element Negative Get Failed");
59     }
60
61     public static void runTests(String base) {
62         NeutronSecurityRuleTests securityRule_tester = new NeutronSecurityRuleTests(base);
63         securityRule_tester.securityRule_collection_get_test();
64         securityRule_tester.singleton_sr_create_test();
65         securityRule_tester.sr_element_get_test();
66         securityRule_tester.sr_delete_test();
67         securityRule_tester.sr_element_negative_get_test();
68     }
69 }