Ejemplo n.º 1
0
def test_iplistitemresource_on_get_found(client, superuser):
    ip_list = IPList(name="test-list", created_by=User.get_by_token(superuser))
    ip_list.save()
    resp = client.simulate_get(
        "/api/test/iplists/test-list/items",
        headers={"Authorization": f"Token {superuser}"},
    )
    assert resp.status_code == 200
Ejemplo n.º 2
0
def test_status(client):
    response = 'Everything is fine!'
    result = client.simulate_get('/v1/status')

    assert result.json['response'] == response and result.status_code == 200
Ejemplo n.º 3
0
def test_user_on_get_found(client, superuser):
    resp = client.simulate_get("/api/test/users/superuser",
                               headers={"Authorization": f"Token {superuser}"})
    assert resp.status_code == 200
    assert "user" in resp.json
Ejemplo n.º 4
0
def test_user_on_get_list_is_admin(client, superuser):
    u = create_user("test-user", "test-password")
    resp = client.simulate_get("/api/test/users",
                               headers={"Authorization": f"Token {superuser}"})
    assert resp.status_code == 200
    assert "users" in resp.json
Ejemplo n.º 5
0
def test_user_on_get_found_not_admin_bad(client, superuser):
    u = create_user("test-user", "test-password")
    resp = client.simulate_get("/api/test/users/superuser",
                               headers={"Authorization": f"Token {u}"})
    assert resp.status_code == 403
Ejemplo n.º 6
0
def test_iplistresource_list_on_get(client, superuser):
    resp = client.simulate_get(
        "/api/test/iplists", headers={"Authorization": f"Token {superuser}"}
    )
    assert resp.status_code == 200
    assert "iplists" in resp.json
Ejemplo n.º 7
0
def test_token_on_get_found_is_not_admin_ok(client, superuser):
    u = create_user("test-user", "test-user")
    resp = client.simulate_get("/api/test/tokens/test-user",
                               headers={"Authorization": f"Token {u}"})
    assert resp.status_code == 200
    assert "token" in resp.json
Ejemplo n.º 8
0
def test_token_on_get_notfound(client, superuser):
    resp = client.simulate_get("/api/test/tokens/not-found",
                               headers={"Authorization": f"Token {superuser}"})
    assert resp.status_code == 404
Ejemplo n.º 9
0
def test_ges_get_found(client, superuser):
    resp = client.simulate_get("/api/test/geo/1.1.1.1",
                               headers={"Authorization": f"Token {superuser}"})
    assert resp.status_code == 200
    assert "city" in resp.json