File size: 1,032 Bytes
ef4248d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import pytest
from fastapi.testclient import TestClient
from app import app

client = TestClient(app)

def test_register():
    response = client.post("/register", json={"username": "testuser", "password": "testpass"})
    assert response.status_code == 201

def test_list_exploits():
    response = client.get("/exploits/")
    assert response.status_code == 200

def test_feedback_submission():
    response = client.post("/feedback/", json={"feedback": "This is a test feedback."})
    assert response.status_code == 200

def test_execute_exploit():
    response = client.post("/execute-exploit/cve_example_exploit.py")  # Replace with an actual exploit name in your directory.
    assert response.status_code in [200, 404]  # Should be either success or not found.

def test_websocket_connection():
    with client.websocket_connect("/ws") as websocket:
        websocket.send_text("Hello Server!")
        data = websocket.receive_text()
        assert data == "Message text was: Hello Server!"