Commit bf9ac26a by Carson Gee

Corrected CMS tests so that one is passing, added external_auth to cms apps

Several pylint fixes and bad super call
parent 96c7cb5f
...@@ -385,6 +385,9 @@ INSTALLED_APPS = ( ...@@ -385,6 +385,9 @@ INSTALLED_APPS = (
'student', # misleading name due to sharing with lms 'student', # misleading name due to sharing with lms
'course_groups', # not used in cms (yet), but tests run 'course_groups', # not used in cms (yet), but tests run
# External auth (OpenID, shib, SSL)
'external_auth',
# Tracking # Tracking
'track', 'track',
'eventtracking.django', 'eventtracking.django',
......
...@@ -45,7 +45,7 @@ class SSLClientTest(TestCase): ...@@ -45,7 +45,7 @@ class SSLClientTest(TestCase):
def setUp(self): def setUp(self):
"""Setup test case by adding primary user.""" """Setup test case by adding primary user."""
super(TestCase, self).setUp() super(SSLClientTest, self).setUp()
self.client = Client() self.client = Client()
self.factory = RequestFactory() self.factory = RequestFactory()
...@@ -62,7 +62,7 @@ class SSLClientTest(TestCase): ...@@ -62,7 +62,7 @@ class SSLClientTest(TestCase):
# auth should not have a user # auth should not have a user
self.assertIn('<form role="form" id="register-form" method="post"', response.content) self.assertIn('<form role="form" id="register-form" method="post"', response.content)
try: try:
eamap_user = ExternalAuthMap.objects.get(external_id=self.USER_EMAIL) ExternalAuthMap.objects.get(external_id=self.USER_EMAIL)
except ExternalAuthMap.DoesNotExist, ex: except ExternalAuthMap.DoesNotExist, ex:
self.fail('User did not get properly added to external auth map, exception was {0}'.format(str(ex))) self.fail('User did not get properly added to external auth map, exception was {0}'.format(str(ex)))
...@@ -80,10 +80,13 @@ class SSLClientTest(TestCase): ...@@ -80,10 +80,13 @@ class SSLClientTest(TestCase):
some point. using skip here instead of expectFailure because some point. using skip here instead of expectFailure because
of an issue with nose. of an issue with nose.
""" """
response = external_auth.views.ssl_login(self._create_ssl_request(reverse('contentstore.views.login_page'))) self.client.get(
reverse('contentstore.views.login_page'),
SSL_CLIENT_S_DN=self.AUTH_DN.format(self.USER_NAME, self.USER_EMAIL)
)
try: try:
eamap_user = ExternalAuthMap.objects.get(external_id=self.USER_EMAIL) ExternalAuthMap.objects.get(external_id=self.USER_EMAIL)
except ExternalAuthMap.DoesNotExist, ex: except ExternalAuthMap.DoesNotExist, ex:
self.fail('User did not get properly added to external auth map, exception was {0}'.format(str(ex))) self.fail('User did not get properly added to external auth map, exception was {0}'.format(str(ex)))
...@@ -98,21 +101,20 @@ class SSLClientTest(TestCase): ...@@ -98,21 +101,20 @@ class SSLClientTest(TestCase):
and the user is redirected to slash. and the user is redirected to slash.
""" """
response = external_auth.views.ssl_login(self._create_ssl_request('/')) external_auth.views.ssl_login(self._create_ssl_request('/'))
# Assert our user exists in both eamap and Users, and that we are logged in # Assert our user exists in both eamap and Users, and that we are logged in
try: try:
eamap_user = ExternalAuthMap.objects.get(external_id=self.USER_EMAIL) ExternalAuthMap.objects.get(external_id=self.USER_EMAIL)
except ExternalAuthMap.DoesNotExist, ex: except ExternalAuthMap.DoesNotExist, ex:
self.fail('User did not get properly added to external auth map, exception was {0}'.format(str(ex))) self.fail('User did not get properly added to external auth map, exception was {0}'.format(str(ex)))
try: try:
user = User.objects.get(email=self.USER_EMAIL) User.objects.get(email=self.USER_EMAIL)
except ExternalAuthMap.DoesNotExist, ex: except ExternalAuthMap.DoesNotExist, ex:
self.fail('User did not get properly added to internal users, exception was {0}'.format(str(ex))) self.fail('User did not get properly added to internal users, exception was {0}'.format(str(ex)))
@unittest.skipUnless(settings.ROOT_URLCONF == 'cms.urls', 'Test only valid in cms') @unittest.skipUnless(settings.ROOT_URLCONF == 'cms.urls', 'Test only valid in cms')
@override_settings(MITX_FEATURES=MITX_FEATURES_WITH_SSL_AUTH_IMMEDIATE_SIGNUP) @override_settings(MITX_FEATURES=MITX_FEATURES_WITH_SSL_AUTH_IMMEDIATE_SIGNUP)
@unittest.skip
def test_ssl_login_without_signup_cms(self): def test_ssl_login_without_signup_cms(self):
""" """
Test IMMEDIATE_SIGNUP feature flag and ensure the user account is Test IMMEDIATE_SIGNUP feature flag and ensure the user account is
...@@ -123,16 +125,17 @@ class SSLClientTest(TestCase): ...@@ -123,16 +125,17 @@ class SSLClientTest(TestCase):
of an issue with nose. of an issue with nose.
""" """
response = external_auth.views.ssl_login( self.client.get(
self._create_ssl_request(reverse('contentstore.views.login_page')) reverse('contentstore.views.login_page'),
SSL_CLIENT_S_DN=self.AUTH_DN.format(self.USER_NAME, self.USER_EMAIL)
) )
# Assert our user exists in both eamap and Users, and that we are logged in # Assert our user exists in both eamap and Users, and that we are logged in
try: try:
eamap_user = ExternalAuthMap.objects.get(external_id=self.USER_EMAIL) ExternalAuthMap.objects.get(external_id=self.USER_EMAIL)
except ExternalAuthMap.DoesNotExist, ex: except ExternalAuthMap.DoesNotExist, ex:
self.fail('User did not get properly added to external auth map, exception was {0}'.format(str(ex))) self.fail('User did not get properly added to external auth map, exception was {0}'.format(str(ex)))
try: try:
user = User.objects.get(email=self.USER_EMAIL) User.objects.get(email=self.USER_EMAIL)
except ExternalAuthMap.DoesNotExist, ex: except ExternalAuthMap.DoesNotExist, ex:
self.fail('User did not get properly added to internal users, exception was {0}'.format(str(ex))) self.fail('User did not get properly added to internal users, exception was {0}'.format(str(ex)))
...@@ -258,7 +258,7 @@ def _signup(request, eamap): ...@@ -258,7 +258,7 @@ def _signup(request, eamap):
post_vars = dict(username=username, post_vars = dict(username=username,
honor_code=u'true', honor_code=u'true',
terms_of_service=u'true') terms_of_service=u'true')
log.info('doing immediate signup for %s, params=%s' % (username, post_vars)) log.info('doing immediate signup for %s, params=%s', username, post_vars)
student.views.create_account(request, post_vars) student.views.create_account(request, post_vars)
return redirect('/') return redirect('/')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment