aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xrestapi-call-node/provider/pom.xml1
-rw-r--r--restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/MockCookieAuthServer.java40
-rw-r--r--restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestRestapiCallNode.java25
3 files changed, 65 insertions, 1 deletions
diff --git a/restapi-call-node/provider/pom.xml b/restapi-call-node/provider/pom.xml
index 1f698ead..32089455 100755
--- a/restapi-call-node/provider/pom.xml
+++ b/restapi-call-node/provider/pom.xml
@@ -93,4 +93,5 @@
<scope>test</scope>
</dependency>
</dependencies>
+
</project>
diff --git a/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/MockCookieAuthServer.java b/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/MockCookieAuthServer.java
new file mode 100644
index 00000000..b4a30d3a
--- /dev/null
+++ b/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/MockCookieAuthServer.java
@@ -0,0 +1,40 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - CCSDK
+ * ================================================================================
+ * Copyright (C) 2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package jtest.org.onap.ccsdk.sli.plugins.restapicall;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.Produces;
+
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.NewCookie;
+import javax.ws.rs.core.Response;
+
+@Path("get-cookie")
+public class MockCookieAuthServer {
+ @GET
+ @Path("cookie")
+ @Produces(MediaType.APPLICATION_JSON)
+ @Consumes(MediaType.APPLICATION_JSON)
+ public Response getCookie() {
+ return Response.status(200).entity("success").cookie(new NewCookie("cookieResponse", "cookieValueInReturn")).build();
+ }
+}
diff --git a/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestRestapiCallNode.java b/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestRestapiCallNode.java
index 7a24ca1a..52da4615 100644
--- a/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestRestapiCallNode.java
+++ b/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestRestapiCallNode.java
@@ -25,6 +25,7 @@ import java.net.URI;
import java.util.HashMap;
import java.util.Map;
+import org.glassfish.grizzly.http.server.HttpServer;
import org.glassfish.jersey.grizzly2.httpserver.GrizzlyHttpServerFactory;
import org.glassfish.jersey.media.multipart.MultiPartFeature;
import org.junit.Test;
@@ -666,7 +667,7 @@ public class TestRestapiCallNode {
public void testMultipartFormData() throws SvcLogicException {
final ResourceConfig resourceConfig = new ResourceConfig(
MultipartServerMock.class, MultiPartFeature.class);
- GrizzlyHttpServerFactory.createHttpServer(
+ HttpServer server = GrizzlyHttpServerFactory.createHttpServer(
URI.create("http://localhost:8080/"),resourceConfig);
Map<String, String> p = new HashMap<>();
@@ -680,5 +681,27 @@ public class TestRestapiCallNode {
rcn.sendRequest(p, ctx);
assertThat(ctx.getAttribute("response-code"), is("200"));
assertThat(ctx.getAttribute("httpResponse"), is( "test-template.json"));
+ server.shutdownNow();
+ }
+
+ @Test
+ public void testCookieResponse() throws SvcLogicException {
+ final ResourceConfig resourceConfig = new ResourceConfig(
+ MockCookieAuthServer.class);
+ HttpServer server = GrizzlyHttpServerFactory.createHttpServer(
+ URI.create("http://localhost:8080/"),resourceConfig);
+
+ Map<String, String> p = new HashMap<>();
+ p.put("format", "none");
+ p.put("httpMethod", "get");
+ p.put("restapiUrl", "http://localhost:8080/get-cookie/cookie");
+ p.put("dumpHeaders", "true");
+
+ SvcLogicContext ctx = new SvcLogicContext();
+ RestapiCallNode rcn = new RestapiCallNode();
+ rcn.sendRequest(p, ctx);
+ assertThat(ctx.getAttribute("response-code"), is("200"));
+ assertThat(ctx.getAttribute("header.Set-Cookie"), is("cookieResponse=cookieValueInReturn;Version=1"));
+ server.shutdownNow();
}
}