Files
edx-platform/openedx/features/enterprise_support/tests/test_logout.py
Zia Fazal c718c02d6e Show blank screen instead of logout message for Enterprise SSO flow
Changes to show blank screen instead of logout message for Enterprise SSO flow. It confuses learner when they are already signed in and access their course from B2B site.
ENT-1688

Fixed pep8 quality violation

use testserver as HOST instead of edx.org

assert enterprise app is enabled

added logging

Print different values

Reload django url config

assert all quote operations to see how they work on jenkins

debug url resolved values

login user in setup

added log to debug test on jenkins

Using UrlResetMixin

Using regex instead of resolve

Fixed quality violation

Fixed pylint quality violations

Fixed target interpolation syntax

Added developer's comment
2019-10-15 18:28:19 +05:00

65 lines
2.5 KiB
Python

"""
Tests for logout for enterprise flow
"""
from __future__ import absolute_import
import ddt
import mock
from django.test.utils import override_settings
from django.urls import reverse
from openedx.core.djangolib.testing.utils import CacheIsolationTestCase, skip_unless_lms
from openedx.features.enterprise_support.api import enterprise_enabled
from openedx.features.enterprise_support.tests import (
FAKE_ENTERPRISE_CUSTOMER,
FEATURES_WITH_ENTERPRISE_ENABLED,
factories
)
from openedx.features.enterprise_support.tests.mixins.enterprise import EnterpriseServiceMockMixin
from student.tests.factories import UserFactory
from util.testing import UrlResetMixin
@ddt.ddt
@override_settings(FEATURES=FEATURES_WITH_ENTERPRISE_ENABLED)
@skip_unless_lms
class EnterpriseLogoutTests(EnterpriseServiceMockMixin, CacheIsolationTestCase, UrlResetMixin):
""" Tests for the enterprise logout functionality. """
def setUp(self):
super(EnterpriseLogoutTests, self).setUp()
self.user = UserFactory()
self.enterprise_customer = FAKE_ENTERPRISE_CUSTOMER
self.enterprise_learner = factories.EnterpriseCustomerUserFactory(user_id=self.user.id)
self.client.login(username=self.user.username, password='test')
patcher = mock.patch('openedx.features.enterprise_support.api.enterprise_customer_from_api')
self.mock_enterprise_customer_from_api = patcher.start()
self.mock_enterprise_customer_from_api.return_value = self.enterprise_customer
self.addCleanup(patcher.stop)
@ddt.data(
('https%3A%2F%2Ftest.edx.org%2Fcourses', False),
('/courses/course-v1:ARTS+D1+2018_T/course/', False),
('invalid-url', False),
('/enterprise/c5dad9a7-741c-4841-868f-850aca3ff848/course/Microsoft+DAT206x/enroll/', True),
('%2Fenterprise%2Fc5dad9a7-741c-4841-868f-850aca3ff848%2Fcourse%2FMicrosoft%2BDAT206x%2Fenroll%2F', True),
)
@ddt.unpack
def test_logout_enterprise_target(self, redirect_url, enterprise_target):
url = '{logout_path}?redirect_url={redirect_url}'.format(
logout_path=reverse('logout'),
redirect_url=redirect_url
)
self.assertTrue(enterprise_enabled())
response = self.client.get(url, HTTP_HOST='testserver')
expected = {
'enterprise_target': enterprise_target,
}
self.assertDictContainsSubset(expected, response.context_data)
if enterprise_target:
self.assertContains(response, 'We are signing you in.')