Skip to content

Commit

Permalink
add ssl verification flag
Browse files Browse the repository at this point in the history
  • Loading branch information
faustocarrera committed Nov 30, 2018
1 parent f33ca31 commit 8c5dc7d
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 8 deletions.
1 change: 1 addition & 0 deletions config/app.conf
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
[app]
url: https://jsonplaceholder.typicode.com
ssl_verify: True

[vars]
post_id: 1
Expand Down
11 changes: 6 additions & 5 deletions smoke/apicalls.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@
class ApiCalls(object):
"Class to make the request to the API"

def __init__(self, app_url, app_vars, utils):
def __init__(self, app_url, app_vars, ssl_verify, utils):
self.app_url = app_url
self.app_vars = app_vars
self.utils = utils
self.ssl_verify = ssl_verify
self.methods = ['GET', 'POST', 'PUT', 'DELETE']

def call(self, test):
Expand All @@ -38,22 +39,22 @@ def call(self, test):

def get(self, url, headers, payload):
"Make a get call"
req = requests.get(url, headers=headers, data=payload)
req = requests.get(url, headers=headers, data=payload, verify=self.ssl_verify)
return self.prepare(req)

def post(self, url, headers, payload):
"Make a post call"
req = requests.post(url, headers=headers, data=payload)
req = requests.post(url, headers=headers, data=payload, verify=self.ssl_verify)
return self.prepare(req)

def put(self, url, headers, payload):
"Make a put call"
req = requests.put(url, headers=headers, data=payload)
req = requests.put(url, headers=headers, data=payload, verify=self.ssl_verify)
return self.prepare(req)

def delete(self, url, headers, payload):
"Make a get call"
req = requests.delete(url, headers=headers, data=payload)
req = requests.delete(url, headers=headers, data=payload, verify=self.ssl_verify)
return self.prepare(req)

def get_api_url(self):
Expand Down
11 changes: 9 additions & 2 deletions smoke/appconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,17 @@ def __init__(self, config_file):
"Load app config"
self.load(config_file)

def appurl(self):
def app_url(self):
"Get app url"
return self.get('app', 'url')

def ssl_verify(self):
"Get verify ssl"
ssl_verify = self.get('app', 'ssl_verify')
if ssl_verify == 'True':
return True
return False

def vars(self):
"Get the config variables"
app_variables = {}
Expand All @@ -28,4 +35,4 @@ def vars(self):

def debug(self):
"Module debug"
return {'app_url': self.appurl(), 'vars': self.vars()}
return {'app_url': self.app_url(), 'vars': self.vars()}
3 changes: 2 additions & 1 deletion smoke/smoketests.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@ def __init__(self, basepath, config_path, tests_path):
self.tests_config = TestConfig()
self.app_config = AppConfig(self.utils.get_path(basepath, config_path))
self.api_calls = ApiCalls(
self.app_config.appurl(),
self.app_config.app_url(),
self.app_config.vars(),
self.app_config.ssl_verify(),
self.utils
)
self.tests_path = self.utils.get_path(basepath, tests_path)
Expand Down

0 comments on commit 8c5dc7d

Please sign in to comment.