diff --git a/spiffworkflow-backend/src/spiffworkflow_backend/api.yml b/spiffworkflow-backend/src/spiffworkflow_backend/api.yml index b1eb5cc4..664b9186 100755 --- a/spiffworkflow-backend/src/spiffworkflow_backend/api.yml +++ b/spiffworkflow-backend/src/spiffworkflow_backend/api.yml @@ -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 diff --git a/spiffworkflow-backend/src/spiffworkflow_backend/routes/health_controller.py b/spiffworkflow-backend/src/spiffworkflow_backend/routes/health_controller.py index 2cb4092b..05408a4f 100644 --- a/spiffworkflow-backend/src/spiffworkflow_backend/routes/health_controller.py +++ b/spiffworkflow-backend/src/spiffworkflow_backend/routes/health_controller.py @@ -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.") diff --git a/spiffworkflow-backend/src/spiffworkflow_backend/services/authorization_service.py b/spiffworkflow-backend/src/spiffworkflow_backend/services/authorization_service.py index 85bb6fda..eb2478a5 100644 --- a/spiffworkflow-backend/src/spiffworkflow_backend/services/authorization_service.py +++ b/spiffworkflow-backend/src/spiffworkflow_backend/services/authorization_service.py @@ -310,6 +310,7 @@ class AuthorizationService: swagger_functions = ["get_json_spec"] authentication_exclusion_list = [ "status", + "test_raise_error", "authentication_callback", "github_webhook_receive", ] diff --git a/spiffworkflow-backend/tests/spiffworkflow_backend/integration/test_health_controller.py b/spiffworkflow-backend/tests/spiffworkflow_backend/integration/test_health_controller.py new file mode 100644 index 00000000..4958dcdb --- /dev/null +++ b/spiffworkflow-backend/tests/spiffworkflow_backend/integration/test_health_controller.py @@ -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