From e1d0275723cbd01461e5c9e26e82c464e0f94c0d Mon Sep 17 00:00:00 2001 From: Tim van Oostrom Date: Fri, 10 Nov 2023 14:00:20 +0100 Subject: [PATCH] Mijn 6927 env agnostic (#56) * Add env param * Add acc * Enable aquascan * Add test * Update requirements --- app/test_server.py | 29 ++++++++++++++++++++--------- azure-pipelines.yaml | 24 +++++++++++++++--------- requirements.txt | 8 ++++++-- 3 files changed, 41 insertions(+), 20 deletions(-) diff --git a/app/test_server.py b/app/test_server.py index d8328a0..3f60d16 100644 --- a/app/test_server.py +++ b/app/test_server.py @@ -42,8 +42,15 @@ def json(self): return None +@patch.dict( + os.environ, + { + "MA_BUILD_ID": "999", + "MA_GIT_SHA": "abcdefghijk", + "MA_OTAP_ENV": "unittesting", + }, +) class TestAPI(FlaskServerTestCase): - app = app TEST_BSN = "111222333" @@ -71,7 +78,7 @@ def test_get_voorzieningen(self, api_mocked): "serviceOrderDate": "2017-06-01", "supplier": "Welzorg", "title": "autozitje", - 'documents': None, + "documents": None, }, { "dateDecision": "2013-06-17", @@ -85,7 +92,7 @@ def test_get_voorzieningen(self, api_mocked): "serviceOrderDate": "2017-06-01", "supplier": "Welzorg", "title": "buggy", - 'documents': None, + "documents": None, }, { "dateDecision": "2015-02-16", @@ -99,7 +106,7 @@ def test_get_voorzieningen(self, api_mocked): "serviceOrderDate": "2017-06-01", "supplier": "Welzorg", "title": "driewielfiets 5-9 jr", - 'documents': None, + "documents": None, }, { "dateDecision": "2021-08-26", @@ -113,7 +120,7 @@ def test_get_voorzieningen(self, api_mocked): "serviceOrderDate": "2021-08-30", "supplier": "Welzorg", "title": "handbewogen kinderrolstoel", - 'documents': None, + "documents": None, }, { "dateDecision": "2018-04-25", @@ -127,7 +134,7 @@ def test_get_voorzieningen(self, api_mocked): "serviceOrderDate": "2018-04-26", "supplier": "Welzorg", "title": "woonruimteaanpassing", - 'documents': None, + "documents": None, }, ], ) @@ -162,6 +169,10 @@ def test_get_voorzieningen_token_error(self, api_mocked): self.assertEqual(res.status_code, 401, res.data) self.assertEqual(res.json["status"], "ERROR") - def test_health_page(self): - res = self.client.get("/status/health") - self.assertEqual(res.json["status"], "OK") + def test_status(self): + response = self.client.get("/status/health") + self.assertEqual(response.status_code, 200) + self.assertEqual( + response.data.decode(), + '{"content":{"buildId":"999","gitSha":"abcdefghijk","otapEnv":"unittesting"},"status":"OK"}\n', + ) diff --git a/azure-pipelines.yaml b/azure-pipelines.yaml index 650da0e..f4dfde1 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,20 +32,26 @@ parameters: default: none values: - none - - o - t - # - a - # - p - + - a + - p - name: updateAppSettings type: boolean default: false variables: - - ${{ if eq(variables['Build.SourceBranchName'], 'ontwikkelen') }}: + - ${{ 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: o - - ${{ if or(eq(variables['Build.SourceBranchName'], 'testen'), eq(variables['Build.Reason'], 'PullRequest'), eq(parameters.dtapName, 'none')) }}: + 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') }}: @@ -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 6ac0dfc..5bee9b8 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,10 +1,10 @@ # -# This file is autogenerated by pip-compile with Python 3.10 +# This file is autogenerated by pip-compile with Python 3.9 # by the following command: # # pip-compile --output-file=requirements.txt requirements-root.txt # -black==23.10.1 +black==23.11.0 # via -r requirements-root.txt blinker==1.7.0 # via @@ -39,6 +39,8 @@ flask-httpauth==4.8.0 # via -r requirements-root.txt idna==3.4 # via requests +importlib-metadata==6.8.0 + # via flask itsdangerous==2.1.2 # via flask jinja2==3.1.2 @@ -80,3 +82,5 @@ urllib3==2.0.7 # sentry-sdk werkzeug==3.0.1 # via flask +zipp==3.17.0 + # via importlib-metadata