From 69d612621915cf9793b5e8c5a4e9ec42187a557d Mon Sep 17 00:00:00 2001 From: Vidyashree Rama Date: Thu, 25 Oct 2018 14:50:31 +0530 Subject: Add authorization header in SSE request Add authorization header in SSE request to support https Issue-ID: CCSDK-628 Change-Id: I031cbed94e21e1f6d90bc0b00b2d70905d47bd69 Signed-off-by: Vidyashree Rama --- .../plugins/restconfdiscovery/SseServerMock.java | 2 +- .../TestRestconfDiscoveryNode.java | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) (limited to 'restconf-client/provider/src/test/java') diff --git a/restconf-client/provider/src/test/java/org/onap/ccsdk/sli/plugins/restconfdiscovery/SseServerMock.java b/restconf-client/provider/src/test/java/org/onap/ccsdk/sli/plugins/restconfdiscovery/SseServerMock.java index 1b234a236..35ac221fb 100644 --- a/restconf-client/provider/src/test/java/org/onap/ccsdk/sli/plugins/restconfdiscovery/SseServerMock.java +++ b/restconf-client/provider/src/test/java/org/onap/ccsdk/sli/plugins/restconfdiscovery/SseServerMock.java @@ -35,7 +35,7 @@ public class SseServerMock { @Produces(SseFeature.SERVER_SENT_EVENTS) public EventOutput getServerSentEvents() throws IOException { String data = "{" + - "\"ietf-notification:notification\" : {" + + "\"ietf-restconf:notification\" : {" + " \"eventTime\" : \"2017-10-25T08:22:33.44Z\"," + " \"ietf-yang-push:push-change-update\": {" + "\"subscription-id\":\"89\"," + diff --git a/restconf-client/provider/src/test/java/org/onap/ccsdk/sli/plugins/restconfdiscovery/TestRestconfDiscoveryNode.java b/restconf-client/provider/src/test/java/org/onap/ccsdk/sli/plugins/restconfdiscovery/TestRestconfDiscoveryNode.java index b2094ca73..af354e9bf 100644 --- a/restconf-client/provider/src/test/java/org/onap/ccsdk/sli/plugins/restconfdiscovery/TestRestconfDiscoveryNode.java +++ b/restconf-client/provider/src/test/java/org/onap/ccsdk/sli/plugins/restconfdiscovery/TestRestconfDiscoveryNode.java @@ -57,6 +57,13 @@ public class TestRestconfDiscoveryNode { p.put("sseConnectURL", "http://localhost:8080/events"); p.put("subscriberId", "networkId"); p.put("responsePrefix", "restapi-result"); + p.put("restapiUser", "access"); + p.put("restapiPassword", "abc@123"); + p.put("customHttpHeaders", "X-ACCESS-TOKEN=x-ik2ps4ikvzupbx0486ft" + + "1ebzs7rt85futh9ho6eofy3wjsap7wqktemlqm4bbsmnar3vrtbyrzuk" + + "bv5itd6m1cftldpjarnyle3sdcqq9hftc4lebz464b5ffxmlbvg9"); + p.put("restapiUrl", "https://localhost:8080/restconf/operations/" + + "ietf-subscribed-notifications:establish-subscription"); RestconfDiscoveryNode rdn = new RestconfDiscoveryNode( new RestconfApiCallNode(new RestapiCallNode())); rdn.establishPersistentConnection(p, ctx, "networkId"); @@ -111,4 +118,18 @@ public class TestRestconfDiscoveryNode { assertThat(rdn.getOutputIdentifier("restapi-result", ctx), is("89")); } + + @Test + public void testGetTokenId() { + String customHttpHeaders = "X-ACCESS-TOKEN=x-ik2ps4ikvzupbx0486ft1ebzs7rt85" + + "futh9ho6eofy3wjsap7wqktemlqm4bbsmnar3vrtbyrzukbv5itd6m1cftldpjarny" + + "le3sdcqq9hftc4lebz464b5ffxmlbvg9"; + RestconfDiscoveryNode rdn = new RestconfDiscoveryNode( + new RestconfApiCallNode(new RestapiCallNode())); + + assertThat(rdn.getTokenId(customHttpHeaders), + is("x-ik2ps4ikvzupbx0486ft1ebzs7rt85futh9ho6eofy3wjsap7wqkt" + + "emlqm4bbsmnar3vrtbyrzukbv5itd6m1cftldpjarnyle3sdcqq9h" + + "ftc4lebz464b5ffxmlbvg9")); + } } -- cgit 1.2.3-korg