auth: Move some simple GitHub tests to the long-term test class.

This commit is contained in:
Tim Abbott 2018-06-04 21:50:54 -07:00
parent 869d75b02f
commit 238ba2d486
1 changed files with 23 additions and 23 deletions

View File

@ -619,6 +619,29 @@ class GitHubAuthBackendTest(ZulipTestCase):
with self.settings(AUTHENTICATION_BACKENDS=('zproject.backends.GitHubAuthBackend',)): with self.settings(AUTHENTICATION_BACKENDS=('zproject.backends.GitHubAuthBackend',)):
self.assertTrue(github_auth_enabled()) self.assertTrue(github_auth_enabled())
def test_login_url(self) -> None:
result = self.client_get('/accounts/login/social/github')
self.assertIn(reverse('social:begin', args=['github']), result.url)
self.assertIn('is_signup=0', result.url)
def test_login_url_with_next_param(self) -> None:
result = self.client_get('/accounts/login/social/github',
{'next': "/image_path"})
self.assertIn(reverse('social:begin', args=['github']), result.url)
self.assertIn('is_signup=0', result.url)
self.assertIn('image_path', result.url)
result = self.client_get('/accounts/login/social/github',
{'next': '/#narrow/stream/7-test-here'})
self.assertIn(reverse('social:begin', args=['github']), result.url)
self.assertIn('is_signup=0', result.url)
self.assertIn('narrow', result.url)
def test_signup_url(self) -> None:
result = self.client_get('/accounts/register/social/github')
self.assertIn(reverse('social:begin', args=['github']), result.url)
self.assertIn('is_signup=1', result.url)
class GitHubAuthBackendLegacyTest(ZulipTestCase): class GitHubAuthBackendLegacyTest(ZulipTestCase):
def setUp(self) -> None: def setUp(self) -> None:
self.user_profile = self.example_user('hamlet') self.user_profile = self.example_user('hamlet')
@ -903,29 +926,6 @@ class GitHubAuthBackendLegacyTest(ZulipTestCase):
'that are allowed to register for accounts in this organization.', 'that are allowed to register for accounts in this organization.',
result) result)
def test_login_url(self) -> None:
result = self.client_get('/accounts/login/social/github')
self.assertIn(reverse('social:begin', args=['github']), result.url)
self.assertIn('is_signup=0', result.url)
def test_login_url_with_next_param(self) -> None:
result = self.client_get('/accounts/login/social/github',
{'next': "/image_path"})
self.assertIn(reverse('social:begin', args=['github']), result.url)
self.assertIn('is_signup=0', result.url)
self.assertIn('image_path', result.url)
result = self.client_get('/accounts/login/social/github',
{'next': '/#narrow/stream/7-test-here'})
self.assertIn(reverse('social:begin', args=['github']), result.url)
self.assertIn('is_signup=0', result.url)
self.assertIn('narrow', result.url)
def test_signup_url(self) -> None:
result = self.client_get('/accounts/register/social/github')
self.assertIn(reverse('social:begin', args=['github']), result.url)
self.assertIn('is_signup=1', result.url)
def test_github_complete(self) -> None: def test_github_complete(self) -> None:
from social_django import utils from social_django import utils
utils.BACKENDS = ('zproject.backends.GitHubAuthBackend',) utils.BACKENDS = ('zproject.backends.GitHubAuthBackend',)