Fixed unit tests.

This commit is contained in:
Antoine Nguyen
2020-11-10 16:07:34 +01:00
parent e4f5a25e64
commit b9720c1837
3 changed files with 6 additions and 11 deletions
@@ -197,7 +197,8 @@ REST_FRAMEWORK = {
SPECTACULAR_SETTINGS = {
'SCHEMA_PATH_PREFIX': r'/api/v1',
'TITLE': 'Modoboa API',
'VERSION': '1.0.0'
'VERSION': '1.0.0',
'SERVE_PERMISSIONS': ['rest_framework.permissions.IsAuthenticated'],
}
# Modoboa settings
+2 -9
View File
@@ -4,16 +4,13 @@ from modoboa.lib.tests import ModoTestCase
class OpenAPITestCase(ModoTestCase):
openapi_schema_url = reverse_lazy('openapi_schema')
openapi_schema_url = reverse_lazy('schema')
def test_unauthorized(self):
self.client.logout()
response = self.client.get("/docs/api/")
self.assertRedirects(response, "/accounts/login/?next=/docs/api/")
response = self.client.get(self.openapi_schema_url)
self.assertEqual(response.status_code, 403)
self.assertEqual(response.status_code, 401)
def test_get_schema(self):
self.assertEqual(self.openapi_schema_url, "/docs/openapi.json")
@@ -24,7 +21,3 @@ class OpenAPITestCase(ModoTestCase):
'title': "Modoboa API",
'version': "1.0.0",
})
def test_get_swagger_ui(self):
response = self.client.get("/docs/api/")
self.assertContains(response, "Modoboa API")
+2 -1
View File
@@ -191,7 +191,8 @@ REST_FRAMEWORK = {
SPECTACULAR_SETTINGS = {
'SCHEMA_PATH_PREFIX': r'/api/v1',
'TITLE': 'Modoboa API',
'VERSION': '1.0.0'
'VERSION': '1.0.0',
'SERVE_PERMISSIONS': ['rest_framework.permissions.IsAuthenticated'],
}
# Modoboa settings