summaryrefslogtreecommitdiffstats
path: root/robotframework-onap
diff options
context:
space:
mode:
Diffstat (limited to 'robotframework-onap')
-rw-r--r--robotframework-onap/ONAPLibrary/BaseSDCKeywords.py31
-rw-r--r--robotframework-onap/ONAPLibrary/BaseSDNCKeywords.py27
-rw-r--r--robotframework-onap/ONAPLibrary/BaseSOKeywords.py28
-rw-r--r--robotframework-onap/ONAPLibrary/MUSICKeywords.py19
-rw-r--r--robotframework-onap/ONAPLibrary/RequestsHelper.py39
-rw-r--r--robotframework-onap/ONAPLibrary/SNIROKeywords.py21
6 files changed, 75 insertions, 90 deletions
diff --git a/robotframework-onap/ONAPLibrary/BaseSDCKeywords.py b/robotframework-onap/ONAPLibrary/BaseSDCKeywords.py
index cc09a5b..0ec8cf5 100644
--- a/robotframework-onap/ONAPLibrary/BaseSDCKeywords.py
+++ b/robotframework-onap/ONAPLibrary/BaseSDCKeywords.py
@@ -19,7 +19,7 @@ from robot.libraries.BuiltIn import BuiltIn
import hashlib
from ONAPLibrary.Base64Keywords import Base64Keywords
-from ONAPLibrary.UUIDKeywords import UUIDKeywords
+from ONAPLibrary.RequestsHelper import RequestsHelper
class BaseSDCKeywords(object):
@@ -28,8 +28,7 @@ class BaseSDCKeywords(object):
def __init__(self):
super(BaseSDCKeywords, self).__init__()
- self.application_id = "robot-ete"
- self.uuid = UUIDKeywords()
+ self.reqs = RequestsHelper()
self.builtin = BuiltIn()
@keyword
@@ -59,25 +58,11 @@ class BaseSDCKeywords(object):
"""Runs an SDC get request"""
logger.info("Creating session" + endpoint)
RequestsLibrary().create_session("sdc", endpoint, auth=auth)
- resp = RequestsLibrary().get_request("sdc", data_path, headers=self.create_headers(user, accept))
+ headers = self.reqs.create_headers(sdc_user_id=user, accept=accept)
+ resp = RequestsLibrary().get_request("sdc", data_path, headers=headers)
logger.info("Received response from sdc " + resp.text)
return resp
- def create_headers(self, user=None, accept="application/json", content_type="application/json", md5=None):
- """Create the headers that are used by sdc"""
- uuid = self.uuid.generate_uuid4()
- headers = {
- "Accept": accept,
- "Content-Type": content_type,
- "X-TransactionId": self.application_id + "-" + uuid,
- "X-FromAppId": self.application_id
- }
- if not user:
- headers["USER_ID"] = user
- if not md5:
- headers["Content-MD5"] = md5
- return headers
-
def post_request(self, endpoint, data_path, data, user, files=None, accept="application/json",
content_type="application/json", auth=None):
"""Runs an SDC post request"""
@@ -86,7 +71,7 @@ class BaseSDCKeywords(object):
md5.update(data)
md5checksum = Base64Keywords().base64_encode(md5.hexdigest())
RequestsLibrary().create_session("sdc", endpoint, auth=auth)
- headers = self.create_headers(user, accept=accept, content_type=content_type, md5=md5checksum)
+ headers = self.reqs.create_headers(user, accept=accept, content_type=content_type, md5=md5checksum)
resp = RequestsLibrary().post_request("sdc", data_path, files=files, data=data, headers=headers)
logger.info("Received response from sdc " + resp.text)
@@ -96,7 +81,8 @@ class BaseSDCKeywords(object):
"""Runs an SDC post request"""
logger.info("Creating session" + endpoint)
RequestsLibrary().create_session("sdc", endpoint, auth=auth)
- resp = RequestsLibrary().put_request("sdc", data_path, data=data, headers=self.create_headers(user, accept))
+ headers = self.reqs.create_headers(sdc_user_id=user, accept=accept)
+ resp = RequestsLibrary().put_request("sdc", data_path, data=data, headers=headers)
logger.info("Received response from sdc " + resp.text)
return resp
@@ -104,6 +90,7 @@ class BaseSDCKeywords(object):
"""Runs an SDC post request"""
logger.info("Creating session" + endpoint)
RequestsLibrary().create_session("sdc", endpoint, auth=auth)
- resp = RequestsLibrary().delete_request("sdc", data_path, data=data, headers=self.create_headers(user, accept))
+ headers = self.reqs.create_headers(sdc_user_id=user, accept=accept)
+ resp = RequestsLibrary().delete_request("sdc", data_path, data=data, headers=headers)
logger.info("Received response from sdc " + resp.text)
return resp
diff --git a/robotframework-onap/ONAPLibrary/BaseSDNCKeywords.py b/robotframework-onap/ONAPLibrary/BaseSDNCKeywords.py
index 9fa9c04..14bfb54 100644
--- a/robotframework-onap/ONAPLibrary/BaseSDNCKeywords.py
+++ b/robotframework-onap/ONAPLibrary/BaseSDNCKeywords.py
@@ -16,7 +16,7 @@ from robot.api import logger
from robot.api.deco import keyword
from robot.libraries.BuiltIn import BuiltIn
-from ONAPLibrary.Utilities import Utilities
+from ONAPLibrary.RequestsHelper import RequestsHelper
class BaseSDNCKeywords(object):
@@ -25,8 +25,7 @@ class BaseSDNCKeywords(object):
def __init__(self):
super(BaseSDNCKeywords, self).__init__()
- self.application_id = "robot-ete"
- self.uuid = Utilities()
+ self.reqs = RequestsHelper()
self.builtin = BuiltIn()
@keyword
@@ -50,26 +49,16 @@ class BaseSDNCKeywords(object):
"""Runs an SDNC get request"""
logger.info("Creating session" + endpoint)
RequestsLibrary().create_session("sdnc", endpoint, auth=auth)
- resp = RequestsLibrary().get_request("sdnc", data_path, headers=self.create_headers(accept))
+ resp = RequestsLibrary().get_request("sdnc", data_path, headers=self.reqs.create_headers(accept))
logger.info("Received response from sdnc " + resp.text)
return resp
- def create_headers(self, accept="application/json"):
- """Create the headers that are used by sdnc"""
- uuid = self.uuid.generate_uuid4()
- headers = {
- "Accept": accept,
- "Content-Type": "application/json",
- "X-TransactionId": self.application_id + "-" + uuid,
- "X-FromAppId": self.application_id
- }
- return headers
-
def post_request(self, endpoint, data_path, data, accept="application/json", auth=None):
"""Runs an sdnc post request"""
logger.info("Creating session" + endpoint)
RequestsLibrary().create_session("sdnc", endpoint, auth=auth)
- resp = RequestsLibrary().post_request("sdnc", data_path, data=data, headers=self.create_headers(accept))
+ headers = self.reqs.create_headers(accept=accept)
+ resp = RequestsLibrary().post_request("sdnc", data_path, data=data, headers=headers)
logger.info("Received response from sdnc " + resp.text)
return resp
@@ -77,7 +66,8 @@ class BaseSDNCKeywords(object):
"""Runs an sdnc post request"""
logger.info("Creating session" + endpoint)
RequestsLibrary().create_session("sdnc", endpoint, auth=auth)
- resp = RequestsLibrary().put_request("sdnc", data_path, data=data, headers=self.create_headers(accept))
+ headers = self.reqs.create_headers(accept=accept)
+ resp = RequestsLibrary().put_request("sdnc", data_path, data=data, headers=headers)
logger.info("Received response from sdnc " + resp.text)
return resp
@@ -85,6 +75,7 @@ class BaseSDNCKeywords(object):
"""Runs an sdnc post request"""
logger.info("Creating session" + endpoint)
RequestsLibrary().create_session("sdnc", endpoint, auth=auth)
- resp = RequestsLibrary().delete_request("sdnc", data_path, data=data, headers=self.create_headers(accept))
+ headers = self.reqs.create_headers(accept=accept)
+ resp = RequestsLibrary().delete_request("sdnc", data_path, data=data, headers=headers)
logger.info("Received response from sdnc " + resp.text)
return resp
diff --git a/robotframework-onap/ONAPLibrary/BaseSOKeywords.py b/robotframework-onap/ONAPLibrary/BaseSOKeywords.py
index 80ae40c..f262616 100644
--- a/robotframework-onap/ONAPLibrary/BaseSOKeywords.py
+++ b/robotframework-onap/ONAPLibrary/BaseSOKeywords.py
@@ -16,7 +16,7 @@ from robot.api import logger
from robot.api.deco import keyword
from robot.libraries.BuiltIn import BuiltIn
-from ONAPLibrary.Utilities import Utilities
+from ONAPLibrary.RequestsHelper import RequestsHelper
class BaseSOKeywords(object):
@@ -25,8 +25,7 @@ class BaseSOKeywords(object):
def __init__(self):
super(BaseSOKeywords, self).__init__()
- self.application_id = "robot-ete"
- self.uuid = Utilities()
+ self.reqs = RequestsHelper()
self.builtin = BuiltIn()
@keyword
@@ -50,26 +49,17 @@ class BaseSOKeywords(object):
"""Runs an SO get request"""
logger.info("Creating session" + endpoint)
RequestsLibrary().create_session("so", endpoint, auth=auth)
- resp = RequestsLibrary().get_request("so", data_path, headers=self.create_headers(accept))
+ headers = self.reqs.create_headers(accept=accept)
+ resp = RequestsLibrary().get_request("so", data_path, headers=headers)
logger.info("Received response from so " + resp.text)
return resp
- def create_headers(self, accept="application/json"):
- """Create the headers that are used by so"""
- uuid = self.uuid.generate_uuid4()
- headers = {
- "Accept": accept,
- "Content-Type": "application/json",
- "X-TransactionId": self.application_id + "-" + uuid,
- "X-FromAppId": self.application_id
- }
- return headers
-
def post_request(self, endpoint, data_path, data, accept="application/json", auth=None):
"""Runs an SO post request"""
logger.info("Creating session" + endpoint)
RequestsLibrary().create_session("so", endpoint, auth=auth)
- resp = RequestsLibrary().post_request("so", data_path, data=data, headers=self.create_headers(accept))
+ headers = self.reqs.create_headers(accept=accept)
+ resp = RequestsLibrary().post_request("so", data_path, data=data, headers=headers)
logger.info("Received response from so " + resp.text)
return resp
@@ -77,7 +67,8 @@ class BaseSOKeywords(object):
"""Runs an SO post request"""
logger.info("Creating session" + endpoint)
RequestsLibrary().create_session("so", endpoint, auth=auth)
- resp = RequestsLibrary().put_request("so", data_path, data=data, headers=self.create_headers(accept))
+ headers = self.reqs.create_headers(accept=accept)
+ resp = RequestsLibrary().put_request("so", data_path, data=data, headers=headers)
logger.info("Received response from so " + resp.text)
return resp
@@ -85,6 +76,7 @@ class BaseSOKeywords(object):
"""Runs an SO post request"""
logger.info("Creating session" + endpoint)
RequestsLibrary().create_session("so", endpoint, auth=auth)
- resp = RequestsLibrary().delete_request("so", data_path, data=data, headers=self.create_headers(accept))
+ headers = self.reqs.create_headers(accept=accept)
+ resp = RequestsLibrary().delete_request("so", data_path, data=data, headers=headers)
logger.info("Received response from so " + resp.text)
return resp
diff --git a/robotframework-onap/ONAPLibrary/MUSICKeywords.py b/robotframework-onap/ONAPLibrary/MUSICKeywords.py
index abceb54..6d1ae6e 100644
--- a/robotframework-onap/ONAPLibrary/MUSICKeywords.py
+++ b/robotframework-onap/ONAPLibrary/MUSICKeywords.py
@@ -16,7 +16,7 @@ from robot.api import logger
from robot.api.deco import keyword
from robot.libraries.BuiltIn import BuiltIn
-from ONAPLibrary.Utilities import Utilities
+from ONAPLibrary.RequestsHelper import RequestsHelper
class MUSICKeywords(object):
@@ -25,8 +25,7 @@ class MUSICKeywords(object):
def __init__(self):
super(MUSICKeywords, self).__init__()
- self.application_id = "robot-ete"
- self.uuid = Utilities()
+ self.reqs = RequestsHelper()
self.builtin = BuiltIn()
@keyword
@@ -39,21 +38,10 @@ class MUSICKeywords(object):
"""Runs an MUSIC get request"""
logger.info("Creating session" + endpoint)
RequestsLibrary().create_session("music", endpoint, auth=auth)
- resp = RequestsLibrary().get_request("music", data_path, headers=self.create_headers(accept))
+ resp = RequestsLibrary().get_request("music", data_path, headers=self.reqs.create_headers(accept=accept))
logger.info("Received response from music " + resp.text)
return resp
- def create_headers(self, accept="application/json"):
- """Create the headers that are used by MUSIC"""
- uuid = self.uuid.generate_uuid4()
- headers = {
- "Accept": accept,
- "Content-Type": "application/json",
- "X-TransactionId": self.application_id + "-" + uuid,
- "X-FromAppId": self.application_id
- }
- return headers
-
def run_health_check(self, endpoint, health_check_path):
"""Runs MUSIC Health check"""
resp = self.run_get_request(endpoint, health_check_path)
@@ -65,4 +53,3 @@ class MUSICKeywords(object):
resp = self.run_get_request(endpoint, health_check_path)
self.builtin.should_be_equal_as_strings(resp.status_code, "200")
self.builtin.should_be_equal_as_strings(resp.json()['Cassandra'], "Active")
-
diff --git a/robotframework-onap/ONAPLibrary/RequestsHelper.py b/robotframework-onap/ONAPLibrary/RequestsHelper.py
new file mode 100644
index 0000000..3db6100
--- /dev/null
+++ b/robotframework-onap/ONAPLibrary/RequestsHelper.py
@@ -0,0 +1,39 @@
+# Copyright 2019 AT&T Intellectual Property. All rights reserved.
+#
+# 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.
+
+from ONAPLibrary.UUIDKeywords import UUIDKeywords
+
+
+class RequestsHelper(object):
+ """ non keywords methods related to Requests library """
+
+ def __init__(self):
+ super(RequestsHelper, self).__init__()
+ self.uuid = UUIDKeywords()
+ self.application_id = "robot-ete"
+
+ def create_headers(self, sdc_user_id=None, accept="application/json", content_type="application/json", md5=None):
+ """Create the headers that are used by onap"""
+ uuid = self.uuid.generate_uuid4()
+ headers = {
+ "Accept": accept,
+ "Content-Type": content_type,
+ "X-TransactionId": self.application_id + "-" + uuid,
+ "X-FromAppId": self.application_id
+ }
+ if not sdc_user_id:
+ headers["USER_ID"] = sdc_user_id
+ if not md5:
+ headers["Content-MD5"] = md5
+ return headers
diff --git a/robotframework-onap/ONAPLibrary/SNIROKeywords.py b/robotframework-onap/ONAPLibrary/SNIROKeywords.py
index 8e97529..f9750da 100644
--- a/robotframework-onap/ONAPLibrary/SNIROKeywords.py
+++ b/robotframework-onap/ONAPLibrary/SNIROKeywords.py
@@ -16,7 +16,7 @@ from robot.api import logger
from robot.api.deco import keyword
from robot.libraries.BuiltIn import BuiltIn
-from ONAPLibrary.Utilities import Utilities
+from ONAPLibrary.RequestsHelper import RequestsHelper
from ONAPLibrary.TemplatingKeywords import TemplatingKeywords
from ONAPLibrary.Base64Keywords import Base64Keywords
@@ -27,8 +27,7 @@ class SNIROKeywords(object):
def __init__(self):
super(SNIROKeywords, self).__init__()
- self.application_id = "robot-ete"
- self.uuid = Utilities()
+ self.reqs = RequestsHelper()
self.templating = TemplatingKeywords()
self.base64 = Base64Keywords()
self.builtin = BuiltIn()
@@ -69,7 +68,8 @@ class SNIROKeywords(object):
"""Runs an SNIRO post request"""
logger.info("Creating session" + endpoint)
RequestsLibrary().create_session("so", endpoint, auth=auth)
- resp = RequestsLibrary().post_request("so", data_path, data=data, headers=self.create_headers(accept))
+ headers = self.reqs.create_headers(accept=accept)
+ resp = RequestsLibrary().post_request("so", data_path, data=data, headers=headers)
logger.info("Received response from so " + resp.text)
return resp
@@ -77,17 +77,6 @@ class SNIROKeywords(object):
"""Runs an SNIRO get request"""
logger.info("Creating session" + endpoint)
RequestsLibrary().create_session("sniro", endpoint, auth=auth)
- resp = RequestsLibrary().get_request("sniro", data_path, headers=self.create_headers(accept))
+ resp = RequestsLibrary().get_request("sniro", data_path, headers=self.reqs.create_headers(accept=accept))
logger.info("Received response from OOF-SNIRO " + resp.text)
return resp
-
- def create_headers(self, accept="application/json"):
- """Create the headers that are used by so"""
- uuid = self.uuid.generate_uuid4()
- headers = {
- "Accept": accept,
- "Content-Type": "application/json",
- "X-TransactionId": self.application_id + "-" + uuid,
- "X-FromAppId": self.application_id
- }
- return headers