Skip to content

Commit

Permalink
chore: add 'is_superuser' field for POST /users/ endpoint (#703)
Browse files Browse the repository at this point in the history
* add 'is_superuser' field for POST /users/ endpoint, defaults to false
  • Loading branch information
Dostonbek1 authored Mar 5, 2024
1 parent 4f69f6a commit c30db22
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/aap_eda/api/serializers/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ class Meta:
"last_name",
"email",
"password",
"is_superuser",
"roles",
]

Expand Down
26 changes: 26 additions & 0 deletions tests/integration/api/test_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Expand Down

0 comments on commit c30db22

Please sign in to comment.