2  * ============LICENSE_START=======================================================
 
   4  * ================================================================================
 
   5  * Copyright (C) 2017 AT&T Intellectual Property. All rights
 
   7  * ================================================================================
 
   8  * Licensed under the Apache License, Version 2.0 (the "License");
 
   9  * you may not use this file except in compliance with the License.
 
  10  * You may obtain a copy of the License at
 
  12  *      http://www.apache.org/licenses/LICENSE-2.0
 
  14  * Unless required by applicable law or agreed to in writing, software
 
  15  * distributed under the License is distributed on an "AS IS" BASIS,
 
  16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 
  17  * See the License for the specific language governing permissions and
 
  18  * limitations under the License.
 
  19  * ============LICENSE_END=========================================================
 
  22 package jtest.org.onap.ccsdk.sli.plugins.restapicall;
 
  25 import java.util.HashMap;
 
  28 import org.glassfish.jersey.grizzly2.httpserver.GrizzlyHttpServerFactory;
 
  29 import org.glassfish.jersey.media.multipart.MultiPartFeature;
 
  30 import org.junit.Test;
 
  31 import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
 
  32 import org.onap.ccsdk.sli.core.sli.SvcLogicException;
 
  33 import org.onap.ccsdk.sli.plugins.restapicall.RestapiCallNode;
 
  34 import org.slf4j.Logger;
 
  35 import org.slf4j.LoggerFactory;
 
  36 import org.glassfish.jersey.server.ResourceConfig;
 
  38 import static org.hamcrest.MatcherAssert.assertThat;
 
  39 import static org.hamcrest.core.Is.is;
 
  41 public class TestRestapiCallNode {
 
  43     private static final Logger log = LoggerFactory.getLogger(TestRestapiCallNode.class);
 
  47     public void testDelete() throws SvcLogicException {
 
  48         SvcLogicContext ctx = new SvcLogicContext();
 
  50         Map<String, String> p = new HashMap<String, String>();
 
  51         p.put("restapiUrl", "https://echo.getpostman.com/delete");
 
  52         p.put("restapiUser", "user1");
 
  53         p.put("restapiPassword", "pwd1");
 
  54         p.put("httpMethod", "delete");
 
  55         p.put("skipSending", "true");
 
  57         RestapiCallNode rcn = new RestapiCallNode();
 
  58         rcn.sendRequest(p, ctx);
 
  62     public void testJsonSdwanVpnTopologyTemplate() throws SvcLogicException {
 
  63         SvcLogicContext ctx = new SvcLogicContext();
 
  65         ctx.setAttribute("prop.topology", "topoType");
 
  67         ctx.setAttribute("prop.roles_length", "1");
 
  68         ctx.setAttribute("prop.roles[0]", "role1");
 
  70         ctx.setAttribute("prop.siteAttachement_length", "2");
 
  72         ctx.setAttribute("prop.siteAttachement[0].siteId", "site1");
 
  73         ctx.setAttribute("prop.siteAttachement[0].roles_length", "0");
 
  74         ctx.setAttribute("prop.siteAttachement[0].roles[0]", "role1");
 
  75         ctx.setAttribute("prop.siteAttachement[0].roles[1]", "role3");
 
  77         ctx.setAttribute("prop.siteAttachement[1].siteId", "site2");
 
  78         ctx.setAttribute("prop.siteAttachement[1].roles_length", "1");
 
  79         ctx.setAttribute("prop.siteAttachement[1].roles[0]", "role2");
 
  81         Map<String, String> p = new HashMap<String, String>();
 
  82         p.put("templateFileName", "src/test/resources/sdwan-vpn-topology.json");
 
  83         p.put("restapiUrl", "http://echo.getpostman.com");
 
  84         p.put("restapiUser", "user1");
 
  85         p.put("restapiPassword", "abc123");
 
  86         p.put("format", "json");
 
  87         p.put("httpMethod", "post");
 
  88         p.put("responsePrefix", "response");
 
  89         p.put("skipSending", "true");
 
  91         RestapiCallNode rcn = new RestapiCallNode();
 
  92         rcn.sendRequest(p, ctx);
 
  96     public void testJsonSdwanSiteTemplate() throws SvcLogicException {
 
  97         SvcLogicContext ctx = new SvcLogicContext();
 
  99         ctx.setAttribute("prop.name", "site1");
 
 102         Map<String, String> p = new HashMap<String, String>();
 
 103         p.put("templateFileName", "src/test/resources/sdwan-site.json");
 
 104         p.put("restapiUrl", "http://echo.getpostman.com");
 
 105         p.put("restapiUser", "user1");
 
 106         p.put("restapiPassword", "abc123");
 
 107         p.put("format", "json");
 
 108         p.put("httpMethod", "post");
 
 109         p.put("responsePrefix", "response");
 
 110         p.put("skipSending", "true");
 
 112         RestapiCallNode rcn = new RestapiCallNode();
 
 113         rcn.sendRequest(p, ctx);
 
 117     public void testJsonTemplate() throws SvcLogicException {
 
 118         SvcLogicContext ctx = new SvcLogicContext();
 
 119         ctx.setAttribute("tmp.sdn-circuit-req-row_length", "3");
 
 120         ctx.setAttribute("tmp.sdn-circuit-req-row[0].source-uid", "APIDOC-123");
 
 121         ctx.setAttribute("tmp.sdn-circuit-req-row[0].action", "delete");
 
 122         ctx.setAttribute("tmp.sdn-circuit-req-row[0].request-timestamp", "2016-09-09 16:30:35.0");
 
 123         ctx.setAttribute("tmp.sdn-circuit-req-row[0].request-status", "New");
 
 124         ctx.setAttribute("tmp.sdn-circuit-req-row[0].processing-status", "New");
 
 125         ctx.setAttribute("tmp.sdn-circuit-req-row[0].service-clfi", "testClfi1");
 
 126         ctx.setAttribute("tmp.sdn-circuit-req-row[0].clci", "clci");
 
 127         ctx.setAttribute("tmp.sdn-circuit-req-row[1].source-uid", "APIDOC-123");
 
 128         ctx.setAttribute("tmp.sdn-circuit-req-row[1].action", "delete");
 
 129         ctx.setAttribute("tmp.sdn-circuit-req-row[1].request-timestamp", "2016-09-09 16:30:35.0");
 
 130         ctx.setAttribute("tmp.sdn-circuit-req-row[1].request-status", "New");
 
 131         ctx.setAttribute("tmp.sdn-circuit-req-row[1].processing-status", "New");
 
 132         ctx.setAttribute("tmp.sdn-circuit-req-row[1].service-clfi", "testClfi1");
 
 133         ctx.setAttribute("tmp.sdn-circuit-req-row[1].clci", "clci");
 
 134         ctx.setAttribute("tmp.sdn-circuit-req-row[2].source-uid", "APIDOC-123");
 
 135         ctx.setAttribute("tmp.sdn-circuit-req-row[2].action", "delete");
 
 136         ctx.setAttribute("tmp.sdn-circuit-req-row[2].request-timestamp", "2016-09-09 16:30:35.0");
 
 137         ctx.setAttribute("tmp.sdn-circuit-req-row[2].request-status", "New");
 
 138         ctx.setAttribute("tmp.sdn-circuit-req-row[2].processing-status", "New");
 
 139         ctx.setAttribute("tmp.sdn-circuit-req-row[2].service-clfi", "testClfi1");
 
 140         ctx.setAttribute("tmp.sdn-circuit-req-row[2].clci", "clci");
 
 142         Map<String, String> p = new HashMap<String, String>();
 
 143         p.put("templateFileName", "src/test/resources/test-template.json");
 
 144         p.put("restapiUrl", "http://echo.getpostman.com");
 
 145         p.put("restapiUser", "user1");
 
 146         p.put("restapiPassword", "abc123");
 
 147         p.put("format", "json");
 
 148         p.put("httpMethod", "post");
 
 149         p.put("responsePrefix", "response");
 
 150         p.put("skipSending", "true");
 
 152         RestapiCallNode rcn = new RestapiCallNode();
 
 153         rcn.sendRequest(p, ctx);
 
 157     public void testInvalidRepeatTimes() throws SvcLogicException {
 
 158         SvcLogicContext ctx = new SvcLogicContext();
 
 159         ctx.setAttribute("tmp.sdn-circuit-req-row_length", "a");
 
 160         ctx.setAttribute("tmp.sdn-circuit-req-row[0].source-uid", "APIDOC-123");
 
 161         ctx.setAttribute("tmp.sdn-circuit-req-row[0].action", "delete");
 
 162         ctx.setAttribute("tmp.sdn-circuit-req-row[0].request-timestamp", "2016-09-09 16:30:35.0");
 
 163         ctx.setAttribute("tmp.sdn-circuit-req-row[0].request-status", "New");
 
 164         ctx.setAttribute("tmp.sdn-circuit-req-row[0].processing-status", "New");
 
 165         ctx.setAttribute("tmp.sdn-circuit-req-row[0].service-clfi", "testClfi1");
 
 166         ctx.setAttribute("tmp.sdn-circuit-req-row[0].clci", "clci");
 
 168         Map<String, String> p = new HashMap<String, String>();
 
 169         p.put("templateFileName", "src/test/resources/test-template.json");
 
 170         p.put("restapiUrl", "http://echo.getpostman.com");
 
 171         p.put("restapiUser", "user1");
 
 172         p.put("restapiPassword", "abc123");
 
 173         p.put("format", "json");
 
 174         p.put("httpMethod", "post");
 
 175         p.put("responsePrefix", "response");
 
 176         p.put("skipSending", "true");
 
 178         RestapiCallNode rcn = new RestapiCallNode();
 
 179         rcn.sendRequest(p, ctx);
 
 182     @Test(expected = SvcLogicException.class)
 
 183     public void testInvalidTemplatePath() throws SvcLogicException {
 
 184         SvcLogicContext ctx = new SvcLogicContext();
 
 185         ctx.setAttribute("tmp.sdn-circuit-req-row_length", "1");
 
 186         ctx.setAttribute("tmp.sdn-circuit-req-row[0].source-uid", "APIDOC-123");
 
 187         ctx.setAttribute("tmp.sdn-circuit-req-row[0].action", "delete");
 
 188         ctx.setAttribute("tmp.sdn-circuit-req-row[0].request-timestamp", "2016-09-09 16:30:35.0");
 
 189         ctx.setAttribute("tmp.sdn-circuit-req-row[0].request-status", "New");
 
 190         ctx.setAttribute("tmp.sdn-circuit-req-row[0].processing-status", "New");
 
 191         ctx.setAttribute("tmp.sdn-circuit-req-row[0].service-clfi", "testClfi1");
 
 192         ctx.setAttribute("tmp.sdn-circuit-req-row[0].clci", "clci");
 
 194         Map<String, String> p = new HashMap<String, String>();
 
 195         p.put("templateFileName", "src/test/resourcess/test-template.json");
 
 196         p.put("restapiUrl", "http://echo.getpostman.com");
 
 197         p.put("restapiUser", "user1");
 
 198         p.put("restapiPassword", "abc123");
 
 199         p.put("format", "json");
 
 200         p.put("httpMethod", "post");
 
 201         p.put("responsePrefix", "response");
 
 202         p.put("skipSending", "true");
 
 204         RestapiCallNode rcn = new RestapiCallNode();
 
 205         rcn.sendRequest(p, ctx);
 
 208     @Test(expected = SvcLogicException.class)
 
 209     public void testWithoutSkipSending() throws SvcLogicException {
 
 210         SvcLogicContext ctx = new SvcLogicContext();
 
 211         ctx.setAttribute("tmp.sdn-circuit-req-row_length", "1");
 
 212         ctx.setAttribute("tmp.sdn-circuit-req-row[0].source-uid", "APIDOC-123");
 
 213         ctx.setAttribute("tmp.sdn-circuit-req-row[0].action", "delete");
 
 214         ctx.setAttribute("tmp.sdn-circuit-req-row[0].request-timestamp", "2016-09-09 16:30:35.0");
 
 215         ctx.setAttribute("tmp.sdn-circuit-req-row[0].request-status", "New");
 
 216         ctx.setAttribute("tmp.sdn-circuit-req-row[0].processing-status", "New");
 
 217         ctx.setAttribute("tmp.sdn-circuit-req-row[0].service-clfi", "testClfi1");
 
 218         ctx.setAttribute("tmp.sdn-circuit-req-row[0].clci", "clci");
 
 220         Map<String, String> p = new HashMap<String, String>();
 
 221         p.put("templateFileName", "src/test/resources/test-template.json");
 
 222         p.put("restapiUrl", "http://echo.getpostman.com");
 
 223         p.put("restapiUser", "user1");
 
 224         p.put("restapiPassword", "abc123");
 
 225         p.put("format", "json");
 
 226         p.put("httpMethod", "post");
 
 227         p.put("responsePrefix", "response");
 
 228         p.put("skipSending", "false");
 
 230         RestapiCallNode rcn = new RestapiCallNode();
 
 231         rcn.sendRequest(p, ctx);
 
 234     @Test(expected = SvcLogicException.class)
 
 235     public void testFormData() throws SvcLogicException {
 
 236         SvcLogicContext ctx = new SvcLogicContext();
 
 237         ctx.setAttribute("tmp.sdn-circuit-req-row_length", "1");
 
 238         ctx.setAttribute("tmp.sdn-circuit-req-row[0].source-uid", "APIDOC-123");
 
 239         ctx.setAttribute("tmp.sdn-circuit-req-row[0].action", "delete");
 
 240         ctx.setAttribute("tmp.sdn-circuit-req-row[0].request-timestamp", "2016-09-09 16:30:35.0");
 
 241         ctx.setAttribute("tmp.sdn-circuit-req-row[0].request-status", "New");
 
 242         ctx.setAttribute("tmp.sdn-circuit-req-row[0].processing-status", "New");
 
 243         ctx.setAttribute("tmp.sdn-circuit-req-row[0].service-clfi", "testClfi1");
 
 244         ctx.setAttribute("tmp.sdn-circuit-req-row[0].clci", "clci");
 
 246         Map<String, String> p = new HashMap<String, String>();
 
 247         p.put("templateFileName", "src/test/resources/test-template.json");
 
 248         p.put("restapiUrl", "http://echo.getpostman.com");
 
 249         p.put("restapiUser", "user1");
 
 250         p.put("restapiPassword", "abc123");
 
 251         p.put("format", "json");
 
 252         p.put("httpMethod", "post");
 
 253         p.put("responsePrefix", "response");
 
 254         p.put("skipSending", "false");
 
 255         p.put("multipartFormData", "true");
 
 256         p.put("multipartFile", "src/test/resources/test-template.json");
 
 258         RestapiCallNode rcn = new RestapiCallNode();
 
 259         rcn.sendRequest(p, ctx);
 
 262     @Test(expected = SvcLogicException.class)
 
 263     public void testWithInvalidURI() throws SvcLogicException {
 
 264         SvcLogicContext ctx = new SvcLogicContext();
 
 265         ctx.setAttribute("tmp.sdn-circuit-req-row_length", "1");
 
 266         ctx.setAttribute("tmp.sdn-circuit-req-row[0].source-uid", "APIDOC-123");
 
 267         ctx.setAttribute("tmp.sdn-circuit-req-row[0].action", "delete");
 
 268         ctx.setAttribute("tmp.sdn-circuit-req-row[0].request-timestamp", "2016-09-09 16:30:35.0");
 
 269         ctx.setAttribute("tmp.sdn-circuit-req-row[0].request-status", "New");
 
 270         ctx.setAttribute("tmp.sdn-circuit-req-row[0].processing-status", "New");
 
 271         ctx.setAttribute("tmp.sdn-circuit-req-row[0].service-clfi", "testClfi1");
 
 272         ctx.setAttribute("tmp.sdn-circuit-req-row[0].clci", "clci");
 
 274         Map<String, String> p = new HashMap<String, String>();
 
 275         p.put("templateFileName", "src/test/resources/test-template.json");
 
 276         p.put("restapiUrl", "http://echo.  getpostman.com");
 
 277         p.put("restapiUser", "user1");
 
 278         p.put("restapiPassword", "abc123");
 
 279         p.put("format", "json");
 
 280         p.put("httpMethod", "post");
 
 281         p.put("responsePrefix", "response");
 
 282         p.put("skipSending", "false");
 
 284         RestapiCallNode rcn = new RestapiCallNode();
 
 285         rcn.sendRequest(p, ctx);
 
 289     public void testVpnJsonTemplate() throws SvcLogicException {
 
 290         SvcLogicContext ctx = new SvcLogicContext();
 
 291         ctx.setAttribute("prop.l3vpn.name", "10000000-0000-0000-0000-000000000001");
 
 292         ctx.setAttribute("prop.l3vpn.topology", "point_to_point");
 
 294         Map<String, String> p = new HashMap<String, String>();
 
 295         p.put("templateFileName", "src/test/resources/l3smvpntemplate.json");
 
 296         p.put("restapiUrl", "http://ipwan:18002/restconf/data/huawei-ac-net-l3vpn-svc:l3vpn-svc-cfg/vpn-services");
 
 297         p.put("restapiUser", "admin");
 
 298         p.put("restapiPassword", "admin123");
 
 299         p.put("format", "json");
 
 300         p.put("httpMethod", "post");
 
 301         p.put("responsePrefix", "restapi-result");
 
 302         p.put("skipSending", "true");
 
 304         RestapiCallNode rcn = new RestapiCallNode();
 
 305         rcn.sendRequest(p, ctx);
 
 309     public void testSiteJsonTemplate() throws SvcLogicException {
 
 310         SvcLogicContext ctx = new SvcLogicContext();
 
 311         ctx.setAttribute("prop.l3vpn.name", "10000000-0000-0000-0000-000000000001");
 
 312         ctx.setAttribute("prop.l3vpn.topology", "point_to_point");
 
 314         ctx.setAttribute("prop.l3vpn.site1_name", "10000000-0000-0000-0000-000000000002");
 
 315         ctx.setAttribute("prop.l3vpn.vpn-policy1-id", "10000000-0000-0000-0000-000000000003");
 
 316         ctx.setAttribute("prop.l3vpn.entry1-id", "1");
 
 317         ctx.setAttribute("prop.l3vpn.sna1_name", "10000000-0000-0000-0000-000000000004");
 
 318         ctx.setAttribute("prop.l3vpn.pe1_id", "a8098c1a-f86e-11da-bd1a-00112444be1e");
 
 319         ctx.setAttribute("prop.l3vpn.ac1_id", "a8098c1a-f86e-11da-bd1a-00112444be1b");
 
 320         ctx.setAttribute("prop.l3vpn.ac1-peer-ip", "192.168.1.1");
 
 321         ctx.setAttribute("prop.l3vpn.ac1-ip", "192.168.1.2");
 
 322         ctx.setAttribute("prop.l3vpn.sna1_svlan", "100");
 
 323         ctx.setAttribute("prop.l3vpn.ac1_protocol", "static");
 
 324         ctx.setAttribute("prop.l3vpn.sna1-route.ip-prefix", "192.168.1.1/24");
 
 325         ctx.setAttribute("prop.l3vpn.sna1-route.next-hop", "192.168.1.4");
 
 327         ctx.setAttribute("prop.l3vpn.site2_name", "10000000-0000-0000-0000-000000000005");
 
 328         ctx.setAttribute("prop.l3vpn.vpn-policy2-id", "10000000-0000-0000-0000-000000000006");
 
 329         ctx.setAttribute("prop.l3vpn.entry2-id", "1");
 
 330         ctx.setAttribute("prop.l3vpn.sna2_name", "10000000-0000-0000-0000-000000000007");
 
 331         ctx.setAttribute("prop.l3vpn.pe2_id", "a8098c1a-f86e-11da-bd1a-00112444be1a");
 
 332         ctx.setAttribute("prop.l3vpn.ac2_id", "a8098c1a-f86e-11da-bd1a-00112444be1c");
 
 333         ctx.setAttribute("prop.l3vpn.ac2-peer-ip", "192.168.1.6");
 
 334         ctx.setAttribute("prop.l3vpn.ac2-ip", "192.168.1.5");
 
 335         ctx.setAttribute("prop.l3vpn.sna2_svlan", "200");
 
 336         ctx.setAttribute("prop.l3vpn.ac2_protocol", "bgp");
 
 337         ctx.setAttribute("prop.l3vpn.peer2-ip", "192.168.1.7");
 
 338         ctx.setAttribute("prop.l3vpn.ac2_protocol_bgp_as", "200");
 
 340         Map<String, String> p = new HashMap<String, String>();
 
 341         p.put("templateFileName", "src/test/resources/l3smsitetemplate.json");
 
 342         p.put("restapiUrl", "http://ipwan:18002/restconf/data/huawei-ac-net-l3vpn-svc:l3vpn-svc-cfg/sites");
 
 343         p.put("restapiUser", "admin");
 
 344         p.put("restapiPassword", "admin123");
 
 345         p.put("format", "json");
 
 346         p.put("httpMethod", "post");
 
 347         p.put("responsePrefix", "restapi-result");
 
 348         p.put("skipSending", "true");
 
 350         RestapiCallNode rcn = new RestapiCallNode();
 
 351         rcn.sendRequest(p, ctx);
 
 355     public void testVrfJsonTemplate() throws SvcLogicException {
 
 356         SvcLogicContext ctx = new SvcLogicContext();
 
 357         ctx.setAttribute("prop.l3vpn.vrf1-id", "10000000-0000-0000-0000-000000000007");
 
 358         ctx.setAttribute("prop.l3vpn.vpn-policy1-id", "10000000-0000-0000-0000-000000000003");
 
 359         ctx.setAttribute("prop.l3vpn.pe1_id", "a8098c1a-f86e-11da-bd1a-00112444be1e");
 
 360         ctx.setAttribute("prop.l3vpn.vrf2-id", "10000000-0000-0000-0000-000000000009");
 
 361         ctx.setAttribute("prop.l3vpn.vpn-policy2-id", "10000000-0000-0000-0000-000000000006");
 
 362         ctx.setAttribute("prop.l3vpn.pe2_id", "a8098c1a-f86e-11da-bd1a-00112444be1a");
 
 364         Map<String, String> p = new HashMap<String, String>();
 
 365         p.put("templateFileName", "src/test/resources/l3smvrftemplate.json");
 
 366         p.put("restapiUrl", "http://ipwan:18002/restconf/data/huawei-ac-net-l3vpn-svc:l3vpn-svc-cfg/vrf-attributes");
 
 367         p.put("restapiUser", "admin");
 
 368         p.put("restapiPassword", "admin123");
 
 369         p.put("format", "json");
 
 370         p.put("httpMethod", "post");
 
 371         p.put("responsePrefix", "restapi-result");
 
 372         p.put("skipSending", "true");
 
 374         RestapiCallNode rcn = new RestapiCallNode();
 
 375         rcn.sendRequest(p, ctx);
 
 379     public void testDeleteVpnJsonTemplate() throws SvcLogicException {
 
 380         SvcLogicContext ctx = new SvcLogicContext();
 
 381         ctx.setAttribute("prop.l3vpn.name", "10000000-0000-0000-0000-000000000001");
 
 382         ctx.setAttribute("prop.l3vpn.topology", "point_to_point");
 
 384         Map<String, String> p = new HashMap<String, String>();
 
 385         //p.put("templateFileName", "src/test/resources/l3smvpntemplate.json");
 
 386         p.put("restapiUrl", "http://ipwan:18002/restconf/data/huawei-ac-net-l3vpn-svc:l3vpn-svc-cfg/vpn-services"
 
 387             + "/vpnservice=10000000-0000-0000-0000-000000000001");
 
 388         p.put("restapiUser", "admin");
 
 389         p.put("restapiPassword", "admin123");
 
 390         p.put("format", "json");
 
 391         p.put("httpMethod", "delete");
 
 392         p.put("responsePrefix", "restapi-result");
 
 393         p.put("skipSending", "true");
 
 395         RestapiCallNode rcn = new RestapiCallNode();
 
 396         rcn.sendRequest(p, ctx);
 
 400     public void testL2DciTemplate() throws SvcLogicException {
 
 401         SvcLogicContext ctx = new SvcLogicContext();
 
 402         ctx.setAttribute("prop.dci-connects.id", "Id1");
 
 403         ctx.setAttribute("prop.dci-connects.name", "Name1");
 
 404         ctx.setAttribute("prop.dci-connects.local_networks[0]", "NetId1");
 
 405         ctx.setAttribute("prop.dci-connects.local_networks[1]", "NetId2");
 
 406         ctx.setAttribute("prop.dci-connects.evpn_irts[0]", "100:1");
 
 407         ctx.setAttribute("prop.dci-connects.evpn_erts[0]", "100:2");
 
 408         ctx.setAttribute("prop.dci-connects.evpn_irts[1]", "200:1");
 
 409         ctx.setAttribute("prop.dci-connects.evpn_erts[1]", "200:2");
 
 410         ctx.setAttribute("prop.dci-connects.vni", "1");
 
 412         Map<String, String> p = new HashMap<String, String>();
 
 413         p.put("templateFileName", "src/test/resources/l2-dci-connects-template.json");
 
 414         p.put("restapiUrl", "http://echo.getpostman.com");
 
 415         p.put("restapiUser", "user1");
 
 416         p.put("restapiPassword", "abc123");
 
 417         p.put("format", "json");
 
 418         p.put("httpMethod", "post");
 
 419         p.put("responsePrefix", "response");
 
 420         p.put("skipSending", "true");
 
 422         RestapiCallNode rcn = new RestapiCallNode();
 
 423         rcn.sendRequest(p, ctx);
 
 427     public void testL3DciTemplate() throws SvcLogicException {
 
 428         SvcLogicContext ctx = new SvcLogicContext();
 
 429         ctx.setAttribute("prop.dci-connects.id", "Id1");
 
 430         ctx.setAttribute("prop.dci-connects.name", "Name1");
 
 431         ctx.setAttribute("prop.dci-connects.local_networks_length", "2");
 
 432         ctx.setAttribute("prop.dci-connects.local_networks[0]", "NetId1");
 
 433         ctx.setAttribute("prop.dci-connects.local_networks[1]", "NetId2");
 
 434         ctx.setAttribute("prop.dci-connects.evpn_irts[0]", "100:1");
 
 435         ctx.setAttribute("prop.dci-connects.evpn_erts[0]", "100:2");
 
 436         ctx.setAttribute("prop.dci-connects.evpn_irts[1]", "200:1");
 
 437         ctx.setAttribute("prop.dci-connects.evpn_erts[1]", "200:2");
 
 438         ctx.setAttribute("prop.dci-connects.vni", "1");
 
 440         Map<String, String> p = new HashMap<String, String>();
 
 441         p.put("templateFileName", "src/test/resources/l3-dci-connects-template.json");
 
 442         p.put("restapiUrl", "http://echo.getpostman.com");
 
 443         p.put("restapiUser", "user1");
 
 444         p.put("restapiPassword", "abc123");
 
 445         p.put("format", "json");
 
 446         p.put("httpMethod", "post");
 
 447         p.put("responsePrefix", "response");
 
 448         p.put("skipSending", "true");
 
 450         RestapiCallNode rcn = new RestapiCallNode();
 
 451         rcn.sendRequest(p, ctx);
 
 456     public void testControllerTokenTemplate() throws SvcLogicException {
 
 457         SvcLogicContext ctx = new SvcLogicContext();
 
 458         ctx.setAttribute("prop.sdncRestApi.thirdpartySdnc.user", "admin");
 
 459         ctx.setAttribute("prop.sdncRestApi.thirdpartySdnc.password", "admin123");
 
 461         Map<String, String> p = new HashMap<String, String>();
 
 462         p.put("templateFileName", "src/test/resources/actokentemplate.json");
 
 463         p.put("restapiUrl", "https://ipwan:18002/controller/v2/tokens");
 
 464         p.put("format", "json");
 
 465         p.put("httpMethod", "post");
 
 466         p.put("responsePrefix", "restapi-result");
 
 467         p.put("skipSending", "true");
 
 469         RestapiCallNode rcn = new RestapiCallNode();
 
 470         rcn.sendRequest(p, ctx);
 
 475     public void testDeleteNoneAsContentType() throws SvcLogicException {
 
 476         SvcLogicContext ctx = new SvcLogicContext();
 
 478         Map<String, String> p = new HashMap<String, String>();
 
 479         p.put("restapiUrl", "https://echo.getpostman.com/delete");
 
 480         p.put("restapiUser", "user1");
 
 481         p.put("restapiPassword", "pwd1");
 
 482         p.put("httpMethod", "delete");
 
 483         p.put("format", "none");
 
 484         p.put("skipSending", "true");
 
 486         RestapiCallNode rcn = new RestapiCallNode();
 
 487         rcn.sendRequest(p, ctx);
 
 491     public void testPostNoneAsContentType() throws SvcLogicException {
 
 492         SvcLogicContext ctx = new SvcLogicContext();
 
 493         ctx.setAttribute("prop.l3vpn.name", "10000000-0000-0000-0000-000000000001");
 
 494         ctx.setAttribute("prop.l3vpn.topology", "point_to_point");
 
 496         Map<String, String> p = new HashMap<String, String>();
 
 497         p.put("templateFileName", "src/test/resources/l3smvpntemplate.json");
 
 498         p.put("restapiUrl", "http://ipwan:18002/restconf/data/huawei-ac-net-l3vpn-svc:l3vpn-svc-cfg/vpn-services");
 
 499         p.put("restapiUser", "admin");
 
 500         p.put("restapiPassword", "admin123");
 
 501         p.put("format", "none");
 
 502         p.put("httpMethod", "post");
 
 503         p.put("responsePrefix", "restapi-result");
 
 504         p.put("skipSending", "true");
 
 506         RestapiCallNode rcn = new RestapiCallNode();
 
 507         rcn.sendRequest(p, ctx);
 
 511     public void testDeleteOAuthType() throws SvcLogicException {
 
 512         SvcLogicContext ctx = new SvcLogicContext();
 
 514         Map<String, String> p = new HashMap<String, String>();
 
 515         p.put("restapiUrl", "https://echo.getpostman.com/delete");
 
 516         p.put("oAuthConsumerKey", "f2a1ed52710d4533bde25be6da03b6e3");
 
 517         p.put("oAuthConsumerSecret", "secret");
 
 518         p.put("oAuthSignatureMethod", "plainTEXT");
 
 519         p.put("oAuthVersion", "1.0");
 
 520         p.put("httpMethod", "delete");
 
 521         p.put("format", "none");
 
 522         p.put("skipSending", "true");
 
 524         RestapiCallNode rcn = new RestapiCallNode();
 
 525         rcn.sendRequest(p, ctx);
 
 529     public void testDeleteAuthTypeBasic() throws SvcLogicException {
 
 530         SvcLogicContext ctx = new SvcLogicContext();
 
 532         Map<String, String> p = new HashMap<String, String>();
 
 533         p.put("restapiUrl", "https://echo.getpostman.com/delete");
 
 534         p.put("authType", "basic");
 
 535         p.put("restapiUser", "admin");
 
 536         p.put("restapiPassword", "admin123");
 
 537         p.put("httpMethod", "delete");
 
 538         p.put("format", "none");
 
 539         p.put("skipSending", "true");
 
 541         RestapiCallNode rcn = new RestapiCallNode();
 
 542         rcn.sendRequest(p, ctx);
 
 546     public void testDeleteAuthTypeDigest() throws SvcLogicException {
 
 547         SvcLogicContext ctx = new SvcLogicContext();
 
 549         Map<String, String> p = new HashMap<String, String>();
 
 550         p.put("restapiUrl", "https://echo.getpostman.com/delete");
 
 551         p.put("authType", "digest");
 
 552         p.put("restapiUser", "admin");
 
 553         p.put("restapiPassword", "admin123");
 
 554         p.put("httpMethod", "delete");
 
 555         p.put("format", "none");
 
 556         p.put("skipSending", "true");
 
 558         RestapiCallNode rcn = new RestapiCallNode();
 
 559         rcn.sendRequest(p, ctx);
 
 563     public void testDeleteAuthTypeOAuth() throws SvcLogicException {
 
 564         SvcLogicContext ctx = new SvcLogicContext();
 
 566         Map<String, String> p = new HashMap<String, String>();
 
 567         p.put("restapiUrl", "https://echo.getpostman.com/delete");
 
 568         p.put("authType", "oauth");
 
 569         p.put("oAuthConsumerKey", "f2a1ed52710d4533bde25be6da03b6e3");
 
 570         p.put("oAuthConsumerSecret", "secret");
 
 571         p.put("oAuthSignatureMethod", "plainTEXT");
 
 572         p.put("oAuthVersion", "1.0");
 
 573         p.put("httpMethod", "delete");
 
 574         p.put("format", "none");
 
 575         p.put("skipSending", "true");
 
 577         RestapiCallNode rcn = new RestapiCallNode();
 
 578         rcn.sendRequest(p, ctx);
 
 582     public void testDeleteAuthTypeNoneOAuth() throws SvcLogicException {
 
 583         SvcLogicContext ctx = new SvcLogicContext();
 
 585         Map<String, String> p = new HashMap<String, String>();
 
 586         p.put("restapiUrl", "https://echo.getpostman.com/delete");
 
 587         p.put("oAuthConsumerKey", "f2a1ed52710d4533bde25be6da03b6e3");
 
 588         p.put("oAuthConsumerSecret", "secret");
 
 589         p.put("oAuthSignatureMethod", "plainTEXT");
 
 590         p.put("oAuthVersion", "1.0");
 
 591         p.put("httpMethod", "delete");
 
 592         p.put("format", "none");
 
 593         p.put("skipSending", "true");
 
 595         RestapiCallNode rcn = new RestapiCallNode();
 
 596         rcn.sendRequest(p, ctx);
 
 599     public void testDeleteAuthTypeNoneBasic() throws SvcLogicException {
 
 600         SvcLogicContext ctx = new SvcLogicContext();
 
 602         Map<String, String> p = new HashMap<String, String>();
 
 603         p.put("restapiUrl", "https://echo.getpostman.com/delete");
 
 604         p.put("restapiUser", "admin");
 
 605         p.put("restapiPassword", "admin123");
 
 606         p.put("httpMethod", "delete");
 
 607         p.put("format", "none");
 
 608         p.put("skipSending", "true");
 
 610         RestapiCallNode rcn = new RestapiCallNode();
 
 611         rcn.sendRequest(p, ctx);
 
 614     @Test(expected = SvcLogicException.class)
 
 615     public void testInvalidDeleteAuthTypeOAuth() throws SvcLogicException {
 
 616         SvcLogicContext ctx = new SvcLogicContext();
 
 618         Map<String, String> p = new HashMap<String, String>();
 
 619         p.put("restapiUrl", "https://echo.getpostman.com/delete");
 
 620         p.put("authType", "oauth");
 
 621         p.put("oAuthConsumerKey", "f2a1ed52710d4533bde25be6da03b6e3");
 
 622         p.put("oAuthConsumerSecret", "secret");
 
 623         p.put("httpMethod", "delete");
 
 624         p.put("format", "none");
 
 625         p.put("skipSending", "true");
 
 627         RestapiCallNode rcn = new RestapiCallNode();
 
 628         rcn.sendRequest(p, ctx);
 
 631     @Test(expected = SvcLogicException.class)
 
 632     public void testInvalidDeleteAuthTypeBasic() throws SvcLogicException {
 
 633         SvcLogicContext ctx = new SvcLogicContext();
 
 635         Map<String, String> p = new HashMap<String, String>();
 
 636         p.put("restapiUrl", "https://echo.getpostman.com/delete");
 
 637         p.put("authType", "basic");
 
 638         p.put("oAuthConsumerKey", "f2a1ed52710d4533bde25be6da03b6e3");
 
 639         p.put("oAuthConsumerSecret", "secret");
 
 640         p.put("httpMethod", "delete");
 
 641         p.put("format", "none");
 
 642         p.put("skipSending", "true");
 
 644         RestapiCallNode rcn = new RestapiCallNode();
 
 645         rcn.sendRequest(p, ctx);
 
 648     @Test(expected = SvcLogicException.class)
 
 649     public void testInvalidDeleteAuthTypeDigest() throws SvcLogicException {
 
 650         SvcLogicContext ctx = new SvcLogicContext();
 
 652         Map<String, String> p = new HashMap<String, String>();
 
 653         p.put("restapiUrl", "https://echo.getpostman.com/delete");
 
 654         p.put("authType", "digest");
 
 655         p.put("oAuthConsumerKey", "f2a1ed52710d4533bde25be6da03b6e3");
 
 656         p.put("oAuthConsumerSecret", "secret");
 
 657         p.put("httpMethod", "delete");
 
 658         p.put("format", "none");
 
 659         p.put("skipSending", "true");
 
 661         RestapiCallNode rcn = new RestapiCallNode();
 
 662         rcn.sendRequest(p, ctx);
 
 666     public void testMultipartFormData() throws SvcLogicException {
 
 667         final ResourceConfig resourceConfig = new ResourceConfig(
 
 668                 MultipartServerMock.class, MultiPartFeature.class);
 
 669         GrizzlyHttpServerFactory.createHttpServer(
 
 670                 URI.create("http://localhost:8080/"),resourceConfig);
 
 672         Map<String, String> p = new HashMap<>();
 
 673         p.put("multipartFormData", "true");
 
 674         p.put("format", "none");
 
 675         p.put("multipartFile", "src/test/resources/test-template.json");
 
 676         p.put("restapiUrl", "http://localhost:8080/file-upload/upload");
 
 678         SvcLogicContext ctx = new SvcLogicContext();
 
 679         RestapiCallNode rcn = new RestapiCallNode();
 
 680         rcn.sendRequest(p, ctx);
 
 681         assertThat(ctx.getAttribute("response-code"), is("200"));
 
 682         assertThat(ctx.getAttribute("httpResponse"), is( "test-template.json"));