From 74f654c7cc41908d0109f60c7554f329f0b29daf Mon Sep 17 00:00:00 2001 From: Kanagaraj Manickam k00365106 Date: Sat, 30 Sep 2017 22:48:55 +0530 Subject: Migrate auth logic into http command Login/Logout logic is moved into http command as this framework would be enhanced to support other command types like ssh Issue-Id: CLI-66 Change-Id: I33936f8871dfa4c000f8fcabb9cf17e96fc71e0b Signed-off-by: Kanagaraj Manickam k00365106 --- .../cli/fw/ad/OnapAuthClientCommandBasedTest.java | 19 +++++++++---------- .../org/onap/cli/fw/cmd/OnapSwaggerCommandTest.java | 2 +- 2 files changed, 10 insertions(+), 11 deletions(-) (limited to 'framework/src/test/java') diff --git a/framework/src/test/java/org/onap/cli/fw/ad/OnapAuthClientCommandBasedTest.java b/framework/src/test/java/org/onap/cli/fw/ad/OnapAuthClientCommandBasedTest.java index 77ef680d..e6054127 100644 --- a/framework/src/test/java/org/onap/cli/fw/ad/OnapAuthClientCommandBasedTest.java +++ b/framework/src/test/java/org/onap/cli/fw/ad/OnapAuthClientCommandBasedTest.java @@ -21,18 +21,17 @@ import static org.junit.Assert.fail; import org.junit.Test; import org.onap.cli.fw.OnapCommand; import org.onap.cli.fw.OnapCommandRegistrar; +import org.onap.cli.fw.cmd.OnapHttpCommand; import org.onap.cli.fw.conf.Constants; import org.onap.cli.fw.conf.OnapCommandConfg; import org.onap.cli.fw.error.OnapCommandException; public class OnapAuthClientCommandBasedTest { - OnapCommand cmd; - @Test public void internalCommandTest() { try { - cmd = OnapCommandRegistrar.getRegistrar().get("sample-test"); + OnapCommand cmd = OnapCommandRegistrar.getRegistrar().get("sample-test"); cmd.getService().setName(OnapCommandConfg.getInternalCmd()); cmd.execute(); @@ -45,7 +44,7 @@ public class OnapAuthClientCommandBasedTest { @Test public void yesCatalogYesAuthTest() throws OnapCommandException { try { - cmd = getCommand("sample-test-schema-yes-auth-yes-catalog.yaml"); + OnapHttpCommand cmd = getCommand("sample-test-schema-yes-auth-yes-catalog.yaml"); cmd.getParametersMap().get(Constants.DEAFULT_PARAMETER_HOST_URL).setValue("http://localhost:8080"); cmd.getParametersMap().get(Constants.DEAFULT_PARAMETER_USERNAME).setValue("test"); cmd.getParametersMap().get(Constants.DEAFULT_PARAMETER_PASS_WORD).setValue("password"); @@ -60,7 +59,7 @@ public class OnapAuthClientCommandBasedTest { @Test public void yesCatalogNoAuthTest() throws OnapCommandException { try { - cmd = getCommand("sample-test-schema-no-auth-yes-catalog.yaml"); + OnapHttpCommand cmd = getCommand("sample-test-schema-no-auth-yes-catalog.yaml"); cmd.getParametersMap().get(Constants.DEAFULT_PARAMETER_HOST_URL).setValue("http://localhost:8080"); cmd.execute(); @@ -73,7 +72,7 @@ public class OnapAuthClientCommandBasedTest { @Test public void noCatalogYesAuthTest() throws OnapCommandException { try { - cmd = getCommand("sample-test-schema-yes-auth-no-catalog.yaml"); + OnapHttpCommand cmd = getCommand("sample-test-schema-yes-auth-no-catalog.yaml"); cmd.getParametersMap().get(Constants.DEAFULT_PARAMETER_HOST_URL).setValue("http://localhost:8080"); cmd.getParametersMap().get(Constants.DEAFULT_PARAMETER_USERNAME).setValue("test"); cmd.getParametersMap().get(Constants.DEAFULT_PARAMETER_PASS_WORD).setValue("password"); @@ -88,7 +87,7 @@ public class OnapAuthClientCommandBasedTest { @Test public void noCatalogNoAuthTest() throws OnapCommandException { try { - cmd = getCommand("sample-test-schema-no-auth-no-catalog.yaml"); + OnapHttpCommand cmd = getCommand("sample-test-schema-no-auth-no-catalog.yaml"); cmd.getParametersMap().get(Constants.DEAFULT_PARAMETER_HOST_URL).setValue("http://localhost:8080"); cmd.execute(); @@ -98,10 +97,10 @@ public class OnapAuthClientCommandBasedTest { } } - private OnapCommand getCommand(String yaml) throws OnapCommandException { - OnapCommand cmd = new OnapCommand() { + private OnapHttpCommand getCommand(String yaml) throws OnapCommandException { + OnapHttpCommand cmd = new OnapHttpCommand() { @Override - protected void run() throws OnapCommandException { + protected void processRequest() throws OnapCommandException { if (!this.getService().isModeDirect()) { String url = this.authClient.getServiceUrl(); assert url.equals(this.getParametersMap().get(Constants.DEAFULT_PARAMETER_HOST_URL).getValue() + "/"); diff --git a/framework/src/test/java/org/onap/cli/fw/cmd/OnapSwaggerCommandTest.java b/framework/src/test/java/org/onap/cli/fw/cmd/OnapSwaggerCommandTest.java index 628b9a42..47e3e050 100644 --- a/framework/src/test/java/org/onap/cli/fw/cmd/OnapSwaggerCommandTest.java +++ b/framework/src/test/java/org/onap/cli/fw/cmd/OnapSwaggerCommandTest.java @@ -55,7 +55,7 @@ public class OnapSwaggerCommandTest { swagger.initializeResult(obj1); } - @Test(expected = NullPointerException.class) + @Test public void initializeResultTest3() throws OnapCommandException { OnapSwaggerCommandImpl swagger = new OnapSwaggerCommandImpl(); swagger.initializeSchema("onap-test-schema.yaml"); -- cgit 1.2.3-korg