accounts: Standardize URL for find_account.

This changes it to match the /accounts/ URL style for all of our other
auth code path endpoints.
This commit is contained in:
Tim Abbott 2017-08-28 14:36:57 -07:00
parent 1eead8db2d
commit 50f5560bd1
4 changed files with 25 additions and 23 deletions

View File

@ -26,7 +26,7 @@
<ul>
{% if find_team_link_disabled %}
{% else %}
<li><a href="{{ root_domain_uri }}/find_account/">{{ _("Find account") }}</a></li>
<li><a href="{{ root_domain_uri }}/accounts/find">{{ _("Find account") }}</a></li>
{% endif %}
{% if open_realm_creation %}
<li><a href="{{ root_domain_uri }}/create_realm/">{{ _("New organization") }}</a></li>

View File

@ -41,7 +41,7 @@
{% if find_team_link_disabled %}
{% else %}
<li>
<a class="no-style" href="/find_account/">Find Accounts</a>
<a class="no-style" href="/accounts/find/">Find Accounts</a>
</li>
{% endif %}
</ul>

View File

@ -1726,7 +1726,7 @@ class TestLoginPage(ZulipTestCase):
ROOT_SUBDOMAIN_ALIASES=['www']):
result = self.client_get("/en/login/")
self.assertEqual(result.status_code, 302)
self.assertEqual(result.url, '/find_account/')
self.assertEqual(result.url, '/accounts/find/')
@patch('django.http.HttpRequest.get_host')
def test_login_page_redirects_for_root_domain(self, mock_get_host):
@ -1737,7 +1737,7 @@ class TestLoginPage(ZulipTestCase):
ROOT_SUBDOMAIN_ALIASES=['www']):
result = self.client_get("/en/login/")
self.assertEqual(result.status_code, 302)
self.assertEqual(result.url, '/find_account/')
self.assertEqual(result.url, '/accounts/find/')
mock_get_host.return_value = 'www.testserver.com'
with self.settings(REALMS_HAVE_SUBDOMAINS=True,
@ -1746,7 +1746,7 @@ class TestLoginPage(ZulipTestCase):
ROOT_SUBDOMAIN_ALIASES=['test']):
result = self.client_get("/en/login/")
self.assertEqual(result.status_code, 302)
self.assertEqual(result.url, '/find_account/')
self.assertEqual(result.url, '/accounts/find/')
@patch('django.http.HttpRequest.get_host')
def test_login_page_works_without_subdomains(self, mock_get_host):
@ -1764,15 +1764,15 @@ class TestLoginPage(ZulipTestCase):
class TestFindMyTeam(ZulipTestCase):
def test_template(self):
# type: () -> None
result = self.client_get('/find_account/')
result = self.client_get('/accounts/find/')
self.assertIn("Find your Zulip accounts", result.content.decode('utf8'))
def test_result(self):
# type: () -> None
result = self.client_post('/find_account/',
result = self.client_post('/accounts/find/',
dict(emails="iago@zulip.com,cordelia@zulip.com"))
self.assertEqual(result.status_code, 302)
self.assertEqual(result.url, "/find_account/?emails=iago%40zulip.com%2Ccordelia%40zulip.com")
self.assertEqual(result.url, "/accounts/find/?emails=iago%40zulip.com%2Ccordelia%40zulip.com")
result = self.client_get(result.url)
content = result.content.decode('utf8')
self.assertIn("Emails sent! You will only receive emails", content)
@ -1783,10 +1783,10 @@ class TestFindMyTeam(ZulipTestCase):
def test_find_team_ignore_invalid_email(self):
# type: () -> None
result = self.client_post('/find_account/',
result = self.client_post('/accounts/find/',
dict(emails="iago@zulip.com,invalid_email@zulip.com"))
self.assertEqual(result.status_code, 302)
self.assertEqual(result.url, "/find_account/?emails=iago%40zulip.com%2Cinvalid_email%40zulip.com")
self.assertEqual(result.url, "/accounts/find/?emails=iago%40zulip.com%2Cinvalid_email%40zulip.com")
result = self.client_get(result.url)
content = result.content.decode('utf8')
self.assertIn("Emails sent! You will only receive emails", content)
@ -1797,7 +1797,7 @@ class TestFindMyTeam(ZulipTestCase):
def test_find_team_reject_invalid_email(self):
# type: () -> None
result = self.client_post('/find_account/',
result = self.client_post('/accounts/find/',
dict(emails="invalid_string"))
self.assertEqual(result.status_code, 200)
self.assertIn(b"Enter a valid email", result.content)
@ -1805,13 +1805,13 @@ class TestFindMyTeam(ZulipTestCase):
self.assertEqual(len(outbox), 0)
# Just for coverage on perhaps-unnecessary validation code.
result = self.client_get('/find_account/?emails=invalid')
result = self.client_get('/accounts/find/?emails=invalid')
self.assertEqual(result.status_code, 200)
def test_find_team_zero_emails(self):
# type: () -> None
data = {'emails': ''}
result = self.client_post('/find_account/', data)
result = self.client_post('/accounts/find/', data)
self.assertIn('This field is required', result.content.decode('utf8'))
self.assertEqual(result.status_code, 200)
from django.core.mail import outbox
@ -1820,9 +1820,9 @@ class TestFindMyTeam(ZulipTestCase):
def test_find_team_one_email(self):
# type: () -> None
data = {'emails': self.example_email("hamlet")}
result = self.client_post('/find_account/', data)
result = self.client_post('/accounts/find/', data)
self.assertEqual(result.status_code, 302)
self.assertEqual(result.url, '/find_account/?emails=hamlet%40zulip.com')
self.assertEqual(result.url, '/accounts/find/?emails=hamlet%40zulip.com')
from django.core.mail import outbox
self.assertEqual(len(outbox), 1)
@ -1830,9 +1830,9 @@ class TestFindMyTeam(ZulipTestCase):
# type: () -> None
do_deactivate_user(self.example_user("hamlet"))
data = {'emails': self.example_email("hamlet")}
result = self.client_post('/find_account/', data)
result = self.client_post('/accounts/find/', data)
self.assertEqual(result.status_code, 302)
self.assertEqual(result.url, '/find_account/?emails=hamlet%40zulip.com')
self.assertEqual(result.url, '/accounts/find/?emails=hamlet%40zulip.com')
from django.core.mail import outbox
self.assertEqual(len(outbox), 0)
@ -1840,25 +1840,25 @@ class TestFindMyTeam(ZulipTestCase):
# type: () -> None
do_deactivate_realm(get_realm("zulip"))
data = {'emails': self.example_email("hamlet")}
result = self.client_post('/find_account/', data)
result = self.client_post('/accounts/find/', data)
self.assertEqual(result.status_code, 302)
self.assertEqual(result.url, '/find_account/?emails=hamlet%40zulip.com')
self.assertEqual(result.url, '/accounts/find/?emails=hamlet%40zulip.com')
from django.core.mail import outbox
self.assertEqual(len(outbox), 0)
def test_find_team_bot_email(self):
# type: () -> None
data = {'emails': self.example_email("webhook_bot")}
result = self.client_post('/find_account/', data)
result = self.client_post('/accounts/find/', data)
self.assertEqual(result.status_code, 302)
self.assertEqual(result.url, '/find_account/?emails=webhook-bot%40zulip.com')
self.assertEqual(result.url, '/accounts/find/?emails=webhook-bot%40zulip.com')
from django.core.mail import outbox
self.assertEqual(len(outbox), 0)
def test_find_team_more_than_ten_emails(self):
# type: () -> None
data = {'emails': ','.join(['hamlet-{}@zulip.com'.format(i) for i in range(11)])}
result = self.client_post('/find_account/', data)
result = self.client_post('/accounts/find/', data)
self.assertEqual(result.status_code, 200)
self.assertIn("Please enter at most 10", result.content.decode('utf8'))
from django.core.mail import outbox

View File

@ -127,6 +127,9 @@ i18n_urls = [
# Portico-styled page used to provide email confirmation of terms acceptance.
url(r'^accounts/accept_terms/$', zerver.views.home.accounts_accept_terms, name='zerver.views.home.accounts_accept_terms'),
# Find your account
url(r'^accounts/find/$', zerver.views.registration.find_account, name='zerver.views.registration.find_account'),
# Realm Creation
url(r'^create_realm/$', zerver.views.registration.create_realm, name='zerver.views.create_realm'),
url(r'^create_realm/(?P<creation_key>[\w]+)$', zerver.views.registration.create_realm, name='zerver.views.create_realm'),
@ -154,7 +157,6 @@ i18n_urls = [
url(r'^for/open-source/$', TemplateView.as_view(template_name='zerver/for-open-source.html')),
url(r'^for/companies/$', TemplateView.as_view(template_name='zerver/for-companies.html')),
url(r'^for/working-groups-and-communities/$', TemplateView.as_view(template_name='zerver/for-working-groups-and-communities.html')),
url(r'^find_account/$', zerver.views.registration.find_account, name='zerver.views.registration.find_account'),
# Terms of service and privacy pages.
url(r'^terms/$', TemplateView.as_view(template_name='zerver/terms.html'), name='terms'),