-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: add 'is_superuser' field for POST /users/ endpoint (#703)
* add 'is_superuser' field for POST /users/ endpoint, defaults to false
- Loading branch information
1 parent
4f69f6a
commit c30db22
Showing
2 changed files
with
27 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -90,6 +90,7 @@ class Meta: | |
"last_name", | ||
"email", | ||
"password", | ||
"is_superuser", | ||
"roles", | ||
] | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -172,6 +172,32 @@ def test_create_user( | |
response = client.post(f"{api_url_v1}/users/", data=create_user_data) | ||
|
||
assert response.status_code == status.HTTP_201_CREATED | ||
assert response.data["is_superuser"] is False | ||
check_permission_mock.assert_called_once_with( | ||
mock.ANY, mock.ANY, ResourceType.USER, Action.CREATE | ||
) | ||
|
||
|
||
@pytest.mark.django_db | ||
def test_create_superuser( | ||
client: APIClient, | ||
check_permission_mock: mock.Mock, | ||
init_db, | ||
): | ||
create_user_data = { | ||
"username": "test.user", | ||
"first_name": "Test", | ||
"last_name": "User", | ||
"email": "[email protected]", | ||
"password": "secret", | ||
"is_superuser": True, | ||
"roles": [str(init_db.role.id)], | ||
} | ||
|
||
response = client.post(f"{api_url_v1}/users/", data=create_user_data) | ||
|
||
assert response.status_code == status.HTTP_201_CREATED | ||
assert response.data["is_superuser"] is True | ||
check_permission_mock.assert_called_once_with( | ||
mock.ANY, mock.ANY, ResourceType.USER, Action.CREATE | ||
) | ||
|