add test-raise-error endpoint for sentry testing, etc

This commit is contained in:
burnettk 2023-04-27 11:05:24 -04:00
parent c74474f019
commit 562cb091dc
No known key found for this signature in database
4 changed files with 55 additions and 0 deletions

View File

@ -148,6 +148,21 @@ paths:
schema:
$ref: "#/components/schemas/OkTrue"
/status/test-raise-error:
get:
operationId: spiffworkflow_backend.routes.health_controller.test_raise_error
summary: Returns an unhandled exception that should notify sentry, if sentry is configured
tags:
- Status
responses:
"500":
description: The server raises a test error as expected.
content:
application/json:
schema:
$ref: "#/components/schemas/OkTrue"
/process-groups:
parameters:
- name: process_group_identifier

View File

@ -9,3 +9,7 @@ def status() -> Response:
"""Status."""
ProcessInstanceModel.query.filter().first()
return make_response({"ok": True}, 200)
def test_raise_error() -> Response:
raise Exception("This exception was generated by /status/test-raise-error for testing purposes. Please ignore.")

View File

@ -310,6 +310,7 @@ class AuthorizationService:
swagger_functions = ["get_json_spec"]
authentication_exclusion_list = [
"status",
"test_raise_error",
"authentication_callback",
"github_webhook_receive",
]

View File

@ -0,0 +1,35 @@
from flask.app import Flask
from flask.testing import FlaskClient
from tests.spiffworkflow_backend.helpers.base_test import BaseTest
from spiffworkflow_backend.models.user import UserModel
class TestHealthController(BaseTest):
"""TestUsersController."""
def test_status(
self,
app: Flask,
client: FlaskClient,
with_db_and_bpmn_file_cleanup: None,
with_super_admin_user: UserModel,
) -> None:
"""Test_user_search_returns_a_user."""
response = client.get(
f"/v1.0/status",
)
assert response.status_code == 200
def test_test_raise_error(
self,
app: Flask,
client: FlaskClient,
with_db_and_bpmn_file_cleanup: None,
with_super_admin_user: UserModel,
) -> None:
"""Test_user_search_returns_a_user."""
response = client.get(
f"/v1.0/status/test-raise-error",
)
assert response.status_code == 500