diff --git a/app/server.py b/app/server.py index edfb980..84abf49 100644 --- a/app/server.py +++ b/app/server.py @@ -1,4 +1,5 @@ import logging +import os from urllib.error import HTTPError import sentry_sdk @@ -41,10 +42,16 @@ ) -@application.route("/", methods=["GET"]) -@application.route("/status/health", methods=["GET"]) -def status_health(): - return success_response_json("OK") +@application.route("/") +@application.route("/status/health") +def health_check(): + return success_response_json( + { + "gitSha": os.getenv("MA_GIT_SHA", -1), + "buildId": os.getenv("MA_BUILD_ID", -1), + "otapEnv": os.getenv("MA_OTAP_ENV", None), + } + ) @application.route(f"{API_BASE_PATH}/uitkering-en-stadspas/aanvragen", methods=["GET"]) diff --git a/app/test_server.py b/app/test_server.py index 277d5b4..d638516 100644 --- a/app/test_server.py +++ b/app/test_server.py @@ -1,4 +1,5 @@ import datetime +import os from unittest.mock import patch from app.test_app import WpiApiTestApp @@ -8,14 +9,22 @@ from app.utils import encrypt +@patch.dict( + os.environ, + { + "MA_BUILD_ID": "999", + "MA_GIT_SHA": "abcdefghijk", + "MA_OTAP_ENV": "unittesting", + }, +) class WPITestServer(WpiApiTestApp): - def test_status_health(self): + def test_status(self): response = self.client.get("/status/health") - data = response.get_json() - self.assertEqual(response.status_code, 200) - self.assertEqual(data["status"], "OK") - self.assertEqual(data["content"], "OK") + self.assertEqual( + response.data.decode(), + '{"content":{"buildId":"999","gitSha":"abcdefghijk","otapEnv":"unittesting"},"status":"OK"}\n', + ) @patch("app.server.get_aanvragen") def test_aanvragen(self, get_aanvragen_mock): diff --git a/azure-pipelines.yaml b/azure-pipelines.yaml index 569a397..85a3007 100644 --- a/azure-pipelines.yaml +++ b/azure-pipelines.yaml @@ -2,8 +2,8 @@ trigger: batch: true branches: include: - - ontwikkelen - testen + - az-acceptance pr: autoCancel: true branches: @@ -32,22 +32,28 @@ parameters: default: none values: - none - - o - t - # - a - # - p - + - a + - p - name: updateAppSettings type: boolean default: false variables: - - ${{ if eq(variables['Build.SourceBranchName'], 'ontwikkelen') }}: - - name: dtapName - value: o - ${{ if or(eq(variables['Build.SourceBranchName'], 'testen'), eq(variables['Build.Reason'], 'PullRequest')) }}: - name: dtapName value: t + - ${{ if eq(variables['Build.SourceBranchName'], 'az-acceptance') }}: + - name: dtapName + value: a + - ${{ if eq(variables['Build.Reason'], 'PullRequest') }}: + - name: btdDeploy + value: false + - ${{ if ne(variables['Build.Reason'], 'PullRequest') }}: + - name: btdDeploy + value: ${{ parameters.btdDeploy }} + - name: dtapName + value: t - ${{ if ne(parameters.dtapName, 'none') }}: - name: dtapName value: ${{ parameters.dtapName }} @@ -59,6 +65,6 @@ jobs: dtapName: ${{ variables.dtapName }} btdBuild: ${{ parameters.btdBuild }} btdTest: ${{ parameters.btdTest }} - btdDeploy: ${{ parameters.btdDeploy }} + btdDeploy: ${{ variables.btdDeploy }} updateAppSettings: ${{ parameters.updateAppSettings }} aquaScan: ${{ eq(variables['Build.Reason'], 'PullRequest') }} diff --git a/requirements.txt b/requirements.txt index 25665ad..0ceebf4 100644 --- a/requirements.txt +++ b/requirements.txt @@ -6,7 +6,7 @@ # attrs==23.1.0 # via zeep -black==23.10.1 +black==23.11.0 # via -r requirements-root.txt blinker==1.7.0 # via