aboutsummaryrefslogtreecommitdiffstats
path: root/catalog-be
diff options
context:
space:
mode:
authorxuegao <xue.gao@intl.att.com>2020-12-18 10:37:23 +0100
committerXue Gao <xue.gao@intl.att.com>2021-01-19 15:32:33 +0000
commita856d54c8df7bf3a0212b4c7fd8f18a6a6b91449 (patch)
treef4a5b2a4ef5cc2865282b108bd2103778d7fb9e3 /catalog-be
parent27fa75194efcf77c93b645ef7b412668ac3f5d38 (diff)
Add basic auth header
Add basic auth header for sdc-backend-init python scripts. Issue-ID: OJSI-273 Signed-off-by: xuegao <xue.gao@intl.att.com> Change-Id: I3559d5792509db0f65b202a731545083c7c91c96 Signed-off-by: xuegao <xue.gao@intl.att.com>
Diffstat (limited to 'catalog-be')
-rw-r--r--catalog-be/sdc-backend-init/chef-repo/cookbooks/sdc-catalog-be-setup/attributes/default.rb6
-rw-r--r--catalog-be/sdc-backend-init/chef-repo/cookbooks/sdc-catalog-be-setup/recipes/1_create_consumer_and_user.rb17
-rw-r--r--catalog-be/sdc-backend-init/chef-repo/cookbooks/sdc-catalog-be-setup/recipes/2_check_Backend.rb15
-rw-r--r--catalog-be/sdc-backend-init/chef-repo/cookbooks/sdc-catalog-be-setup/recipes/3_import_Normatives.rb14
-rw-r--r--catalog-be/src/main/docker/backend/chef-repo/cookbooks/sdc-catalog-be/attributes/default.rb2
-rw-r--r--catalog-be/src/main/docker/backend/chef-repo/cookbooks/sdc-catalog-be/templates/default/BE-configuration.yaml.erb2
-rw-r--r--catalog-be/src/main/resources/scripts/sdcBePy/common/healthCheck.py11
-rw-r--r--catalog-be/src/main/resources/scripts/sdcBePy/common/normative/toscaElements.py4
-rw-r--r--catalog-be/src/main/resources/scripts/sdcBePy/common/normative/toscaTypes.py4
-rwxr-xr-xcatalog-be/src/main/resources/scripts/sdcBePy/common/sdcBeProxy.py32
-rw-r--r--catalog-be/src/main/resources/scripts/sdcBePy/consumers/run.py8
-rw-r--r--catalog-be/src/main/resources/scripts/sdcBePy/tosca/imports/runNormativeElement.py4
-rw-r--r--catalog-be/src/main/resources/scripts/sdcBePy/tosca/main.py19
-rwxr-xr-xcatalog-be/src/main/resources/scripts/sdcBePy/users/run.py7
-rw-r--r--catalog-be/src/test/resources/config/catalog-be/configuration.yaml6
15 files changed, 109 insertions, 42 deletions
diff --git a/catalog-be/sdc-backend-init/chef-repo/cookbooks/sdc-catalog-be-setup/attributes/default.rb b/catalog-be/sdc-backend-init/chef-repo/cookbooks/sdc-catalog-be-setup/attributes/default.rb
index 792d600548..682885312e 100644
--- a/catalog-be/sdc-backend-init/chef-repo/cookbooks/sdc-catalog-be-setup/attributes/default.rb
+++ b/catalog-be/sdc-backend-init/chef-repo/cookbooks/sdc-catalog-be-setup/attributes/default.rb
@@ -1 +1,5 @@
-#
+#BasicAuth
+default['basic_auth']['enabled'] = true
+default['basic_auth'][:user_name] = "testName"
+default['basic_auth'][:user_pass] = "testPass"
+
diff --git a/catalog-be/sdc-backend-init/chef-repo/cookbooks/sdc-catalog-be-setup/recipes/1_create_consumer_and_user.rb b/catalog-be/sdc-backend-init/chef-repo/cookbooks/sdc-catalog-be-setup/recipes/1_create_consumer_and_user.rb
index 68cfcab6ea..5585bc0b25 100644
--- a/catalog-be/sdc-backend-init/chef-repo/cookbooks/sdc-catalog-be-setup/recipes/1_create_consumer_and_user.rb
+++ b/catalog-be/sdc-backend-init/chef-repo/cookbooks/sdc-catalog-be-setup/recipes/1_create_consumer_and_user.rb
@@ -1,3 +1,4 @@
+require 'base64'
if node['disableHttp']
protocol = "https"
https_flag = "--https"
@@ -15,9 +16,21 @@ else
user_conf_dir = ""
end
+if node['basic_auth']
+ basic_auth_enabled = node['basic_auth']['enabled']
+ basic_auth_user = node['basic_auth']['user_name']
+ basic_auth_pass = node['basic_auth']['user_pass']
+ if basic_auth_enabled
+ basic_auth_config = "--header " + Base64.encode64(basic_auth_user + ":" + basic_auth_pass)
+ else
+ # set default user configuration file
+ basic_auth_config = ""
+ end
+end
+
bash "executing-create_users" do
code <<-EOH
- sdcuserinit -i #{node['Nodes']['BE']} -p #{be_port} #{user_conf_dir} #{https_flag}
+ sdcuserinit -i #{node['Nodes']['BE']} -p #{be_port} #{basic_auth_config} #{user_conf_dir} #{https_flag}
rc=$?
if [[ $rc != 0 ]]; then exit $rc; fi
EOH
@@ -26,7 +39,7 @@ end
bash "executing-create_consumers" do
code <<-EOH
- sdcconsumerinit -i #{node['Nodes']['BE']} -p #{be_port} #{https_flag}
+ sdcconsumerinit -i #{node['Nodes']['BE']} -p #{be_port} #{basic_auth_config} #{https_flag}
rc=$?
if [[ $rc != 0 ]]; then exit $rc; fi
EOH
diff --git a/catalog-be/sdc-backend-init/chef-repo/cookbooks/sdc-catalog-be-setup/recipes/2_check_Backend.rb b/catalog-be/sdc-backend-init/chef-repo/cookbooks/sdc-catalog-be-setup/recipes/2_check_Backend.rb
index e35caed5b1..ffa1fee66b 100644
--- a/catalog-be/sdc-backend-init/chef-repo/cookbooks/sdc-catalog-be-setup/recipes/2_check_Backend.rb
+++ b/catalog-be/sdc-backend-init/chef-repo/cookbooks/sdc-catalog-be-setup/recipes/2_check_Backend.rb
@@ -1,3 +1,4 @@
+require 'base64'
if node['disableHttp']
protocol = "https"
https_flag = "--https"
@@ -8,9 +9,21 @@ else
be_port = node['BE']['http_port']
end
+if node['basic_auth']
+ basic_auth_enabled = node['basic_auth']['enabled']
+ basic_auth_user = node['basic_auth']['user_name']
+ basic_auth_pass = node['basic_auth']['user_pass']
+ if basic_auth_enabled
+ basic_auth_config = "--header " + Base64.encode64(basic_auth_user + ":" + basic_auth_pass)
+ else
+ # set default user configuration file
+ basic_auth_config = ""
+ end
+end
+
bash "executing-check_backend_health" do
code <<-EOH
- sdccheckbackend -i #{node['Nodes']['BE']} -p #{be_port} #{https_flag}
+ sdccheckbackend -i #{node['Nodes']['BE']} -p #{be_port} #{basic_auth_config} #{https_flag}
rc=$?
if [[ $rc != 0 ]]; then exit $rc; fi
EOH
diff --git a/catalog-be/sdc-backend-init/chef-repo/cookbooks/sdc-catalog-be-setup/recipes/3_import_Normatives.rb b/catalog-be/sdc-backend-init/chef-repo/cookbooks/sdc-catalog-be-setup/recipes/3_import_Normatives.rb
index e9e44c0df9..04fb25f49e 100644
--- a/catalog-be/sdc-backend-init/chef-repo/cookbooks/sdc-catalog-be-setup/recipes/3_import_Normatives.rb
+++ b/catalog-be/sdc-backend-init/chef-repo/cookbooks/sdc-catalog-be-setup/recipes/3_import_Normatives.rb
@@ -1,3 +1,4 @@
+require 'base64'
be_ip=node['Nodes'][:BE]
if node['disableHttp']
@@ -10,6 +11,17 @@ else
param="-i #{be_ip} -p #{be_port}"
end
+if node['basic_auth']
+ basic_auth_enabled = node['basic_auth']['enabled']
+ basic_auth_user = node['basic_auth']['user_name']
+ basic_auth_pass = node['basic_auth']['user_pass']
+ if basic_auth_enabled
+ basic_auth_config = "--header " + Base64.encode64(basic_auth_user + ":" + basic_auth_pass)
+ else
+ # set default user configuration file
+ basic_auth_config = ""
+ end
+end
cookbook_file "/var/tmp/normatives.tar.gz" do
source "normatives.tar.gz"
end
@@ -25,7 +37,7 @@ bash "executing-import_Normatives" do
# add --debug to the sdcinit command to enable debug
cd /var/tmp/normatives/import/tosca
- sdcinit #{param} > /var/lib/jetty/logs/init.log
+ sdcinit #{param} #{basic_auth_config} > /var/lib/jetty/logs/init.log
rc=$?
if [[ $rc != 0 ]]; then exit $rc; fi
diff --git a/catalog-be/src/main/docker/backend/chef-repo/cookbooks/sdc-catalog-be/attributes/default.rb b/catalog-be/src/main/docker/backend/chef-repo/cookbooks/sdc-catalog-be/attributes/default.rb
index 40411f2041..614433c2e7 100644
--- a/catalog-be/src/main/docker/backend/chef-repo/cookbooks/sdc-catalog-be/attributes/default.rb
+++ b/catalog-be/src/main/docker/backend/chef-repo/cookbooks/sdc-catalog-be/attributes/default.rb
@@ -28,7 +28,7 @@ default['DCAE_BE_VIP'] = "dcae-be"
default['basic_auth']['enabled'] = false
default['basic_auth'][:user_name] = "testName"
default['basic_auth'][:user_pass] = "testPass"
-default['basic_auth']['excludedUrls'] = "/sdc2/rest/healthCheck,/sdc2/rest/v1/user,/sdc2/rest/v1/user/jh0003,/sdc2/rest/v1/screen,/sdc2/rest/v1/consumers,/sdc2/rest/v1/catalog/uploadType/datatypes,/sdc2/rest/v1/catalog/upload/multipart"
+default['basic_auth']['excludedUrls'] = "/sdc2/rest/healthCheck"
#Cassandra
default['cassandra']['cassandra_port'] = 9042
diff --git a/catalog-be/src/main/docker/backend/chef-repo/cookbooks/sdc-catalog-be/templates/default/BE-configuration.yaml.erb b/catalog-be/src/main/docker/backend/chef-repo/cookbooks/sdc-catalog-be/templates/default/BE-configuration.yaml.erb
index 1e1888e95b..e8d2ece84b 100644
--- a/catalog-be/src/main/docker/backend/chef-repo/cookbooks/sdc-catalog-be/templates/default/BE-configuration.yaml.erb
+++ b/catalog-be/src/main/docker/backend/chef-repo/cookbooks/sdc-catalog-be/templates/default/BE-configuration.yaml.erb
@@ -99,7 +99,7 @@ basicAuth:
enabled: <%= @basic_auth_flag %>
userName: <%= @user_name %>
userPass: <%= @user_pass %>
- excludedUrls: "/sdc2/rest/healthCheck,/sdc2/rest/v1/user,/sdc2/rest/v1/user/jh0003,/sdc2/rest/v1/screen,/sdc2/rest/v1/consumers,/sdc2/rest/v1/catalog/uploadType/datatypes,/sdc2/rest/v1/catalog/upload/multipart,/sdc2/rest/v1/catalog/uploadType/capability,/sdc2/rest/v1/catalog/uploadType/relationship,/sdc2/rest/v1/catalog/uploadType/interfaceLifecycle,/sdc2/rest/v1/catalog/uploadType/categories,/sdc2/rest/v1/catalog/uploadType/grouptypes,/sdc2/rest/v1/catalog/uploadType/policytypes,/sdc2/rest/v1/catalog/uploadType/annotationtypes"
+ excludedUrls: "/sdc2/rest/healthCheck"
cassandraConfig:
cassandraHosts: [<%= @cassandra_ip %>]
diff --git a/catalog-be/src/main/resources/scripts/sdcBePy/common/healthCheck.py b/catalog-be/src/main/resources/scripts/sdcBePy/common/healthCheck.py
index c99db5b434..a0acc90d44 100644
--- a/catalog-be/src/main/resources/scripts/sdcBePy/common/healthCheck.py
+++ b/catalog-be/src/main/resources/scripts/sdcBePy/common/healthCheck.py
@@ -12,9 +12,9 @@ from sdcBePy.common.sdcBeProxy import SdcBeProxy
colors = BColors()
-def check_backend(sdc_be_proxy=None, reply_append_count=1, be_host=None, be_port=None, scheme=None, debug=False):
+def check_backend(sdc_be_proxy=None, reply_append_count=1, be_host=None, be_port=None, header=None, scheme=None, debug=False):
if sdc_be_proxy is None:
- sdc_be_proxy = SdcBeProxy(be_host, be_port, scheme, debug=debug)
+ sdc_be_proxy = SdcBeProxy(be_host, be_port, header, scheme, debug=debug)
for i in range(1, reply_append_count + 1):
if sdc_be_proxy.check_backend() == 200:
@@ -28,9 +28,9 @@ def check_backend(sdc_be_proxy=None, reply_append_count=1, be_host=None, be_port
return False
-def run(be_host, be_port, protocol):
+def run(be_host, be_port, header, protocol):
if not check_backend(reply_append_count=properties.retry_attempts, be_host=be_host,
- be_port=be_port, scheme=protocol):
+ be_port=be_port, header=header, scheme=protocol):
print('[ERROR]: ' + time.strftime('%Y/%m/%d %H:%M:%S') + colors.FAIL + ' Backend is DOWN :-(' + colors.END_C)
sys.exit()
@@ -40,12 +40,13 @@ def get_args():
parser.add_argument('-i', '--ip', required=True)
parser.add_argument('-p', '--port', required=True)
+ parser.add_argument('--header')
parser.add_argument('--https', action='store_true')
args = parser.parse_args()
init_properties(10, 10)
- return [args.ip, args.port, 'https' if args.https else 'http']
+ return [args.ip, args.port, args.header, 'https' if args.https else 'http']
def main():
diff --git a/catalog-be/src/main/resources/scripts/sdcBePy/common/normative/toscaElements.py b/catalog-be/src/main/resources/scripts/sdcBePy/common/normative/toscaElements.py
index 5cdca0a095..5ef3173907 100644
--- a/catalog-be/src/main/resources/scripts/sdcBePy/common/normative/toscaElements.py
+++ b/catalog-be/src/main/resources/scripts/sdcBePy/common/normative/toscaElements.py
@@ -9,11 +9,11 @@ from sdcBePy.common.errors import ResourceCreationError
def process_and_create_normative_element(normative_element,
- scheme=None, be_host=None, be_port=None, admin_user=None, sdc_be_proxy=None,
+ scheme=None, be_host=None, be_port=None, header=None, admin_user=None, sdc_be_proxy=None,
debug=False,
exit_on_success=False):
if sdc_be_proxy is None:
- sdc_be_proxy = SdcBeProxy(be_host, be_port, scheme, admin_user, debug=debug)
+ sdc_be_proxy = SdcBeProxy(be_host, be_port, header, scheme, admin_user, debug=debug)
file_dir, url_suffix, element_name, element_from_name, with_metadata = normative_element.get_parameters()
_create_normative_element(sdc_be_proxy,
diff --git a/catalog-be/src/main/resources/scripts/sdcBePy/common/normative/toscaTypes.py b/catalog-be/src/main/resources/scripts/sdcBePy/common/normative/toscaTypes.py
index 5d64f448d3..97fb2d1d7e 100644
--- a/catalog-be/src/main/resources/scripts/sdcBePy/common/normative/toscaTypes.py
+++ b/catalog-be/src/main/resources/scripts/sdcBePy/common/normative/toscaTypes.py
@@ -9,13 +9,13 @@ from sdcBePy.common.sdcBeProxy import SdcBeProxy
def process_and_create_normative_types(normative_type,
- scheme=None, be_host=None, be_port=None, admin_user=None,
+ scheme=None, be_host=None, be_port=None, header=None, admin_user=None,
sdc_be_proxy=None,
update_version=False,
debug=False,
exit_on_success=False):
if sdc_be_proxy is None:
- sdc_be_proxy = SdcBeProxy(be_host, be_port, scheme, admin_user, debug=debug)
+ sdc_be_proxy = SdcBeProxy(be_host, be_port, header, scheme, admin_user, debug=debug)
file_dir, normative_type_list = normative_type.get_parameters()
diff --git a/catalog-be/src/main/resources/scripts/sdcBePy/common/sdcBeProxy.py b/catalog-be/src/main/resources/scripts/sdcBePy/common/sdcBeProxy.py
index d9aa260b80..169979ae73 100755
--- a/catalog-be/src/main/resources/scripts/sdcBePy/common/sdcBeProxy.py
+++ b/catalog-be/src/main/resources/scripts/sdcBePy/common/sdcBeProxy.py
@@ -15,21 +15,22 @@ class SdcBeProxy:
BODY_SEPARATOR = "\r\n\r\n"
CHARTSET = 'UTF-8'
- def __init__(self, be_ip, be_port, scheme, user_id="jh0003",
+ def __init__(self, be_ip, be_port, header, scheme, user_id="jh0003",
debug=False, connector=None):
if not check_arguments_not_none(be_ip, be_port, scheme, user_id):
raise AttributeError("The be_host, be_port, scheme or admin_user are missing")
url = get_url(be_ip, be_port, scheme)
self.con = connector if connector \
- else CurlConnector(url, user_id, scheme=scheme, debug=debug)
+ else CurlConnector(url, user_id, header, scheme=scheme, debug=debug)
def check_backend(self):
return self.con.get('/sdc2/rest/v1/user/jh0003')
def check_user(self, user_name):
- return self.con.get("/sdc2/rest/v1/user/" + user_name)
+ return self.con.get("/sdc2/rest/v1/user" + user_name)
def create_user(self, first_name, last_name, user_id, email, role):
+
return self.con.post('/sdc2/rest/v1/user', json.dumps({
'firstName': first_name,
'lastName': last_name,
@@ -39,10 +40,10 @@ class SdcBeProxy:
}))
def check_consumer(self, consumer_name):
- return self.con.get("/sdc2/rest/v1/consumers/" + consumer_name)
+ return self.con.get("/sdc2/rest/v1/consumers" + consumer_name)
def create_consumer(self, consumer_name, slat, password):
- return self.con.post("/sdc2/rest/v1/consumers/", json.dumps({
+ return self.con.post("/sdc2/rest/v1/consumers", json.dumps({
'consumerName': consumer_name,
'consumerSalt': slat,
'consumerPassword': password
@@ -67,7 +68,7 @@ class CurlConnector:
CONTENT_TYPE_HEADER = "Content-Type: application/json"
ACCEPT_HEADER = "Accept: application/json; charset=UTF-8"
- def __init__(self, url, user_id_header, buffer=None, scheme="http", debug=False):
+ def __init__(self, url, user_id_header, header, buffer=None, scheme="http", debug=False):
self.c = pycurl.Curl()
self.c.setopt(pycurl.HEADER, True)
@@ -82,6 +83,11 @@ class CurlConnector:
if not buffer:
self.buffer = BytesIO()
+ if header is None:
+ self.basicauth_header = ""
+ else:
+ self.basicauth_header = "Authorization: Basic " + header
+
self.url = url
self._check_schema(scheme)
@@ -90,7 +96,9 @@ class CurlConnector:
self.c.setopt(pycurl.URL, self.url + path)
self.c.setopt(pycurl.HTTPHEADER, [self.user_header,
CurlConnector.CONTENT_TYPE_HEADER,
- CurlConnector.ACCEPT_HEADER])
+ CurlConnector.ACCEPT_HEADER,
+ self.basicauth_header])
+
if with_buffer:
write = self.buffer.write if not buffer else buffer.write
@@ -105,9 +113,11 @@ class CurlConnector:
try:
self.c.setopt(pycurl.URL, self.url + path)
self.c.setopt(pycurl.POST, 1)
+
self.c.setopt(pycurl.HTTPHEADER, [self.user_header,
- CurlConnector.CONTENT_TYPE_HEADER,
- CurlConnector.ACCEPT_HEADER])
+ CurlConnector.CONTENT_TYPE_HEADER,
+ CurlConnector.ACCEPT_HEADER,
+ self.basicauth_header])
self.c.setopt(pycurl.POSTFIELDS, data)
@@ -122,7 +132,9 @@ class CurlConnector:
try:
self.c.setopt(pycurl.URL, self.url + path)
self.c.setopt(pycurl.POST, 1)
- self.c.setopt(pycurl.HTTPHEADER, [self.user_header])
+ self.c.setopt(pycurl.HTTPHEADER, [self.user_header,
+ self.basicauth_header])
+
self.c.setopt(pycurl.HTTPPOST, post_body)
diff --git a/catalog-be/src/main/resources/scripts/sdcBePy/consumers/run.py b/catalog-be/src/main/resources/scripts/sdcBePy/consumers/run.py
index 1fb766227b..8ea1d1cf64 100644
--- a/catalog-be/src/main/resources/scripts/sdcBePy/consumers/run.py
+++ b/catalog-be/src/main/resources/scripts/sdcBePy/consumers/run.py
@@ -7,8 +7,8 @@ from sdcBePy.consumers.models.consumerCandidateList import get_consumers
from sdcBePy.users.run import colors
-def be_consumers_init(be_ip, be_port, protocol, consumer_candidate_list):
- sdc_be_proxy = SdcBeProxy(be_ip, be_port, protocol)
+def be_consumers_init(be_ip, be_port, header, protocol, consumer_candidate_list):
+ sdc_be_proxy = SdcBeProxy(be_ip, be_port, header, protocol)
if check_backend(sdc_be_proxy, properties.retry_attempts):
for consumer in consumer_candidate_list:
if sdc_be_proxy.check_user(consumer.consumer_name) != 200:
@@ -28,8 +28,8 @@ def be_consumers_init(be_ip, be_port, protocol, consumer_candidate_list):
def main():
- be_ip, be_port, protocol = get_args()
- be_consumers_init(be_ip, be_port, protocol, get_consumers())
+ be_ip, be_port, header, protocol = get_args()
+ be_consumers_init(be_ip, be_port, header, protocol, get_consumers())
if __name__ == '__main__':
diff --git a/catalog-be/src/main/resources/scripts/sdcBePy/tosca/imports/runNormativeElement.py b/catalog-be/src/main/resources/scripts/sdcBePy/tosca/imports/runNormativeElement.py
index 1bdb1504b2..ce5eca427a 100644
--- a/catalog-be/src/main/resources/scripts/sdcBePy/tosca/imports/runNormativeElement.py
+++ b/catalog-be/src/main/resources/scripts/sdcBePy/tosca/imports/runNormativeElement.py
@@ -9,10 +9,10 @@ from sdcBePy.tosca.models.normativeElementsList import get_capability, get_data,
def run(candidate):
- scheme, be_host, be_port, admin_user, _, debug = get_args()
+ scheme, be_host, be_port, header, admin_user, _, debug = get_args()
try:
process_and_create_normative_element(candidate,
- scheme, be_host, be_port, admin_user,
+ scheme, be_host, be_port, header, admin_user,
debug=debug,
exit_on_success=True)
except AttributeError:
diff --git a/catalog-be/src/main/resources/scripts/sdcBePy/tosca/main.py b/catalog-be/src/main/resources/scripts/sdcBePy/tosca/main.py
index 565ce7efdb..78032a4e3a 100644
--- a/catalog-be/src/main/resources/scripts/sdcBePy/tosca/main.py
+++ b/catalog-be/src/main/resources/scripts/sdcBePy/tosca/main.py
@@ -11,7 +11,7 @@ from sdcBePy.common.sdcBeProxy import SdcBeProxy
def usage():
print(sys.argv[0],
'[-s <scheme> | --scheme=<scheme> ] [-i <be host> | --ip=<be host>] [-p <be port> | '
- '--port=<be port> ] [-u <user userId> | --user=<user userId> ] [-d <true|false> | '
+ '--port=<be port> ] --header=<header> ] [-u <user userId> | --user=<user userId> ] [-d <true|false> | '
'--debug=<true|false>] [-v <true|false> | --updateVersion=<true|false>]')
@@ -28,6 +28,7 @@ def parse_param():
parser.add_argument('--ip', "-i")
parser.add_argument('--port', "-p")
+ parser.add_argument('--header')
parser.add_argument('--adminUser', "-a")
parser.add_argument('--https', action='store_true')
parser.add_argument('--updateVersion', action='store_false')
@@ -36,14 +37,14 @@ def parse_param():
args, _ = parser.parse_known_args()
return [args.conf, 'https' if args.https else 'http',
- args.ip, args.port, args.adminUser, args.updateVersion,
+ args.ip, args.port, args.header, args.adminUser, args.updateVersion,
args.debug]
def get_args():
print('Number of arguments:', len(sys.argv), 'arguments.')
- conf_path, scheme, be_host, be_port, admin_user, update_version, debug = parse_param()
+ conf_path, scheme, be_host, be_port, header, admin_user, update_version, debug = parse_param()
defaults = load_be_config(conf_path)
# Use defaults if param not provided by the user
@@ -54,22 +55,26 @@ def get_args():
if admin_user is None:
admin_user = defaults["adminUser"]
- print('scheme =', scheme, ',be host =', be_host, ', be port =', be_port, ', user =', admin_user,
+ if header is None:
+ print('scheme =', scheme, ',be host =', be_host, ', be port =', be_port, ', user =', admin_user,
', debug =', debug, ', update_version =', update_version)
+ else:
+ print('scheme =', scheme, ',be host =', be_host, ', be port =', be_port, ', header =', header, ', user =', admin_user,
+ ', debug =', debug, ', update_version =', update_version)
init_properties(defaults["retryTime"], defaults["retryAttempt"], defaults["resourceLen"])
- return scheme, be_host, be_port, admin_user, update_version, debug
+ return scheme, be_host, be_port, header, admin_user, update_version, debug
def parse_and_create_proxy():
- scheme, be_host, be_port, admin_user, update_version, debug = get_args()
+ scheme, be_host, be_port, header, admin_user, update_version, debug = get_args()
if debug is False:
print('Disabling debug mode')
logger.debugFlag = debug
try:
- sdc_be_proxy = SdcBeProxy(be_host, be_port, scheme, admin_user, debug=debug)
+ sdc_be_proxy = SdcBeProxy(be_host, be_port, header, scheme, admin_user, debug=debug)
except AttributeError:
usage()
sys.exit(3)
diff --git a/catalog-be/src/main/resources/scripts/sdcBePy/users/run.py b/catalog-be/src/main/resources/scripts/sdcBePy/users/run.py
index 1518c2f673..56640db4cf 100755
--- a/catalog-be/src/main/resources/scripts/sdcBePy/users/run.py
+++ b/catalog-be/src/main/resources/scripts/sdcBePy/users/run.py
@@ -19,8 +19,8 @@ def load_users(conf_path):
return json.load(f)
-def be_user_init(be_ip, be_port, protocol, conf_path):
- sdc_be_proxy = SdcBeProxy(be_ip, be_port, protocol)
+def be_user_init(be_ip, be_port, header, protocol, conf_path):
+ sdc_be_proxy = SdcBeProxy(be_ip, be_port, header, protocol)
if check_backend(sdc_be_proxy, properties.retry_attempts):
users = load_users(conf_path)
for user in users:
@@ -49,6 +49,7 @@ def get_args():
parser.add_argument('-i', '--ip', required=True)
parser.add_argument('-p', '--port', required=True)
+ parser.add_argument('--header')
parser.add_argument('--https', action='store_true')
path = os.path.dirname(__file__)
parser.add_argument('--conf', default=os.path.join(path, 'data', 'users.json'))
@@ -56,7 +57,7 @@ def get_args():
args = parser.parse_args()
init_properties(10, 10)
- return [args.ip, args.port, 'https' if args.https else 'http', args.conf]
+ return [args.ip, args.port, args.header, 'https' if args.https else 'http', args.conf]
def main():
diff --git a/catalog-be/src/test/resources/config/catalog-be/configuration.yaml b/catalog-be/src/test/resources/config/catalog-be/configuration.yaml
index 7f75646467..3ca0682a4b 100644
--- a/catalog-be/src/test/resources/config/catalog-be/configuration.yaml
+++ b/catalog-be/src/test/resources/config/catalog-be/configuration.yaml
@@ -82,6 +82,12 @@ neo4j:
user: neo4j
password: "12345"
+basicAuth:
+ enabled: false
+ userName: test
+ userPass: test
+ excludedUrls:
+
cassandraConfig:
cassandraHosts: ['localhost']
cassandraPort: 9042