From 289589654b32703572aaf49734ef47434d92b4c8 Mon Sep 17 00:00:00 2001 From: jonaswinkler <17569239+jonaswinkler@users.noreply.github.com> Date: Fri, 26 Feb 2021 13:21:33 +0100 Subject: [PATCH] tests for API versioning --- src/documents/tests/test_api.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/documents/tests/test_api.py b/src/documents/tests/test_api.py index 9a4788135..770562ba8 100644 --- a/src/documents/tests/test_api.py +++ b/src/documents/tests/test_api.py @@ -1356,3 +1356,16 @@ class TestApiAuth(APITestCase): self.assertEqual(self.client.get("/api/documents/bulk_edit/").status_code, 401) self.assertEqual(self.client.get("/api/documents/bulk_download/").status_code, 401) self.assertEqual(self.client.get("/api/documents/selection_data/").status_code, 401) + + def test_api_version_no_auth(self): + + response = self.client.get("/api/") + self.assertNotIn("X-Api-Version", response) + self.assertNotIn("X-Version", response) + + def test_api_version_with_auth(self): + user = User.objects.create_superuser(username="test") + self.client.force_login(user) + response = self.client.get("/api/") + self.assertIn("X-Api-Version", response) + self.assertIn("X-Version", response)