diff options
author | kusuma kumari M <km583p@att.com> | 2018-01-03 21:55:50 -0500 |
---|---|---|
committer | Skip Wonnell <skip@att.com> | 2018-01-09 15:18:42 +0000 |
commit | 2a66c7c042d4d5919f8b200d026f211ba241774f (patch) | |
tree | 2f7c0c20f3b113cb91d2f75fb94e7ccd4c79fc31 /appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/test | |
parent | 31540f8ba964a7d66ca04f1468db061abda5c7a1 (diff) |
code changes for platform hardening appc adapters
Issue-ID: APPC-305
Change-Id: Ice60ca77ffccc409d50ef11318e841c3b1f82ce1
Signed-off-by: kusuma kumari M <km583p@att.com>
Diffstat (limited to 'appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/test')
2 files changed, 46 insertions, 21 deletions
diff --git a/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/test/java/org/onap/appc/adapter/chef/chefclient/TestChefApiClient.java b/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/test/java/org/onap/appc/adapter/chef/chefclient/TestChefApiClient.java index 5ea152a8d..bf718ab2f 100644 --- a/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/test/java/org/onap/appc/adapter/chef/chefclient/TestChefApiClient.java +++ b/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/test/java/org/onap/appc/adapter/chef/chefclient/TestChefApiClient.java @@ -1,3 +1,27 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APPC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Copyright (C) 2017 Amdocs + * ============================================================================= + * 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. + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + * ============LICENSE_END========================================================= + */ + package org.onap.appc.adapter.chef.chefclient; import static org.junit.Assert.assertEquals; @@ -51,7 +75,7 @@ public class TestChefApiClient { @Test public void testGet(){ Get get = client.get(props.getProperty("org.onap.appc.adapter.chef.chefclient.path")); - ApiMethod method = get.createRequest(); + ApiMethod method = get.execute(); String[] response = method.test.split("\n"); thenStringShouldMatch("GET", response); @@ -60,7 +84,7 @@ public class TestChefApiClient { @Test public void testPut(){ Put put = client.put(props.getProperty("org.onap.appc.adapter.chef.chefclient.path")); - ApiMethod method = put.createRequest(); + ApiMethod method = put.execute(); String[] response = method.test.split("\n"); thenStringShouldMatch("PUT", response); @@ -69,7 +93,7 @@ public class TestChefApiClient { @Test public void testPost() { Post post = client.post(props.getProperty("org.onap.appc.adapter.chef.chefclient.path")); - ApiMethod method = post.createRequest(); + ApiMethod method = post.execute(); String[] response = method.test.split("\n"); thenStringShouldMatch("POST", response); @@ -78,7 +102,7 @@ public class TestChefApiClient { @Test public void testDelete(){ Delete delete = client.delete(props.getProperty("org.onap.appc.adapter.chef.chefclient.path")); - ApiMethod method = delete.createRequest(); + ApiMethod method = delete.execute(); String[] response = method.test.split("\n"); thenStringShouldMatch("DELETE", response); diff --git a/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/test/java/org/onap/appc/adapter/chef/impl/TestChefAdapterImpl.java b/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/test/java/org/onap/appc/adapter/chef/impl/TestChefAdapterImpl.java index 687ba8338..d5a5d8cd0 100644 --- a/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/test/java/org/onap/appc/adapter/chef/impl/TestChefAdapterImpl.java +++ b/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/test/java/org/onap/appc/adapter/chef/impl/TestChefAdapterImpl.java @@ -36,6 +36,7 @@ import org.junit.Test; import org.onap.appc.exceptions.APPCException; import com.att.cdp.exceptions.ZoneException; import org.onap.ccsdk.sli.core.sli.SvcLogicContext; +import org.onap.ccsdk.sli.core.sli.SvcLogicException; public class TestChefAdapterImpl { private SvcLogicContext svcContext; @@ -49,7 +50,7 @@ public class TestChefAdapterImpl { public void setup() { adapter = new ChefAdapterImpl(Boolean.TRUE); params = new HashMap<>(); - params.put("org.onap.appc.instance.pemPath", + params.put("pemPath", "/src/test/resources/testclient.pem"); } @@ -59,23 +60,23 @@ public class TestChefAdapterImpl { svcContext = null; getAttribute = null; } - - @Test + + @Test(expected=Exception.class) public void testChefGetFail() throws IOException, IllegalStateException, IllegalArgumentException, - ZoneException, APPCException { - params.put("org.onap.appc.instance.chefAction", "/nodes"); + ZoneException, APPCException,SvcLogicException { + params.put("chefAction", "/nodes"); givenParams(params, "chefGet"); thenResponseShouldFail(); } - @Test + @Test(expected=Exception.class) public void testChefPutFail() throws IOException, IllegalStateException, IllegalArgumentException, - ZoneException, APPCException { - params.put("org.onap.appc.instance.chefAction", "/nodes/testnode"); - params.put("org.onap.appc.instance.runList", "recipe[commandtest]"); - params.put("org.onap.appc.instance.attributes", ""); - params.put("org.onap.appc.instance.chefRequestBody", "Test Body"); + ZoneException, APPCException,SvcLogicException { + params.put("chefAction", "/nodes/testnode"); + params.put("runList", "recipe[commandtest]"); + params.put("attributes", ""); + params.put("chefRequestBody", "Test Body"); givenParams(params, "chefPut"); thenResponseShouldFail(); @@ -83,26 +84,26 @@ public class TestChefAdapterImpl { @Test public void testTriggerFail() throws IOException, IllegalStateException, IllegalArgumentException, - ZoneException, APPCException { - params.put("org.onap.appc.instance.ip", ""); + ZoneException, APPCException,SvcLogicException { + params.put("ip", ""); givenParams(params, "trigger"); thenResponseShouldFail(); } - private void givenParams(Map<String, String> adapterParams, String method) { + private void givenParams(Map<String, String> adapterParams, String method) throws SvcLogicException { svcContext = new SvcLogicContext(); if (method == "chefGet"){ adapter.chefGet(adapterParams, svcContext); - getAttribute = "org.onap.appc.chefServerResult.code"; + getAttribute = "chefServerResult.code"; } if (method == "chefPut"){ adapter.chefPut(adapterParams, svcContext); - getAttribute = "org.onap.appc.chefServerResult.code"; + getAttribute = "chefServerResult.code"; } if (method == "trigger"){ adapter.trigger(adapterParams, svcContext); - getAttribute = "org.onap.appc.chefAgent.code"; + getAttribute = "chefAgent.code"; } } |