never return 204, always return json response body

This commit is contained in:
burnettk 2022-09-29 00:13:30 -04:00
parent 8ca5515c16
commit 8da5746bf6
2 changed files with 9 additions and 7 deletions

View File

@ -1282,19 +1282,20 @@ def add_secret(body: Dict) -> Response:
)
def update_secret(key: str, body: dict) -> None:
def update_secret(key: str, body: dict) -> Response:
"""Update secret."""
SecretService().update_secret(key, body["value"], body["creator_user_id"])
return Response(json.dumps({"ok": True}), status=200, mimetype="application/json")
def delete_secret(key: str) -> None:
def delete_secret(key: str) -> Response:
"""Delete secret."""
current_user = UserService.current_user()
SecretService.delete_secret(key, current_user.id)
return Response(json.dumps({"ok": True}), status=200, mimetype="application/json")
def add_allowed_process_path(body: dict) -> Any:
def add_allowed_process_path(body: dict) -> Response:
"""Get allowed process paths."""
allowed_process_path = SecretService.add_allowed_process(
body["secret_id"], g.user.id, body["allowed_relative_path"]
@ -1306,9 +1307,10 @@ def add_allowed_process_path(body: dict) -> Any:
)
def delete_allowed_process_path(allowed_process_path_id: int) -> Any:
def delete_allowed_process_path(allowed_process_path_id: int) -> Response:
"""Get allowed process paths."""
SecretService().delete_allowed_process(allowed_process_path_id, g.user.id)
return Response(json.dumps({"ok": True}), status=200, mimetype="application/json")
def get_required_parameter_or_raise(parameter: str, post_body: dict[str, Any]) -> Any:

View File

@ -394,7 +394,7 @@ class TestSecretServiceApi(SecretServiceTestHelpers):
content_type="application/json",
data=json.dumps(SecretModelSchema().dump(secret_model)),
)
assert response.status_code == 204
assert response.status_code == 200
secret_model = SecretModel.query.filter(
SecretModel.key == self.test_key
@ -414,7 +414,7 @@ class TestSecretServiceApi(SecretServiceTestHelpers):
f"/v1.0/secrets/{self.test_key}",
headers=self.logged_in_headers(user),
)
assert secret_response.status_code == 204
assert secret_response.status_code == 200
secret = SecretService.get_secret(self.test_key)
assert secret is None
@ -489,6 +489,6 @@ class TestSecretServiceApi(SecretServiceTestHelpers):
f"/v1.0/secrets/allowed_process_paths/{allowed_process.id}",
headers=self.logged_in_headers(user),
)
assert response.status_code == 204
assert response.status_code == 200
allowed_processes = SecretAllowedProcessPathModel.query.all()
assert len(allowed_processes) == 0