Skip to content

Commit

Permalink
Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Marven11 committed Mar 16, 2024
1 parent adc6e5c commit feeb1a6
Showing 1 changed file with 33 additions and 13 deletions.
46 changes: 33 additions & 13 deletions tests/test_webui.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@
t.start()
time.sleep(0.5)


class TestWebui(unittest.TestCase):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)


def test_index(self):
resp = requests.get(WEBUI_URL)
self.assertEqual(resp.status_code, 200)
Expand All @@ -48,18 +48,8 @@ def wait_for_task(self, task_id, task_type, max_time=60):
break
self.assertLessEqual(time.perf_counter() - start_time, max_time)

def test_webui(self):
resp = requests.post(
WEBUI_URL + "/createTask",
data={
"type": "crack",
"url": VULUNSERVER_URL,
"inputs": "name",
"method": "GET",
"action": "/",
"interval": "0.02",
}
)
def general_task_test(self, request_data):
resp = requests.post(WEBUI_URL + "/createTask", data=request_data)
resp_data = resp.json()
self.assertEqual(resp_data["code"], const.APICODE_OK)
task_id = resp_data["taskid"]
Expand Down Expand Up @@ -90,3 +80,33 @@ def test_webui(self):

is_cmd_executed = any("test webui" in msg for msg in messages)
self.assertTrue(is_cmd_executed)

def test_crack(self):
self.general_task_test(
{
"type": "crack",
"url": VULUNSERVER_URL,
"inputs": "name",
"method": "GET",
"action": "/",
"interval": "0.02",
}
)

def test_scan(self):
self.general_task_test(
{
"type": "scan",
"url": VULUNSERVER_URL,
"interval": "0.02",
}
)

def test_crack_path(self):
self.general_task_test(
{
"type": "crack-path",
"url": VULUNSERVER_URL + "/crackpath/",
"interval": "0.02",
}
)

0 comments on commit feeb1a6

Please sign in to comment.