ONAP is using basic auth already for some services
and AAF is being used as well. so there are more than
one auth type being used across. to support it,
new property call auth is introduced in service section.
also no-auth is now migrated as auth: none
CLI-29
Change-Id: I151a4669151f67884f9875f47c8df396836ae25b
Signed-off-by: Kanagaraj Manickam k00365106 <kanagaraj.manickam@huawei.com>
16 files changed:
OnapCredentials creds = OnapCommandUtils.fromParameters(this.getParameters());
boolean isAuthRequired = !this.onapService.isNoAuth()
&& "true".equals(paramMap.get(Constants.DEFAULT_PARAMETER_OUTPUT_NO_AUTH).getValue());
OnapCredentials creds = OnapCommandUtils.fromParameters(this.getParameters());
boolean isAuthRequired = !this.onapService.isNoAuth()
&& "true".equals(paramMap.get(Constants.DEFAULT_PARAMETER_OUTPUT_NO_AUTH).getValue());
this.authClient.login();
}
this.authClient.login();
}
if (isAuthRequired) {
this.authClient.logout();
}
if (isAuthRequired) {
this.authClient.logout();
}
*/
private String mode = Constants.MODE_CATALOG;
*/
private String mode = Constants.MODE_CATALOG;
- private boolean noAuth = false;
+ private String authType = Constants.AUTH_BASIC;
public String getMode() {
return mode;
public String getMode() {
return mode;
return this.getMode().equals(Constants.MODE_DIRECT);
}
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() {
}
public String getName() {
public static final String NAME = "name";
public static final String VERSION = "version";
public static final String BASE_PATH = "base_path";
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";
public static final String MODE = "mode";
public static final String MODE_DIRECT = "direct";
public static final String MODE_CATALOG = "catalog";
protected static final List<String> TOP_LEVEL_MANDATORY_LIST = Arrays.asList(ONAP_CMD_SCHEMA_VERSION, NAME,
DESCRIPTION);
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);
protected static final List<String> SERVICE_PARAMS_MANDATORY_LIST = Arrays.asList(NAME, VERSION);
// Validate specific parameters
// Validate specific parameters
- if (serviceMap.containsKey(NO_AUTH)) {
- Object obj = serviceMap.get(NO_AUTH);
+ if (serviceMap.containsKey(AUTH)) {
+ Object obj = serviceMap.get(AUTH);
- schemaErrors.add(SchemaValidate.emptyValue(SERVICE, NO_AUTH));
+ schemaErrors.add(SchemaValidate.emptyValue(SERVICE, AUTH));
} else {
String value = String.valueOf(obj);
} 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));
srv.setName(map.get(key1));
} else if (Constants.VERSION.equals(key1)) {
srv.setVersion(map.get(key1));
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);
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
} else if (Constants.MODE.equals(key1)) {
Object obj = map.get(key1);
//TODO mrkanag Validate and raise exception for invalid case
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.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
name: schema-refresh
description: Onap command to refresh schemas stored in onap_cli_schema folders.
service:
name: schema-refresh
description: Onap command to refresh schemas stored in onap_cli_schema folders.
service:
name: onap-cli
version: 1.0.0
results:
name: onap-cli
version: 1.0.0
results:
name: schema-validate
description: Onap command to validate schema
service:
name: schema-validate
description: Onap command to validate schema
service:
name: onap-cli
version: 1.0.0
default_parameters:
name: onap-cli
version: 1.0.0
default_parameters:
import static org.junit.Assert.assertTrue;
import org.junit.Test;
import static org.junit.Assert.assertTrue;
import org.junit.Test;
+import org.onap.cli.fw.conf.Constants;
public class OnapServiceTest {
public class OnapServiceTest {
ser.setName("name");
ser.setVersion("1.0");
ser.setBasePath("basePath");
ser.setName("name");
ser.setVersion("1.0");
ser.setBasePath("basePath");
+ ser.setAuthType(Constants.AUTH_NONE);
assertTrue(ser.getName().equals("name") && ser.getVersion().equals("1.0")
&& ser.getBasePath().equals("basePath") && ser.isNoAuth());
assertTrue(ser.getName().equals("name") && ser.getVersion().equals("1.0")
&& ser.getBasePath().equals("basePath") && ser.isNoAuth());
service:
name: sample
version: v1
service:
name: sample
version: v1
parameters:
- name: bool-param
type: bool
parameters:
- name: bool-param
type: bool
onap_cmd_schema_version: 1.0
onap_cmd_schema_version: 1.0
-service:
- no-auth: false
default_parameters:
exclude:
- onap-username
\ No newline at end of file
default_parameters:
exclude:
- onap-username
\ No newline at end of file
onap_cmd_schema_version: 1.0
service:
onap_cmd_schema_version: 1.0
service:
default_parameters:
include:
- onap-username
\ No newline at end of file
default_parameters:
include:
- onap-username
\ No newline at end of file
service:
name: sample
version: v1
service:
name: sample
version: v1
parameters:
- name: bool-param
type: bool
parameters:
- name: bool-param
type: bool
service:
name: sample
version: v1
service:
name: sample
version: v1
parameters:
- name: service-name
description: Onap service name
parameters:
- name: service-name
description: Onap service name
service:
name: msb
version: v1
service:
name: msb
version: v1
results:
direction: landscape
attributes:
results:
direction: landscape
attributes:
service:
name: msb
version: v1
service:
name: msb
version: v1
parameters:
- name: service-name
description: Onap service name
parameters:
- name: service-name
description: Onap service name