summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--framework/src/main/java/org/onap/cli/fw/OnapCommand.java3
-rw-r--r--framework/src/main/java/org/onap/cli/fw/ad/OnapService.java14
-rw-r--r--framework/src/main/java/org/onap/cli/fw/conf/Constants.java5
-rw-r--r--framework/src/main/java/org/onap/cli/fw/schema/AbstractSchemaValidate.java12
-rw-r--r--framework/src/main/java/org/onap/cli/fw/utils/OnapCommandUtils.java5
-rw-r--r--framework/src/main/resources/onap.properties2
-rw-r--r--framework/src/main/resources/schema-refresh.yaml2
-rw-r--r--framework/src/main/resources/schema-validate.yaml2
-rw-r--r--framework/src/test/java/org/onap/cli/fw/ad/OnapServiceTest.java3
-rw-r--r--framework/src/test/resources/onap-test-schema.yaml2
-rw-r--r--framework/src/test/resources/sample-test-invalid-exclude-noauth.yaml2
-rw-r--r--framework/src/test/resources/sample-test-invalid-include-noauth.yaml2
-rw-r--r--framework/src/test/resources/sample-test-schema.yaml2
-rw-r--r--main/src/test/resources/onap-cli-schema/sample-create-schema.yaml2
-rw-r--r--plugins/msb/src/main/resources/microservice-list-schema.yaml2
-rw-r--r--plugins/msb/src/main/resources/microservice-show-schema.yaml2
16 files changed, 33 insertions, 29 deletions
diff --git a/framework/src/main/java/org/onap/cli/fw/OnapCommand.java b/framework/src/main/java/org/onap/cli/fw/OnapCommand.java
index 13e67fc6..7e15fbab 100644
--- a/framework/src/main/java/org/onap/cli/fw/OnapCommand.java
+++ b/framework/src/main/java/org/onap/cli/fw/OnapCommand.java
@@ -255,7 +255,6 @@ public abstract class OnapCommand {
}
try {
- // login
OnapCredentials creds = OnapCommandUtils.fromParameters(this.getParameters());
boolean isAuthRequired = !this.onapService.isNoAuth()
&& "true".equals(paramMap.get(Constants.DEFAULT_PARAMETER_OUTPUT_NO_AUTH).getValue());
@@ -268,10 +267,8 @@ public abstract class OnapCommand {
this.authClient.login();
}
- // execute
this.run();
- // logout
if (isAuthRequired) {
this.authClient.logout();
}
diff --git a/framework/src/main/java/org/onap/cli/fw/ad/OnapService.java b/framework/src/main/java/org/onap/cli/fw/ad/OnapService.java
index f9d4a638..c770d17c 100644
--- a/framework/src/main/java/org/onap/cli/fw/ad/OnapService.java
+++ b/framework/src/main/java/org/onap/cli/fw/ad/OnapService.java
@@ -43,7 +43,7 @@ public class OnapService {
*/
private String mode = Constants.MODE_CATALOG;
- private boolean noAuth = false;
+ private String authType = Constants.AUTH_BASIC;
public String getMode() {
return mode;
@@ -57,12 +57,16 @@ public class OnapService {
return this.getMode().equals(Constants.MODE_DIRECT);
}
- public boolean isNoAuth() {
- return noAuth;
+ public String getAuthType() {
+ return this.authType;
+ }
+
+ public void setAuthType(String auth) {
+ this.authType = auth;
}
- public void setNoAuth(boolean noAuth) {
- this.noAuth = noAuth;
+ public boolean isNoAuth() {
+ return this.authType.equalsIgnoreCase(Constants.AUTH_NONE);
}
public String getName() {
diff --git a/framework/src/main/java/org/onap/cli/fw/conf/Constants.java b/framework/src/main/java/org/onap/cli/fw/conf/Constants.java
index d711ba25..8eb88397 100644
--- a/framework/src/main/java/org/onap/cli/fw/conf/Constants.java
+++ b/framework/src/main/java/org/onap/cli/fw/conf/Constants.java
@@ -74,7 +74,9 @@ public class Constants {
public static final String NAME = "name";
public static final String VERSION = "version";
public static final String BASE_PATH = "base_path";
- public static final String NO_AUTH = "no-auth";
+ public static final String AUTH = "auth";
+ public static final String AUTH_NONE = "none";
+ public static final String AUTH_BASIC = "basic";
public static final String MODE = "mode";
public static final String MODE_DIRECT = "direct";
public static final String MODE_CATALOG = "catalog";
@@ -171,3 +173,4 @@ public class Constants {
}
}
+
diff --git a/framework/src/main/java/org/onap/cli/fw/schema/AbstractSchemaValidate.java b/framework/src/main/java/org/onap/cli/fw/schema/AbstractSchemaValidate.java
index 28671521..1b0a2beb 100644
--- a/framework/src/main/java/org/onap/cli/fw/schema/AbstractSchemaValidate.java
+++ b/framework/src/main/java/org/onap/cli/fw/schema/AbstractSchemaValidate.java
@@ -74,7 +74,7 @@ public abstract class AbstractSchemaValidate implements SchemaValidate {
protected static final List<String> TOP_LEVEL_MANDATORY_LIST = Arrays.asList(ONAP_CMD_SCHEMA_VERSION, NAME,
DESCRIPTION);
- protected static final List<String> SERVICE_PARAMS_LIST = Arrays.asList(NAME, VERSION, NO_AUTH);
+ protected static final List<String> SERVICE_PARAMS_LIST = Arrays.asList(NAME, VERSION, AUTH);
protected static final List<String> SERVICE_PARAMS_MANDATORY_LIST = Arrays.asList(NAME, VERSION);
@@ -363,14 +363,14 @@ public abstract class AbstractSchemaValidate implements SchemaValidate {
// Validate specific parameters
- if (serviceMap.containsKey(NO_AUTH)) {
- Object obj = serviceMap.get(NO_AUTH);
+ if (serviceMap.containsKey(AUTH)) {
+ Object obj = serviceMap.get(AUTH);
if (obj == null) {
- schemaErrors.add(SchemaValidate.emptyValue(SERVICE, NO_AUTH));
+ schemaErrors.add(SchemaValidate.emptyValue(SERVICE, AUTH));
} else {
String value = String.valueOf(obj);
- if (!validateBoolean(value)) {
- schemaErrors.add(SchemaValidate.invalidBooleanValueMessage(SERVICE, NO_AUTH, value));
+ if (validateBoolean(value)) {
+ schemaErrors.add(SchemaValidate.invalidBooleanValueMessage(SERVICE, AUTH, value));
}
}
}
diff --git a/framework/src/main/java/org/onap/cli/fw/utils/OnapCommandUtils.java b/framework/src/main/java/org/onap/cli/fw/utils/OnapCommandUtils.java
index 9a425397..512d0b22 100644
--- a/framework/src/main/java/org/onap/cli/fw/utils/OnapCommandUtils.java
+++ b/framework/src/main/java/org/onap/cli/fw/utils/OnapCommandUtils.java
@@ -248,9 +248,10 @@ public class OnapCommandUtils {
srv.setName(map.get(key1));
} else if (Constants.VERSION.equals(key1)) {
srv.setVersion(map.get(key1));
- } else if (Constants.NO_AUTH.equals(key1)) {
+ } else if (Constants.AUTH.equals(key1)) {
Object obj = map.get(key1);
- srv.setNoAuth("true".equalsIgnoreCase(obj.toString()));
+ //TODO mrkanag Validate and raise exception for invalid case
+ srv.setAuthType(obj.toString());
} else if (Constants.MODE.equals(key1)) {
Object obj = map.get(key1);
//TODO mrkanag Validate and raise exception for invalid case
diff --git a/framework/src/main/resources/onap.properties b/framework/src/main/resources/onap.properties
index 47b02c8c..7eb8e598 100644
--- a/framework/src/main/resources/onap.properties
+++ b/framework/src/main/resources/onap.properties
@@ -11,4 +11,4 @@ cli.auth_service=auth
cli.exclude_params_internal_cmd=onap-username,onap-password,host-url,no-auth
cli.no_auth_disable_include_params_external_cmd=onap-username,onap-password,host-url,no-auth
cli.no_auth_enable_exclude_params_external_cmd=onap-username,onap-password,no-auth
-cli.no_auth_enable_include_params_external_cmd=host-url \ No newline at end of file
+cli.no_auth_enable_include_params_external_cmd=host-url
diff --git a/framework/src/main/resources/schema-refresh.yaml b/framework/src/main/resources/schema-refresh.yaml
index f64b0545..59f2496c 100644
--- a/framework/src/main/resources/schema-refresh.yaml
+++ b/framework/src/main/resources/schema-refresh.yaml
@@ -2,7 +2,7 @@ onap_cmd_schema_version: 1.0
name: schema-refresh
description: Onap command to refresh schemas stored in onap_cli_schema folders.
service:
- no-auth: true
+ auth: none
name: onap-cli
version: 1.0.0
results:
diff --git a/framework/src/main/resources/schema-validate.yaml b/framework/src/main/resources/schema-validate.yaml
index 66787912..76945793 100644
--- a/framework/src/main/resources/schema-validate.yaml
+++ b/framework/src/main/resources/schema-validate.yaml
@@ -2,7 +2,7 @@ onap_cmd_schema_version: 1.0
name: schema-validate
description: Onap command to validate schema
service:
- no-auth: true
+ auth: none
name: onap-cli
version: 1.0.0
default_parameters:
diff --git a/framework/src/test/java/org/onap/cli/fw/ad/OnapServiceTest.java b/framework/src/test/java/org/onap/cli/fw/ad/OnapServiceTest.java
index f0ec8c63..9ceba67d 100644
--- a/framework/src/test/java/org/onap/cli/fw/ad/OnapServiceTest.java
+++ b/framework/src/test/java/org/onap/cli/fw/ad/OnapServiceTest.java
@@ -19,6 +19,7 @@ package org.onap.cli.fw.ad;
import static org.junit.Assert.assertTrue;
import org.junit.Test;
+import org.onap.cli.fw.conf.Constants;
public class OnapServiceTest {
@@ -28,7 +29,7 @@ public class OnapServiceTest {
ser.setName("name");
ser.setVersion("1.0");
ser.setBasePath("basePath");
- ser.setNoAuth(true);
+ ser.setAuthType(Constants.AUTH_NONE);
assertTrue(ser.getName().equals("name") && ser.getVersion().equals("1.0")
&& ser.getBasePath().equals("basePath") && ser.isNoAuth());
diff --git a/framework/src/test/resources/onap-test-schema.yaml b/framework/src/test/resources/onap-test-schema.yaml
index df260502..aa656064 100644
--- a/framework/src/test/resources/onap-test-schema.yaml
+++ b/framework/src/test/resources/onap-test-schema.yaml
@@ -4,7 +4,7 @@ description: Onap sample command to test the command features
service:
name: sample
version: v1
- no-auth: true
+ auth: none
parameters:
- name: bool-param
type: bool
diff --git a/framework/src/test/resources/sample-test-invalid-exclude-noauth.yaml b/framework/src/test/resources/sample-test-invalid-exclude-noauth.yaml
index bad12e60..1de471c8 100644
--- a/framework/src/test/resources/sample-test-invalid-exclude-noauth.yaml
+++ b/framework/src/test/resources/sample-test-invalid-exclude-noauth.yaml
@@ -1,6 +1,4 @@
onap_cmd_schema_version: 1.0
-service:
- no-auth: false
default_parameters:
exclude:
- onap-username \ No newline at end of file
diff --git a/framework/src/test/resources/sample-test-invalid-include-noauth.yaml b/framework/src/test/resources/sample-test-invalid-include-noauth.yaml
index c4384ca0..b80ac57f 100644
--- a/framework/src/test/resources/sample-test-invalid-include-noauth.yaml
+++ b/framework/src/test/resources/sample-test-invalid-include-noauth.yaml
@@ -1,6 +1,6 @@
onap_cmd_schema_version: 1.0
service:
- no-auth: true
+ auth: none
default_parameters:
include:
- onap-username \ No newline at end of file
diff --git a/framework/src/test/resources/sample-test-schema.yaml b/framework/src/test/resources/sample-test-schema.yaml
index a480147d..dbb5cbed 100644
--- a/framework/src/test/resources/sample-test-schema.yaml
+++ b/framework/src/test/resources/sample-test-schema.yaml
@@ -4,7 +4,7 @@ description: Onap sample command to test the command features
service:
name: sample
version: v1
- no-auth: true
+ auth: none
parameters:
- name: bool-param
type: bool
diff --git a/main/src/test/resources/onap-cli-schema/sample-create-schema.yaml b/main/src/test/resources/onap-cli-schema/sample-create-schema.yaml
index 6e775334..6fb12beb 100644
--- a/main/src/test/resources/onap-cli-schema/sample-create-schema.yaml
+++ b/main/src/test/resources/onap-cli-schema/sample-create-schema.yaml
@@ -4,7 +4,7 @@ description: Sample create into Onap
service:
name: sample
version: v1
- no-auth: true
+ auth: none
parameters:
- name: service-name
description: Onap service name
diff --git a/plugins/msb/src/main/resources/microservice-list-schema.yaml b/plugins/msb/src/main/resources/microservice-list-schema.yaml
index 79dca5b1..42fa0ec4 100644
--- a/plugins/msb/src/main/resources/microservice-list-schema.yaml
+++ b/plugins/msb/src/main/resources/microservice-list-schema.yaml
@@ -4,7 +4,7 @@ description: Lists the registetred micro services in Onap
service:
name: msb
version: v1
- no-auth: true
+ auth: none
results:
direction: landscape
attributes:
diff --git a/plugins/msb/src/main/resources/microservice-show-schema.yaml b/plugins/msb/src/main/resources/microservice-show-schema.yaml
index 47e33c6a..26cccfd3 100644
--- a/plugins/msb/src/main/resources/microservice-show-schema.yaml
+++ b/plugins/msb/src/main/resources/microservice-show-schema.yaml
@@ -4,7 +4,7 @@ description: Details the registered microservice in Onap
service:
name: msb
version: v1
- no-auth: true
+ auth: none
parameters:
- name: service-name
description: Onap service name