Skip to content

Commit

Permalink
Merge pull request #370 from ropable/master
Browse files Browse the repository at this point in the history
Increment project version
  • Loading branch information
ropable authored Mar 11, 2024
2 parents aeeb38b + 084bf5b commit dbcd235
Show file tree
Hide file tree
Showing 9 changed files with 118 additions and 176 deletions.
13 changes: 6 additions & 7 deletions itassets/middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,13 @@ def readiness(self, request):
"""
try:
from django.db import connections
for name in connections:
cursor = connections[name].cursor()
cursor.execute("SELECT 1;")
row = cursor.fetchone()
if row is None:
return HttpResponseServerError("db: invalid response")
cursor = connections["default"].cursor()
cursor.execute("SELECT 1;")
row = cursor.fetchone()
if row is None:
return HttpResponseServerError("Database: invalid response")
except Exception as e:
LOGGER.exception(e)
return HttpResponseServerError("db: cannot connect to database.")
return HttpResponseServerError("Database: unable to connect")

return HttpResponse("OK")
69 changes: 0 additions & 69 deletions itassets/models.py

This file was deleted.

2 changes: 2 additions & 0 deletions itassets/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,14 @@ def setUp(self):
email=random_dbca_email, ad_guid=uuid1, in_sync=False,
account_type=2, # Permanent
cost_centre=self.cc1,
assigned_licences=['MICROSOFT 365 E5'],
)
self.user2 = mixer.blend(
DepartmentUser, active=True,
email=random_dbca_email, ad_guid=uuid1, in_sync=False,
account_type=3, # Agency contract
cost_centre=self.cc1,
assigned_licences=['MICROSOFT 365 F3'],
)
self.inactive_user = mixer.blend(
DepartmentUser, active=False,
Expand Down
53 changes: 0 additions & 53 deletions itassets/utils_meraki.py

This file was deleted.

2 changes: 1 addition & 1 deletion kustomize/overlays/prod/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ patches:
- path: postgres_fdw_service_patch.yaml
images:
- name: ghcr.io/dbca-wa/it-assets
newTag: 2.4.17
newTag: 2.4.18
18 changes: 18 additions & 0 deletions kustomize/overlays/uat/ingress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,21 @@ spec:
name: itassets-clusterip-uat
port:
number: 8080
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: addressbook-ingress
spec:
ingressClassName: nginx
rules:
- host: addressbook-uat.dbca.wa.gov.au
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: itassets-clusterip-uat
port:
number: 8080
42 changes: 42 additions & 0 deletions organisation/test_views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
from django.urls import reverse
from itassets.test_api import ApiTestCase


class ViewsTestCase(ApiTestCase):

def test_view_address_book(self):
"""Test the Address Book view
"""
url = reverse("address_book")
resp = self.client.get(url)
self.assertEqual(resp.status_code, 200)
self.assertContains(resp, self.user1.name)
self.assertContains(resp, self.user2.name)
# Check the exclusion rules.
self.assertNotContains(resp, self.inactive_user.name)
self.assertNotContains(resp, self.shared_acct.name)
self.assertNotContains(resp, self.contractor.name)

def test_view_address_book_filtered(self):
"""Test the filtered Address Book view
"""
url = reverse("address_book") + f"?q={self.user1.name}"
resp = self.client.get(url)
self.assertEqual(resp.status_code, 200)
self.assertContains(resp, self.user1.name)
self.assertNotContains(resp, self.user2.name)

def test_view_user_accounts(self):
"""Test the User Accounts view
"""
url = reverse("user_accounts")
resp = self.client.get(url)
self.assertEqual(resp.status_code, 200)
self.assertContains(resp, self.user1.name)
self.assertContains(resp, self.user2.name)
# Remove the license from a user and re-check.
self.user1.assigned_licences = []
self.user1.save()
resp = self.client.get(url)
self.assertNotContains(resp, self.user1.name)
self.assertContains(resp, self.user2.name)
70 changes: 35 additions & 35 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit dbcd235

Please sign in to comment.