Skip to content
Snippets Groups Projects
Commit 9eb0538a authored by brianlam38's avatar brianlam38
Browse files

adding reimport_scan feature and associated unit test

parent 87006a61
Branches
Tags
No related merge requests found
...@@ -668,35 +668,35 @@ class DefectDojoAPI(object): ...@@ -668,35 +668,35 @@ class DefectDojoAPI(object):
files=data files=data
) )
##### Credential API ##### ##### Re-upload API #####
def list_credentials(self, name=None, username=None, limit=20): def reupload_scan(self, test_id, scan_type, file, active, scan_date, tags=None, build=None):
"""Retrieves all the globally configured credentials. """Re-uploads and processes a scan file.
:param name_contains: Search by credential name. :param test_id: Test identifier.
:param username: Search by username :param file: Path to the scan file to be uploaded.
:param limit: Number of records to return.
""" """
if tags is None:
tags = ''
params = {} if build is None:
if limit: build = ''
params['limit'] = limit
if name:
params['name__contains'] = name
if username:
params['username__contains'] = username
return self._request('GET', 'credentials/', params) data = {
'test': ('', self.get_test_uri(test_id)),
'file': open(file, 'rb'),
'scan_type': ('', scan_type),
'active': ('', active),
'scan_date': ('', scan_date),
'tags': ('', tags),
'build_id': ('', build)
}
def get_credential(self, cred_id, limit=20): return self._request(
""" 'POST', 'reimportscan/',
Retrieves a credential using the given credential id. files=data
:param credential_id: Credential identification. )
"""
return self._request('GET', 'credentials/' + str(cred_id) + '/')
##### Credential Mapping API ##### ##### Credential Mapping API #####
......
...@@ -158,5 +158,15 @@ class TestDefectDojoAPI(unittest.TestCase): ...@@ -158,5 +158,15 @@ class TestDefectDojoAPI(unittest.TestCase):
self.assertIsNotNone(upload_scan.id()) self.assertIsNotNone(upload_scan.id())
#### Re-upload API Test ####
def test_20_reupload_scan(self):
dir_path = os.path.dirname(os.path.realpath(__file__))
date = datetime.now()
upload_scan = self.dd.upload_scan(self.__class__.test_id, "Burp Scan", dir_path + "/scans/Bodgeit-burp.xml",
"true", date.strftime("%Y/%m/%d"), "API")
self.assertIsNotNone(upload_scan.id())
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment