Skip to content

Commit c2e25db

Browse files
authored
Merge pull request #1197 from thunderstore-io/fix-delete-service-account-cyberstorm-api
Update remove service account URL(TS-2756)
2 parents be8a3b9 + 00b7c2c commit c2e25db

File tree

4 files changed

+10
-10
lines changed

4 files changed

+10
-10
lines changed

django/thunderstore/api/cyberstorm/tests/endpoint_data.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
"DELETE": [
6161
"/api/cyberstorm/team/{team_name}/disband/",
6262
"/api/cyberstorm/team/{team_name}/member/{username}/remove/",
63-
"/api/cyberstorm/team/{team_name}/service-account/delete/{uuid}/",
63+
"/api/cyberstorm/service-account/{uuid}/delete/",
6464
"/api/cyberstorm/user/delete/",
6565
"/api/cyberstorm/user/linked-account/{provider}/disconnect/",
6666
],

django/thunderstore/api/cyberstorm/tests/test_service_account.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ def get_create_service_account_url(team_name: str) -> str:
1414
return f"/api/cyberstorm/team/{team_name}/service-account/create/"
1515

1616

17-
def get_delete_service_account_url(team_name: str, uuid: str) -> str:
18-
return f"/api/cyberstorm/team/{team_name}/service-account/delete/{uuid}/"
17+
def get_delete_service_account_url(uuid: str) -> str:
18+
return f"/api/cyberstorm/service-account/{uuid}/delete/"
1919

2020

2121
@pytest.mark.django_db
@@ -140,7 +140,7 @@ def test_delete_service_account_success(
140140
assert ServiceAccount.objects.filter(uuid=service_account.uuid).count() == 1
141141

142142
api_client.force_authenticate(team_owner.user)
143-
url = get_delete_service_account_url(team_owner.team.name, service_account.uuid)
143+
url = get_delete_service_account_url(service_account.uuid)
144144
response = api_client.delete(path=url, content_type="application/json")
145145

146146
assert response.status_code == 204
@@ -155,7 +155,7 @@ def test_delete_service_account_fail_user_is_not_authenticated(
155155
):
156156
assert ServiceAccount.objects.filter(uuid=service_account.uuid).count() == 1
157157

158-
url = get_delete_service_account_url(team.name, service_account.uuid)
158+
url = get_delete_service_account_url(service_account.uuid)
159159
response = api_client.delete(path=url, content_type="application/json")
160160
expected_response = {"detail": "Authentication credentials were not provided."}
161161

@@ -175,7 +175,7 @@ def test_delete_service_account_fails_because_user_is_not_team_member(
175175
non_team_user = User.objects.create()
176176
api_client.force_authenticate(non_team_user)
177177

178-
url = get_delete_service_account_url(team.name, service_account.uuid)
178+
url = get_delete_service_account_url(service_account.uuid)
179179
response = api_client.delete(path=url, content_type="application/json")
180180
expected_response = {"non_field_errors": ["Must be a member to access team"]}
181181

@@ -194,7 +194,7 @@ def test_delete_service_account_fail_because_user_is_not_team_owner(
194194
assert ServiceAccount.objects.filter(uuid=service_account.uuid).count() == 1
195195

196196
api_client.force_authenticate(team_member.user)
197-
url = get_delete_service_account_url(team.name, service_account.uuid)
197+
url = get_delete_service_account_url(service_account.uuid)
198198
response = api_client.delete(path=url, content_type="application/json")
199199
expected_response = {
200200
"non_field_errors": ["Must be an owner to delete a service account"]

django/thunderstore/api/cyberstorm/views/team.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ class DeleteServiceAccountAPIView(APIView):
208208

209209
@conditional_swagger_auto_schema(
210210
request_body=None,
211-
operation_id="cyberstorm.team.service-account.delete",
211+
operation_id="cyberstorm.service-account.delete",
212212
tags=["cyberstorm"],
213213
responses={status.HTTP_204_NO_CONTENT: ""},
214214
)

django/thunderstore/api/urls.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,9 +200,9 @@
200200
name="cyberstorm.team.service-account.create",
201201
),
202202
path(
203-
"team/<str:team_name>/service-account/delete/<uuid:uuid>/",
203+
"service-account/<uuid:uuid>/delete/",
204204
DeleteServiceAccountAPIView.as_view(),
205-
name="cyberstorm.team.service-account.delete",
205+
name="cyberstorm.service-account.delete",
206206
),
207207
path(
208208
"user/delete/",

0 commit comments

Comments
 (0)