예제 #1
0
def test_apiary_view(client, set_up_apiary):
    apiary = Apiary.objects.first()
    apiary_count = Apiary.objects.count()
    response = client.get(f'/apiary_view/{apiary.id}')
    assert response.status_code == 200
    assert apiary_count == 5
    assert response.context['apiary'] == apiary
예제 #2
0
def test_scanresults(client, hostscan):
    # Test rendering
    scanresults_view = reverse("portscanner.hosts:results")
    response = client.get(scanresults_view)

    assert response.status_code == 200
    assert hostscan.target.label in response.content.decode()

    # Test search
    response = client.post(scanresults_view, {"label": hostscan.target.label})

    assert response.status_code == 302
    assert response.url == f"/results/{hostscan.target.label}"
예제 #3
0
def test_scanresults_host(client, hostscan):
    # Test rendering
    scanresults_view = reverse("portscanner.hosts:results",
                               args=(hostscan.target.label, ))
    assert scanresults_view == f"/results/{hostscan.target.label}"

    response = client.get(scanresults_view, {"label": "testhost.example.com"})

    assert response.status_code == 200
    assert hostscan.target.label in response.content.decode()

    # Test search
    response = client.post(scanresults_view, {"label": "testhost.example.com"})

    assert response.status_code == 302
    assert response.url == "/results/testhost.example.com"
예제 #4
0
def test_hostscan(client, monkeypatch):
    # Test rendering
    monkeypatch.setattr(PortScanner, "scan", mockNmap().scan)
    monkeypatch.setattr(PortScanner, "all_hosts", mockNmap().all_hosts)
    hostscan_view = reverse("portscanner.hosts:hostscan")
    response = client.get(hostscan_view)

    assert response.status_code == 200

    # Test scan
    response = client.post(hostscan_view, {"label": "192.168.1.1"})

    assert response.status_code == 302
    assert response.url == "/results/192.168.1.1"

    host = models.Host.objects.get(label="192.168.1.1")
    hostscan = models.HostScan.objects.get(target__label="192.168.1.1")

    assert set(["22/tcp", "80/tcp"]) == set(hostscan.ports["open"])
예제 #5
0
def test_beehive_view(client, set_up_beehive):
    beehive = BeeHive.objects.first()
    response = client.get(f'/beehive_view/{beehive.id}')
    assert response.status_code == 200
예제 #6
0
def test_beehive_list_view(client, set_up_beehive):
    response = client.get('/beehive_view/')
    beehive = BeeHive.objects.all()
    assert response.status_code == 200
    assert len(response.context['beehive']) == 5
예제 #7
0
def test_beehive_create(client):
    response = client.get('/beehive_create/')
    assert response.status_code == 200
예제 #8
0
def test_apiary_create(client):
    response = client.get('/apiary_create/')
    assert response.status_code == 200
예제 #9
0
def test_apiary_list_view(client, set_up_apiary):
    response = client.get('/apiary_view/')
    apiary = Apiary.objects.all()
    assert response.status_code == 200
    assert len(response.context['apiary']) == 5
예제 #10
0
def test_add_user_view(client):
    response = client.get('/add_user/')
    assert response.status_code == 200
예제 #11
0
def test_login_view(client):
    response = client.get('/login_view/')
    assert response.status_code == 200
예제 #12
0
def test_dashboard_view(client):
    response = client.get('/dashboard/')
    assert response.status_code == 200
예제 #13
0
def test_beemother_list_view(client, set_up_beefamily):
    response = client.get('/beemother_view/')
    beemother = BeeMother.objects.all()
    assert response.status_code == 200
    assert len(response.context['beemother']) == 5
예제 #14
0
def test_index_view(client):
    response = client.get('/')
    assert response.status_code == 200