Skip to content

Commit

Permalink
Mijn 6927 env agnostic (#56)
Browse files Browse the repository at this point in the history
* Add env param

* Add acc

* Enable aquascan

* Add test

* Update requirements
  • Loading branch information
timvanoostrom authored Nov 10, 2023
1 parent e0e1ff8 commit e1d0275
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 20 deletions.
29 changes: 20 additions & 9 deletions app/test_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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",
Expand All @@ -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",
Expand All @@ -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",
Expand All @@ -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",
Expand All @@ -127,7 +134,7 @@ def test_get_voorzieningen(self, api_mocked):
"serviceOrderDate": "2018-04-26",
"supplier": "Welzorg",
"title": "woonruimteaanpassing",
'documents': None,
"documents": None,
},
],
)
Expand Down Expand Up @@ -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',
)
24 changes: 15 additions & 9 deletions azure-pipelines.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ trigger:
batch: true
branches:
include:
- ontwikkelen
- testen
- az-acceptance
pr:
autoCancel: true
branches:
Expand Down Expand Up @@ -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') }}:
Expand All @@ -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') }}
8 changes: 6 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -80,3 +82,5 @@ urllib3==2.0.7
# sentry-sdk
werkzeug==3.0.1
# via flask
zipp==3.17.0
# via importlib-metadata

0 comments on commit e1d0275

Please sign in to comment.