2016-07-25 22:12:12 +02:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
2017-10-28 00:44:19 +02:00
|
|
|
import mock
|
2016-07-25 22:12:12 +02:00
|
|
|
import os
|
2017-03-08 12:33:50 +01:00
|
|
|
import subprocess
|
2016-09-14 07:07:21 +02:00
|
|
|
|
2016-07-19 14:35:08 +02:00
|
|
|
from django.conf import settings
|
|
|
|
from django.test import TestCase, override_settings
|
2018-05-11 16:35:03 +02:00
|
|
|
from django.http import HttpResponse
|
2017-05-10 20:28:05 +02:00
|
|
|
from typing import Any, Dict, List
|
2016-09-14 07:07:21 +02:00
|
|
|
|
2016-07-25 22:12:12 +02:00
|
|
|
from zproject.settings import DEPLOY_ROOT
|
2017-11-15 22:58:34 +01:00
|
|
|
from zerver.lib.integrations import INTEGRATIONS
|
2017-03-08 12:32:41 +01:00
|
|
|
from zerver.lib.test_classes import ZulipTestCase
|
2016-09-28 06:06:21 +02:00
|
|
|
from zerver.lib.test_helpers import HostRequestMock
|
2017-10-07 00:29:18 +02:00
|
|
|
from zerver.lib.test_runner import slow
|
2017-03-08 12:43:45 +01:00
|
|
|
from zerver.lib.utils import split_by
|
2017-02-28 07:18:45 +01:00
|
|
|
from zerver.views.integrations import (
|
|
|
|
add_api_uri_context,
|
|
|
|
add_integrations_context,
|
|
|
|
)
|
2016-07-25 22:12:12 +02:00
|
|
|
|
2017-03-08 12:32:41 +01:00
|
|
|
class DocPageTest(ZulipTestCase):
|
2018-05-11 16:35:03 +02:00
|
|
|
def get_doc(self, url: str, subdomain: str) -> HttpResponse:
|
|
|
|
if url[0:23] == "/integrations/doc-html/":
|
|
|
|
return self.client_get(url, subdomain=subdomain, HTTP_X_REQUESTED_WITH='XMLHttpRequest')
|
|
|
|
return self.client_get(url, subdomain=subdomain)
|
|
|
|
|
2017-11-14 02:01:44 +01:00
|
|
|
def _test(self, url: str, expected_content: str, extra_strings: List[str]=[],
|
2018-05-01 20:59:24 +02:00
|
|
|
landing_missing_strings: List[str]=[], landing_page: bool=True,
|
2018-05-11 16:35:03 +02:00
|
|
|
doc_html_str: bool=False) -> None:
|
2017-08-25 23:55:33 +02:00
|
|
|
|
2018-05-01 20:59:24 +02:00
|
|
|
# Test the URL on the "zephyr" subdomain
|
2018-05-11 16:35:03 +02:00
|
|
|
result = self.get_doc(url, subdomain="zephyr")
|
2017-07-13 01:28:38 +02:00
|
|
|
self.assertEqual(result.status_code, 200)
|
|
|
|
self.assertIn(expected_content, str(result.content))
|
|
|
|
for s in extra_strings:
|
|
|
|
self.assertIn(s, str(result.content))
|
2018-05-11 16:35:03 +02:00
|
|
|
if not doc_html_str:
|
2018-05-01 20:59:24 +02:00
|
|
|
self.assert_in_success_response(['<meta name="robots" content="noindex,nofollow">'], result)
|
2017-03-08 12:32:41 +01:00
|
|
|
|
2017-08-25 23:55:33 +02:00
|
|
|
# Test the URL on the root subdomain
|
2018-05-11 16:35:03 +02:00
|
|
|
result = self.get_doc(url, subdomain="")
|
2017-08-25 23:55:33 +02:00
|
|
|
self.assertEqual(result.status_code, 200)
|
|
|
|
self.assertIn(expected_content, str(result.content))
|
2018-05-11 16:35:03 +02:00
|
|
|
if not doc_html_str:
|
2018-05-01 20:59:24 +02:00
|
|
|
self.assert_in_success_response(['<meta name="robots" content="noindex,nofollow">'], result)
|
|
|
|
|
2017-08-25 23:55:33 +02:00
|
|
|
for s in extra_strings:
|
|
|
|
self.assertIn(s, str(result.content))
|
|
|
|
|
|
|
|
if not landing_page:
|
|
|
|
return
|
|
|
|
with self.settings(ROOT_DOMAIN_LANDING_PAGE=True):
|
2018-05-04 21:51:05 +02:00
|
|
|
# Test the URL on the root subdomain with the landing page setting
|
2018-05-11 16:35:03 +02:00
|
|
|
result = self.get_doc(url, subdomain="")
|
2017-08-25 23:55:33 +02:00
|
|
|
self.assertEqual(result.status_code, 200)
|
|
|
|
self.assertIn(expected_content, str(result.content))
|
|
|
|
for s in extra_strings:
|
|
|
|
self.assertIn(s, str(result.content))
|
2017-11-14 02:01:44 +01:00
|
|
|
for s in landing_missing_strings:
|
|
|
|
self.assertNotIn(s, str(result.content))
|
2018-05-11 16:35:03 +02:00
|
|
|
if not doc_html_str:
|
2018-05-01 20:59:24 +02:00
|
|
|
self.assert_in_success_response(['<meta name="description" content="Zulip combines'], result)
|
2018-05-11 16:35:03 +02:00
|
|
|
self.assert_not_in_success_response(['<meta name="robots" content="noindex,nofollow">'], result)
|
2017-08-25 23:55:33 +02:00
|
|
|
|
2018-05-04 21:51:05 +02:00
|
|
|
# Test the URL on the "zephyr" subdomain with the landing page setting
|
|
|
|
result = self.get_doc(url, subdomain="zephyr")
|
|
|
|
self.assertEqual(result.status_code, 200)
|
|
|
|
self.assertIn(expected_content, str(result.content))
|
|
|
|
for s in extra_strings:
|
|
|
|
self.assertIn(s, str(result.content))
|
|
|
|
if not doc_html_str:
|
|
|
|
self.assert_in_success_response(['<meta name="robots" content="noindex,nofollow">'], result)
|
|
|
|
|
2017-10-07 00:29:18 +02:00
|
|
|
@slow("Tests dozens of endpoints, including generating lots of emails")
|
2017-11-05 10:51:25 +01:00
|
|
|
def test_doc_endpoints(self) -> None:
|
2018-04-17 01:10:35 +02:00
|
|
|
self._test('/api/', 'The Zulip API')
|
2017-11-11 02:49:43 +01:00
|
|
|
self._test('/api/api-keys', 'you can use its email and API key')
|
|
|
|
self._test('/api/installation-instructions', 'No download required!')
|
2017-12-22 02:24:30 +01:00
|
|
|
self._test('/api/private-message', 'steal away your hearts')
|
|
|
|
self._test('/api/stream-message', 'rotten in the state of Denmark')
|
2017-12-30 05:09:16 +01:00
|
|
|
self._test('/api/render-message', '**foo**')
|
|
|
|
self._test('/api/get-all-streams', 'include_public')
|
|
|
|
self._test('/api/get-stream-id', 'The name of the stream to retrieve the ID for.')
|
|
|
|
self._test('/api/get-subscribed-streams', 'Get all streams that the user is subscribed to.')
|
|
|
|
self._test('/api/get-all-users', 'client_gravatar')
|
2018-01-03 01:33:30 +01:00
|
|
|
self._test('/api/register-queue', 'apply_markdown')
|
2018-01-04 00:07:26 +01:00
|
|
|
self._test('/api/get-events-from-queue', 'dont_block')
|
2018-01-04 21:35:32 +01:00
|
|
|
self._test('/api/delete-queue', 'Delete a previously registered queue')
|
2018-01-04 23:49:11 +01:00
|
|
|
self._test('/api/update-message', 'propagate_mode')
|
2018-01-05 22:31:56 +01:00
|
|
|
self._test('/api/get-profile', 'takes no arguments')
|
2018-01-06 23:49:14 +01:00
|
|
|
self._test('/api/add-subscriptions', 'authorization_errors_fatal')
|
2018-01-08 19:48:53 +01:00
|
|
|
self._test('/api/create-user', 'zuliprc-admin')
|
2018-01-11 01:43:08 +01:00
|
|
|
self._test('/api/remove-subscriptions', 'not_subscribed')
|
2017-10-31 20:27:56 +01:00
|
|
|
self._test('/team/', 'industry veterans')
|
2017-10-31 20:08:32 +01:00
|
|
|
self._test('/history/', 'Cambridge, Massachusetts')
|
2017-07-13 01:28:38 +02:00
|
|
|
# Test the i18n version of one of these pages.
|
2017-10-31 20:08:32 +01:00
|
|
|
self._test('/en/history/', 'Cambridge, Massachusetts')
|
2017-07-26 19:08:16 +02:00
|
|
|
self._test('/apps/', 'Apps for every platform.')
|
2017-08-02 09:09:10 +02:00
|
|
|
self._test('/features/', 'Beautiful messaging')
|
2017-11-14 02:01:44 +01:00
|
|
|
self._test('/hello/', 'productive group chat', landing_missing_strings=["Login"])
|
2017-07-19 05:45:45 +02:00
|
|
|
self._test('/why-zulip/', 'all stakeholders can see and')
|
2017-07-13 01:28:38 +02:00
|
|
|
self._test('/for/open-source/', 'for open source projects')
|
2017-07-30 20:14:59 +02:00
|
|
|
self._test('/for/companies/', 'in a company')
|
2017-08-01 00:19:18 +02:00
|
|
|
self._test('/for/working-groups-and-communities/', 'standards bodies')
|
2017-11-18 03:40:30 +01:00
|
|
|
self._test('/for/mystery-hunt/', 'four SIPB alums')
|
2017-12-16 21:18:27 +01:00
|
|
|
self._test('/plans/', 'Community support')
|
2017-08-25 23:55:33 +02:00
|
|
|
self._test('/devlogin/', 'Normal users', landing_page=False)
|
2017-07-13 01:28:38 +02:00
|
|
|
self._test('/devtools/', 'Useful development URLs')
|
|
|
|
self._test('/errors/404/', 'Page not found')
|
|
|
|
self._test('/errors/5xx/', 'Internal server error')
|
2017-10-25 01:58:05 +02:00
|
|
|
self._test('/emails/', 'manually generate most of the emails by clicking')
|
2017-03-08 12:32:41 +01:00
|
|
|
|
2018-05-11 16:35:03 +02:00
|
|
|
result = self.client_get('/integrations/doc-html/nonexistent_integration', follow=True,
|
|
|
|
HTTP_X_REQUESTED_WITH='XMLHttpRequest')
|
2017-07-12 02:50:27 +02:00
|
|
|
self.assertEqual(result.status_code, 404)
|
|
|
|
|
2017-07-13 01:28:38 +02:00
|
|
|
result = self.client_get('/new-user/')
|
|
|
|
self.assertEqual(result.status_code, 301)
|
|
|
|
self.assertIn('hello', result['Location'])
|
2017-03-08 12:32:41 +01:00
|
|
|
|
2017-09-16 10:55:26 +02:00
|
|
|
result = self.client_get('/static/favicon.ico')
|
2017-07-13 01:28:38 +02:00
|
|
|
self.assertEqual(result.status_code, 200)
|
2017-07-14 03:38:12 +02:00
|
|
|
|
2017-11-11 00:41:55 +01:00
|
|
|
@slow("Tests dozens of endpoints, including all our integrations docs")
|
2017-11-05 10:51:25 +01:00
|
|
|
def test_integration_doc_endpoints(self) -> None:
|
2017-11-11 00:41:55 +01:00
|
|
|
self._test('/integrations/',
|
2018-02-07 22:01:42 +01:00
|
|
|
'native integrations.',
|
2017-11-11 00:41:55 +01:00
|
|
|
extra_strings=[
|
|
|
|
'And hundreds more through',
|
|
|
|
'Hubot',
|
|
|
|
'Zapier',
|
|
|
|
'IFTTT'
|
2018-05-11 16:35:03 +02:00
|
|
|
])
|
2017-11-11 00:41:55 +01:00
|
|
|
|
|
|
|
for integration in INTEGRATIONS.keys():
|
|
|
|
url = '/integrations/doc-html/{}'.format(integration)
|
2018-05-11 16:35:03 +02:00
|
|
|
self._test(url, '', doc_html_str=True)
|
2017-11-11 00:41:55 +01:00
|
|
|
|
2018-01-25 23:38:57 +01:00
|
|
|
def test_email_integration(self) -> None:
|
|
|
|
self._test('/integrations/doc-html/email',
|
2018-05-11 16:35:03 +02:00
|
|
|
'support+abcdefg@testserver', doc_html_str=True)
|
2018-01-25 23:38:57 +01:00
|
|
|
|
|
|
|
with self.settings(EMAIL_GATEWAY_PATTERN=''):
|
2018-05-11 16:35:03 +02:00
|
|
|
result = self.get_doc('integrations/doc-html/email', subdomain='zulip')
|
2018-01-25 23:38:57 +01:00
|
|
|
self.assertNotIn('support+abcdefg@testserver', str(result.content))
|
|
|
|
# if EMAIL_GATEWAY_PATTERN is empty, the main /integrations page should
|
|
|
|
# be rendered instead
|
2018-05-11 16:35:03 +02:00
|
|
|
self._test('/integrations/', 'native integrations.')
|
|
|
|
|
|
|
|
def test_doc_html_str_non_ajax_call(self) -> None:
|
|
|
|
# We don't need to test all the pages for 404
|
|
|
|
for integration in list(INTEGRATIONS.keys())[5]:
|
|
|
|
with self.settings(ROOT_DOMAIN_LANDING_PAGE=True):
|
|
|
|
url = '/en/integrations/doc-html/{}'.format(integration)
|
|
|
|
result = self.client_get(url, subdomain="", follow=True)
|
|
|
|
self.assertEqual(result.status_code, 404)
|
|
|
|
result = self.client_get(url, subdomain="zephyr", follow=True)
|
|
|
|
self.assertEqual(result.status_code, 404)
|
|
|
|
|
|
|
|
url = '/en/integrations/doc-html/{}'.format(integration)
|
|
|
|
result = self.client_get(url, subdomain="", follow=True)
|
|
|
|
self.assertEqual(result.status_code, 404)
|
|
|
|
result = self.client_get(url, subdomain="zephyr", follow=True)
|
|
|
|
self.assertEqual(result.status_code, 404)
|
|
|
|
|
|
|
|
result = self.client_get('/integrations/doc-html/nonexistent_integration', follow=True)
|
|
|
|
self.assertEqual(result.status_code, 404)
|
2018-01-25 23:38:57 +01:00
|
|
|
|
2018-04-05 21:20:17 +02:00
|
|
|
class HelpTest(ZulipTestCase):
|
|
|
|
def test_html_settings_links(self) -> None:
|
|
|
|
result = self.client_get('/help/message-a-stream-by-email')
|
|
|
|
self.assertEqual(result.status_code, 200)
|
2018-04-05 23:39:35 +02:00
|
|
|
self.assertIn('<a target="_blank" href="/#streams">streams page</a>', str(result.content))
|
2017-11-11 00:41:55 +01:00
|
|
|
|
2018-04-18 04:31:57 +02:00
|
|
|
def test_html_settings_links_help_docs(self) -> None:
|
2018-05-14 21:32:44 +02:00
|
|
|
result = self.client_get('/help/change-the-time-format')
|
2018-04-18 04:31:57 +02:00
|
|
|
self.assertIn('click <a href="/#settings/display-settings">Display settings</a>', str(result.content))
|
|
|
|
self.assertEqual(result.status_code, 200)
|
|
|
|
|
|
|
|
with self.settings(ROOT_DOMAIN_LANDING_PAGE=True):
|
2018-05-14 21:32:44 +02:00
|
|
|
result = self.client_get('/help/change-the-time-format',
|
2018-04-18 04:31:57 +02:00
|
|
|
subdomain="")
|
|
|
|
self.assertEqual(result.status_code, 200)
|
|
|
|
self.assertIn('<strong>Display settings</strong>', str(result.content))
|
|
|
|
self.assertNotIn('click <a href="/#settings/display-settings">Display settings</a>', str(result.content))
|
|
|
|
|
2016-09-14 07:07:21 +02:00
|
|
|
class IntegrationTest(TestCase):
|
2017-11-05 10:51:25 +01:00
|
|
|
def test_check_if_every_integration_has_logo_that_exists(self) -> None:
|
2016-07-25 22:12:12 +02:00
|
|
|
for integration in INTEGRATIONS.values():
|
2016-11-23 18:58:59 +01:00
|
|
|
self.assertTrue(os.path.isfile(os.path.join(DEPLOY_ROOT, integration.logo)))
|
|
|
|
|
2017-11-05 10:51:25 +01:00
|
|
|
def test_api_url_view_subdomains_base(self) -> None:
|
2017-08-24 05:27:21 +02:00
|
|
|
context = dict() # type: Dict[str, Any]
|
|
|
|
add_api_uri_context(context, HostRequestMock())
|
2017-10-30 22:04:15 +01:00
|
|
|
self.assertEqual(context["api_url_scheme_relative"], "testserver/api")
|
|
|
|
self.assertEqual(context["api_url"], "http://testserver/api")
|
2017-08-24 05:27:21 +02:00
|
|
|
self.assertTrue(context["html_settings_links"])
|
|
|
|
|
2017-08-25 04:32:16 +02:00
|
|
|
@override_settings(ROOT_DOMAIN_LANDING_PAGE=True)
|
2017-11-05 10:51:25 +01:00
|
|
|
def test_api_url_view_subdomains_homepage_base(self) -> None:
|
2016-07-19 14:35:08 +02:00
|
|
|
context = dict() # type: Dict[str, Any]
|
|
|
|
add_api_uri_context(context, HostRequestMock())
|
2017-10-30 22:04:15 +01:00
|
|
|
self.assertEqual(context["api_url_scheme_relative"], "yourZulipDomain.testserver/api")
|
|
|
|
self.assertEqual(context["api_url"], "http://yourZulipDomain.testserver/api")
|
2017-02-28 07:18:45 +01:00
|
|
|
self.assertFalse(context["html_settings_links"])
|
2016-07-19 14:35:08 +02:00
|
|
|
|
2017-11-05 10:51:25 +01:00
|
|
|
def test_api_url_view_subdomains_full(self) -> None:
|
2016-07-19 14:35:08 +02:00
|
|
|
context = dict() # type: Dict[str, Any]
|
2016-10-06 01:42:24 +02:00
|
|
|
request = HostRequestMock(host="mysubdomain.testserver")
|
2016-07-19 14:35:08 +02:00
|
|
|
add_api_uri_context(context, request)
|
2017-10-30 22:04:15 +01:00
|
|
|
self.assertEqual(context["api_url_scheme_relative"], "mysubdomain.testserver/api")
|
|
|
|
self.assertEqual(context["api_url"], "http://mysubdomain.testserver/api")
|
2017-02-28 07:18:45 +01:00
|
|
|
self.assertTrue(context["html_settings_links"])
|
|
|
|
|
2018-04-05 20:31:43 +02:00
|
|
|
def test_html_settings_links(self) -> None:
|
|
|
|
context = dict() # type: Dict[str, Any]
|
|
|
|
with self.settings(ROOT_DOMAIN_LANDING_PAGE=True):
|
|
|
|
add_api_uri_context(context, HostRequestMock())
|
2017-02-28 07:18:45 +01:00
|
|
|
self.assertEqual(
|
|
|
|
context['settings_html'],
|
|
|
|
'Zulip settings page')
|
|
|
|
self.assertEqual(
|
|
|
|
context['subscriptions_html'],
|
2017-03-09 00:20:22 +01:00
|
|
|
'streams page')
|
2017-02-28 07:18:45 +01:00
|
|
|
|
|
|
|
context = dict()
|
2018-04-05 20:31:43 +02:00
|
|
|
with self.settings(ROOT_DOMAIN_LANDING_PAGE=True):
|
|
|
|
add_api_uri_context(context, HostRequestMock(host="mysubdomain.testserver"))
|
|
|
|
self.assertEqual(
|
|
|
|
context['settings_html'],
|
2018-04-05 23:39:35 +02:00
|
|
|
'<a href="/#settings">Zulip settings page</a>')
|
2018-04-05 20:31:43 +02:00
|
|
|
self.assertEqual(
|
|
|
|
context['subscriptions_html'],
|
2018-04-05 23:39:35 +02:00
|
|
|
'<a target="_blank" href="/#streams">streams page</a>')
|
2018-04-05 20:31:43 +02:00
|
|
|
|
|
|
|
context = dict()
|
|
|
|
add_api_uri_context(context, HostRequestMock())
|
2017-02-28 07:18:45 +01:00
|
|
|
self.assertEqual(
|
|
|
|
context['settings_html'],
|
2018-04-05 23:39:35 +02:00
|
|
|
'<a href="/#settings">Zulip settings page</a>')
|
2017-02-28 07:18:45 +01:00
|
|
|
self.assertEqual(
|
|
|
|
context['subscriptions_html'],
|
2018-04-05 23:39:35 +02:00
|
|
|
'<a target="_blank" href="/#streams">streams page</a>')
|
2017-03-08 12:33:50 +01:00
|
|
|
|
2017-07-27 03:05:45 +02:00
|
|
|
class AboutPageTest(ZulipTestCase):
|
2017-11-05 10:51:25 +01:00
|
|
|
def setUp(self) -> None:
|
2017-03-08 12:33:50 +01:00
|
|
|
""" Manual installation which did not execute `tools/provision`
|
|
|
|
would not have the `static/generated/github-contributors.json` fixture
|
|
|
|
file.
|
|
|
|
"""
|
|
|
|
# This block has unreliable test coverage due to the implicit
|
|
|
|
# caching here, so we exclude it from coverage.
|
|
|
|
if not os.path.exists(settings.CONTRIBUTORS_DATA):
|
2018-04-19 20:17:24 +02:00
|
|
|
# Copy the fixture file in `zerver/tests/fixtures` to `static/generated`
|
2017-03-08 12:33:50 +01:00
|
|
|
update_script = os.path.join(os.path.dirname(__file__),
|
|
|
|
'../../tools/update-authors-json') # nocoverage
|
|
|
|
subprocess.check_call([update_script, '--use-fixture']) # nocoverage
|
|
|
|
|
2017-11-05 10:51:25 +01:00
|
|
|
def test_endpoint(self) -> None:
|
2017-11-17 19:50:55 +01:00
|
|
|
""" We can't check the contributors list since it is rendered client-side """
|
2017-10-31 20:08:32 +01:00
|
|
|
result = self.client_get('/team/')
|
2017-11-17 19:50:55 +01:00
|
|
|
self.assert_in_success_response(['Our amazing community'], result)
|
2017-03-08 12:43:45 +01:00
|
|
|
|
2017-11-05 10:51:25 +01:00
|
|
|
def test_split_by(self) -> None:
|
2017-03-08 12:43:45 +01:00
|
|
|
"""Utility function primarily used in authors page"""
|
2017-07-27 03:05:45 +02:00
|
|
|
flat_list = [1, 2, 3, 4, 5, 6, 7, 8, 9]
|
|
|
|
expected_result = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
|
|
|
|
self.assertEqual(split_by(flat_list, 3, None), expected_result)
|
2017-08-07 17:38:25 +02:00
|
|
|
|
|
|
|
class ConfigErrorTest(ZulipTestCase):
|
|
|
|
@override_settings(GOOGLE_OAUTH2_CLIENT_ID=None)
|
2017-11-05 10:51:25 +01:00
|
|
|
def test_google(self) -> None:
|
2017-08-07 17:38:25 +02:00
|
|
|
result = self.client_get("/accounts/login/google/")
|
|
|
|
self.assertEqual(result.status_code, 302)
|
|
|
|
self.assertEqual(result.url, '/config-error/google')
|
|
|
|
result = self.client_get(result.url)
|
|
|
|
self.assert_in_success_response(["GOOGLE_OAUTH2_CLIENT_ID"], result)
|
|
|
|
|
|
|
|
@override_settings(SOCIAL_AUTH_GITHUB_KEY=None)
|
2017-11-05 10:51:25 +01:00
|
|
|
def test_github(self) -> None:
|
2017-08-07 17:38:25 +02:00
|
|
|
result = self.client_get("/accounts/login/social/github")
|
|
|
|
self.assertEqual(result.status_code, 302)
|
|
|
|
self.assertEqual(result.url, '/config-error/github')
|
|
|
|
result = self.client_get(result.url)
|
|
|
|
self.assert_in_success_response(["SOCIAL_AUTH_GITHUB_KEY"], result)
|
|
|
|
|
|
|
|
@override_settings(SOCIAL_AUTH_GITHUB_KEY=None)
|
|
|
|
@override_settings(DEVELOPMENT=False)
|
2017-11-05 10:51:25 +01:00
|
|
|
def test_github_production_error(self) -> None:
|
2017-08-07 17:38:25 +02:00
|
|
|
"""Test the !DEVELOPMENT code path of config-error."""
|
|
|
|
result = self.client_get("/accounts/login/social/github")
|
|
|
|
self.assertEqual(result.status_code, 302)
|
|
|
|
self.assertEqual(result.url, '/config-error/github')
|
|
|
|
result = self.client_get(result.url)
|
|
|
|
self.assert_in_success_response(["/etc/zulip/zulip-secrets.conf"], result)
|
2017-08-17 18:27:36 +02:00
|
|
|
|
2017-11-05 10:51:25 +01:00
|
|
|
def test_smtp_error(self) -> None:
|
2017-08-17 18:27:36 +02:00
|
|
|
result = self.client_get("/config-error/smtp")
|
|
|
|
self.assertEqual(result.status_code, 200)
|
2017-10-25 01:58:05 +02:00
|
|
|
self.assert_in_success_response(["email configuration"], result)
|
2018-02-21 06:31:53 +01:00
|
|
|
|
|
|
|
def test_dev_direct_production_error(self) -> None:
|
|
|
|
result = self.client_get("/config-error/dev")
|
|
|
|
self.assertEqual(result.status_code, 200)
|
|
|
|
self.assert_in_success_response(["DevAuthBackend"], result)
|