コード例 #1
0
def test_user_on_put_not_admin_ok(client, superuser):
    u = create_user("test-user", "test-password")
    json = {"password": "******"}
    resp = client.simulate_put("/api/test/users/superuser",
                               headers={"Authorization": f"Token {u}"},
                               json=json)
    assert resp.status_code == 403
コード例 #2
0
def test_user_on_put_not_admin_bad_own_attributes(client):
    u = create_user("test-user", "test-password")
    json = {"is_admin": True}
    resp = client.simulate_put("/api/test/users/test-user",
                               headers={"Authorization": f"Token {u}"},
                               json=json)
    assert resp.status_code == 403
コード例 #3
0
def test_iplistresource_on_put_ok(client, superuser):
    ip_list = IPList(name="test-list", created_by=User.get_by_token(superuser))
    ip_list.save()
    json = {"description": "test-list"}
    resp = client.simulate_put(
        "/api/test/iplists/test-list",
        headers={"Authorization": f"Token {superuser}"},
        json=json,
    )
    assert resp.status_code == 200
    assert resp.json["status"] == "Success"
コード例 #4
0
def test_user_on_put_is_admin(client, superuser):
    create_user("test-user", "test-password")
    json = {
        "password": "******",
        "is_admin": True,
        "is_manager": True,
        "is_active": False,
    }
    resp = client.simulate_put(
        "/api/test/users/test-user",
        headers={"Authorization": f"Token {superuser}"},
        json=json,
    )
    assert resp.status_code == 200
    assert resp.json["status"] == "Success"
コード例 #5
0
def test_token_on_put_notfound(client, superuser):
    resp = client.simulate_put("/api/test/tokens/notfound",
                               headers={"Authorization": f"Token {superuser}"})
    assert resp.status_code == 404
コード例 #6
0
def test_token_on_put_is_not_admin_ok(client, superuser):
    u = create_user("test-user", "test-user")
    resp = client.simulate_put("/api/test/tokens/test-user",
                               headers={"Authorization": f"Token {u}"})
    assert resp.status_code == 200
    assert "token" in resp.json
コード例 #7
0
def test_token_on_put_is_admin(client, superuser):
    resp = client.simulate_put("/api/test/tokens/superuser",
                               headers={"Authorization": f"Token {superuser}"})
    assert resp.status_code == 200
    assert "token" in resp.json