'Auto signup auth user and ensure they return to the original
url they visited after being logged in.'

@skip_unless_cms
@override_settings(FEATURES=FEATURES_WITH_SSL_AUTH_AUTO_ACTIVATE)
def test_ssl_cms_redirection(self):

    course = CourseFactory.create(org='MITx', number='999', display_name='Robot    Super    Course')
    with self._create_ssl_request('/') as request:
        external_auth_views.ssl_login(request)
    user = User.objects.get(email=self.USER_EMAIL)
    CourseEnrollment.enroll(user, course.id)
    CourseStaffRole(course.id).add_users(user)
    course_private_url = reverse('course_handler', args=(unicode(course.id),))
    self.assertNotIn(SESSION_KEY, self.client.session)
    response = self.client.get(course_private_url, follow=True, SSL_CLIENT_S_DN=self.AUTH_DN.format(self.USER_NAME, self.USER_EMAIL), HTTP_ACCEPT='text/html')
    self.assertEqual(('http://testserver{0}'.format(course_private_url), 302), response.redirect_chain[(-1)])
    self.assertIn(SESSION_KEY, self.client.session)
