mirror of
https://github.com/fastapi-users/fastapi-users.git
synced 2025-08-17 05:38:33 +08:00
Fix #17: prevent to set is_active/is_superuser on register route
This commit is contained in:
@ -91,6 +91,30 @@ class TestRegister:
|
||||
assert "password" not in response_json
|
||||
assert "id" in response_json
|
||||
|
||||
def test_valid_body_is_superuser(self, test_app_client: TestClient):
|
||||
json = {
|
||||
"email": "lancelot@camelot.bt",
|
||||
"password": "guinevere",
|
||||
"is_superuser": True,
|
||||
}
|
||||
response = test_app_client.post("/register", json=json)
|
||||
assert response.status_code == status.HTTP_201_CREATED
|
||||
|
||||
response_json = response.json()
|
||||
assert response_json["is_superuser"] is False
|
||||
|
||||
def test_valid_body_is_active(self, test_app_client: TestClient):
|
||||
json = {
|
||||
"email": "lancelot@camelot.bt",
|
||||
"password": "guinevere",
|
||||
"is_active": False,
|
||||
}
|
||||
response = test_app_client.post("/register", json=json)
|
||||
assert response.status_code == status.HTTP_201_CREATED
|
||||
|
||||
response_json = response.json()
|
||||
assert response_json["is_active"] is True
|
||||
|
||||
|
||||
class TestLogin:
|
||||
def test_empty_body(self, test_app_client: TestClient):
|
||||
|
Reference in New Issue
Block a user