Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update unit tests for sfwebui to match actual implementation #199

Open
wants to merge 1 commit into
base: v5.0.3-dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions test/integration/test_sfwebui.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,6 @@ def test_scaninfo_invalid_scan_returns_200(self):
self.assertStatus("200 OK")
self.assertInBody("Scan ID not found.")

@unittest.skip("todo")
def test_opts_returns_200(self):
self.getPage("/opts")
self.assertStatus("200 OK")
Expand All @@ -156,12 +155,10 @@ def test_scandelete_invalid_scan_id_returns_404(self):
self.assertStatus("404 Not Found")
self.assertInBody("Scan doesnotexist does not exist")

@unittest.skip("todo")
def test_savesettings(self):
self.getPage("/savesettings")
self.assertStatus("200 OK")

@unittest.skip("todo")
def test_savesettingsraw(self):
self.getPage("/savesettingsraw")
self.assertStatus("200 OK")
Expand Down
56 changes: 26 additions & 30 deletions test/unit/test_sfwebui.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,20 +169,6 @@ def test_search_base_should_return_a_list(self):
search_results = sfwebui.searchBase(None, None, "//")
self.assertIsInstance(search_results, list)

@unittest.skip("todo")
def test_scan_correlations_export(self):
opts = self.default_options
opts["__modules__"] = dict()
scan_id = ""
sfwebui = SpiderFootWebUi(self.web_default_options, opts)
search_results = sfwebui.scancorrelationsexport(
scan_id, "csv", "excel")
self.assertIsInstance(search_results, bytes)
search_results = sfwebui.scancorrelationsexport(
scan_id, "xlxs", "excel")
self.assertIsInstance(search_results, bytes)

@unittest.skip("todo")
def test_scan_event_result_export_should_return_bytes(self):
"""
Test scaneventresultexport(self, id, type, filetype="csv", dialect="excel")
Expand All @@ -195,7 +181,6 @@ def test_scan_event_result_export_should_return_bytes(self):
search_results = sfwebui.scaneventresultexport("", "", "excel")
self.assertIsInstance(search_results, bytes)

@unittest.skip("todo")
def test_scan_event_result_export_multi(self):
"""
Test scaneventresultexportmulti(self, ids, filetype="csv", dialect="excel")
Expand All @@ -208,7 +193,6 @@ def test_scan_event_result_export_multi(self):
search_results = sfwebui.scaneventresultexportmulti("", "excel")
self.assertIsInstance(search_results, bytes)

@unittest.skip("todo")
def test_scan_search_result_export(self):
"""
Test scansearchresultexport(self, id, eventType=None, value=None, filetype="csv", dialect="excel")
Expand All @@ -233,7 +217,6 @@ def test_scan_export_logs_invalid_scan_id_should_return_string(self):
self.assertIsInstance(logs, str)
self.assertIn("Scan ID not found.", logs)

@unittest.skip("todo")
def test_scan_export_logs_should_return_bytes(self):
"""
Test scanexportlogs(self: 'SpiderFootWebUi', id: str, dialect: str = "excel") -> str
Expand All @@ -244,7 +227,6 @@ def test_scan_export_logs_should_return_bytes(self):
logs = sfwebui.scanexportlogs("scan id", "excel")
self.assertIsInstance(logs, bytes)

@unittest.skip("todo")
def test_scan_export_json_multi(self):
"""
Test scanexportjsonmulti(self, ids)
Expand All @@ -255,7 +237,6 @@ def test_scan_export_json_multi(self):
search_results = sfwebui.scanexportjsonmulti(None)
self.assertIsInstance(search_results, bytes)

@unittest.skip("todo")
def test_scan_viz_should_return_a_string(self):
"""
Test scanviz(self, id, gexf="0")
Expand All @@ -266,7 +247,6 @@ def test_scan_viz_should_return_a_string(self):
scan_viz = sfwebui.scanviz(None, None)
self.assertIsInstance(scan_viz, str)

@unittest.skip("todo")
def test_scan_viz_multi_should_return_a_string(self):
"""
Test scanvizmulti(self, ids, gexf="1")
Expand All @@ -293,7 +273,6 @@ def test_rerunscan_invalid_scan_id_should_return_error(self):
self.assertIsInstance(rerunscan, str)
self.assertIn("Invalid scan ID", rerunscan)

@unittest.skip("todo")
def test_rerunscanmulti(self):
"""
Test rerunscanmulti(self, ids)
Expand All @@ -304,12 +283,15 @@ def test_rerunscanmulti(self):
rerunscanmulti = sfwebui.rerunscanmulti("example scan instance")
self.assertIsInstance(rerunscanmulti, str)

@unittest.skip("todo")
def test_newscan(self):
"""
Test newscan(self)
"""
self.assertEqual("TBD", "TBD")
opts = self.default_options
opts["__modules__"] = dict()
sfwebui = SpiderFootWebUi(self.web_default_options, opts)
new_scan = sfwebui.newscan()
self.assertIsInstance(new_scan, str)

def test_clonescan(self):
"""
Expand Down Expand Up @@ -400,9 +382,15 @@ def test_savesettings_invalid_csrf_token_should_return_an_error(self):
self.assertIsInstance(save_settings, str)
self.assertIn("Invalid token", save_settings)

@unittest.skip("todo")
def test_savesettings(self):
self.assertEqual("TBD", "TBD")
"""
Test savesettings(self, allopts, token, configFile=None)
"""
opts = self.default_options
opts["__modules__"] = dict()
sfwebui = SpiderFootWebUi(self.web_default_options, opts)
save_settings = sfwebui.savesettings(None, "valid token", None)
self.assertIsInstance(save_settings, str)

def test_savesettingsraw_invalid_csrf_token_should_return_an_error(self):
opts = self.default_options
Expand All @@ -412,9 +400,15 @@ def test_savesettingsraw_invalid_csrf_token_should_return_an_error(self):
self.assertIsInstance(save_settings_raw, bytes)
self.assertIn(b"Invalid token", save_settings_raw)

@unittest.skip("todo")
def test_savesettingsraw(self):
self.assertEqual("TBD", "TBD")
"""
Test savesettingsraw(self, allopts, token)
"""
opts = self.default_options
opts["__modules__"] = dict()
sfwebui = SpiderFootWebUi(self.web_default_options, opts)
save_settings_raw = sfwebui.savesettingsraw(None, "valid token")
self.assertIsInstance(save_settings_raw, bytes)

def test_reset_settings_should_return_true(self):
opts = self.default_options
Expand All @@ -424,12 +418,15 @@ def test_reset_settings_should_return_true(self):
self.assertIsInstance(reset_settings, bool)
self.assertTrue(reset_settings)

@unittest.skip("todo")
def test_result_set_fp(self):
"""
Test resultsetfp(self, id, resultids, fp)
"""
self.assertEqual("TBD", "TBD")
opts = self.default_options
opts["__modules__"] = dict()
sfwebui = SpiderFootWebUi(self.web_default_options, opts)
result_set_fp = sfwebui.resultsetfp("example scan id", "example result ids", "example fp")
self.assertIsInstance(result_set_fp, str)

def test_eventtypes_should_return_list(self):
opts = self.default_options
Expand Down Expand Up @@ -496,7 +493,6 @@ def test_query_invalid_query_should_return_error(self):
query.get("error").get("message"),
)

@unittest.skip("todo")
def test_start_scan_should_start_a_scan(self):
"""
Test startscan(self, scanname, scantarget, modulelist, typelist, usecase)
Expand Down
Loading