cleanups
This commit is contained in:
@ -19,13 +19,6 @@ class mockAPI(object):
|
||||
self.logger.info('mockAPI initialised, API requests will be mocked')
|
||||
self.logger.info('Test path resolved as {}'.format(self.mock_dir))
|
||||
|
||||
self.openvas_requests = {
|
||||
'request_1': ('POST', 200, 'omp'),
|
||||
'request_2': ('GET', 200, 'omp?cmd=get_reports&token=efbe7076-4ae9-4e57-89cc-bcd6bd93f1f3&max_results=1&ignore_pagination=1&filter=apply_overrides%3D1+min_qod%3D70+autofp%3D0+first%3D1+rows%3D0+levels%3Dhml+sort-reverse%3Dseverity'),
|
||||
'request_3': ('GET', 200, 'omp?cmd=get_report_formats&token=efbe7076-4ae9-4e57-89cc-bcd6bd93f1f3'),
|
||||
'request_4': ('GET', 200, 'omp?token=efbe7076-4ae9-4e57-89cc-bcd6bd93f1f3&cmd=get_report&report_id=4c6c900c-71f5-42f7-91e2-1b19b7976606&filter=apply_overrides%3D0+min_qod%3D70+autofp%3D0+levels%3Dhml+first%3D1+rows%3D0+sort-reverse%3Dseverity&ignore_pagination=1&report_format_id=c1645568-627a-11e3-a660-406186ea4fc5&submit=Download')
|
||||
}
|
||||
|
||||
def get_directories(self, path):
|
||||
dir, subdirs, files = next(os.walk(path))
|
||||
return sorted(subdirs)
|
||||
@ -53,13 +46,13 @@ class mockAPI(object):
|
||||
elif 'fetch' in request.parsed_body['action']:
|
||||
try:
|
||||
response_body = open('{}/{}'.format(
|
||||
self.qualys_vuln_path,
|
||||
self.qualys_vuln_path,
|
||||
request.parsed_body['scan_ref'][0].replace('/', '_'))
|
||||
).read()
|
||||
except:
|
||||
# Can't find the file, just send an empty response
|
||||
response_body = ''
|
||||
return [200, response_headers, response_body]
|
||||
return [200, response_headers, response_body]
|
||||
|
||||
def create_qualys_vuln_resource(self, framework):
|
||||
# Create health check endpoint
|
||||
@ -90,7 +83,7 @@ class mockAPI(object):
|
||||
getattr(httpretty, method), 'https://{}:443/{}'.format(framework, resource),
|
||||
body=open('{}/{}/{}'.format(self.mock_dir, framework, filename)).read()
|
||||
)
|
||||
|
||||
|
||||
self.logger.debug('Adding mocked {} endpoint {} {}'.format(framework, 'POST', 'qps/rest/3.0/create/was/report'))
|
||||
httpretty.register_uri(
|
||||
httpretty.POST, 'https://{}:443/qps/rest/3.0/create/was/report'.format(framework),
|
||||
@ -118,17 +111,6 @@ class mockAPI(object):
|
||||
httpretty.GET, 'https://{}:4000/omp'.format(framework),
|
||||
body=self.openvas_callback
|
||||
)
|
||||
# try:
|
||||
# method, status, resource = self.openvas_requests[filename]
|
||||
# self.logger.debug('Adding mocked {} endpoint {} {}'.format(framework, method, resource))
|
||||
# except:
|
||||
# self.logger.error('Cound not find mocked {} endpoint for file {}/{}/{}'.format(framework, self.mock_dir, framework, filename))
|
||||
# continue
|
||||
# httpretty.register_uri(
|
||||
# getattr(httpretty, method), 'https://{}:4000/{}'.format(framework, resource),
|
||||
# body=open('{}/{}/{}'.format(self.mock_dir, framework, filename)).read(),
|
||||
# status=status
|
||||
# )
|
||||
|
||||
def mock_endpoints(self):
|
||||
for framework in self.get_directories(self.mock_dir):
|
||||
|
Reference in New Issue
Block a user