Merge pull request #20351 from edx/youngstrom/INCR-176

INCR-176
This commit is contained in:
Michael Youngstrom
2019-04-26 17:31:26 -04:00
committed by GitHub
13 changed files with 55 additions and 46 deletions

View File

@@ -1,8 +1,7 @@
"""Tests for remove_headers and force_header decorator. """
from django.http import HttpResponse, HttpRequest
from django.http import HttpRequest, HttpResponse
from django.test import TestCase
from openedx.core.djangoapps.header_control.decorators import remove_headers, force_header
from openedx.core.djangoapps.header_control.decorators import force_header, remove_headers
def fake_view(_request):

View File

@@ -1,8 +1,7 @@
"""Tests for header_control middleware."""
from django.http import HttpResponse, HttpRequest
from django.http import HttpRequest, HttpResponse
from django.test import TestCase
from openedx.core.djangoapps.header_control import remove_headers_from_response, force_header_for_response
from openedx.core.djangoapps.header_control import force_header_for_response, remove_headers_from_response
from openedx.core.djangoapps.header_control.middleware import HeaderControlMiddleware

View File

@@ -1,24 +1,25 @@
"""
APIs providing support for enterprise functionality.
"""
from __future__ import absolute_import
import logging
from functools import wraps
from django.conf import settings
from django.contrib.auth.models import User
from django.core.cache import cache
from django.urls import reverse
from django.shortcuts import redirect
from django.template.loader import render_to_string
from django.urls import reverse
from django.utils.http import urlencode
from django.utils.translation import ugettext as _
from edx_django_utils.cache import TieredCache
from edx_rest_api_client.client import EdxRestApiClient
from slumber.exceptions import HttpClientError, HttpNotFoundError, HttpServerError
from openedx.core.djangoapps.oauth_dispatch.jwt import create_jwt_for_user
from openedx.core.djangoapps.site_configuration import helpers as configuration_helpers
from openedx.features.enterprise_support.utils import get_cache_key, get_data_consent_share_cache_key
from slumber.exceptions import HttpClientError, HttpNotFoundError, HttpServerError
from third_party_auth.pipeline import get as get_partial_pipeline
from third_party_auth.provider import Registry

View File

@@ -1,6 +1,8 @@
"""
Configuration for enterprise_support
"""
from __future__ import absolute_import
from django.apps import AppConfig

View File

@@ -4,8 +4,9 @@ Middleware for the Enterprise feature.
The Enterprise feature must be turned on for this middleware to have any effect.
"""
from django.core.exceptions import MiddlewareNotUsed
from __future__ import absolute_import
from django.core.exceptions import MiddlewareNotUsed
from openedx.features.enterprise_support import api

View File

@@ -2,13 +2,13 @@
This module contains signals related to enterprise.
"""
from django.dispatch import receiver
from django.db.models.signals import post_save
from __future__ import absolute_import
from django.contrib.auth.models import User
from enterprise.models import EnterpriseCustomerUser, EnterpriseCourseEnrollment
from django.db.models.signals import post_save
from django.dispatch import receiver
from email_marketing.tasks import update_user
from enterprise.models import EnterpriseCourseEnrollment, EnterpriseCustomerUser
from openedx.features.enterprise_support.utils import clear_data_consent_share_cache

View File

@@ -2,6 +2,8 @@
Things commonly needed in Enterprise tests.
"""
from __future__ import absolute_import
from django.conf import settings
FEATURES_WITH_ENTERPRISE_ENABLED = settings.FEATURES.copy()

View File

@@ -6,15 +6,10 @@ from __future__ import absolute_import, unicode_literals
from uuid import UUID
import factory
from enterprise.models import EnterpriseCustomer, EnterpriseCustomerUser
from faker import Factory as FakerFactory
from openedx.core.djangoapps.site_configuration.tests.factories import SiteFactory
from enterprise.models import (
EnterpriseCustomer,
EnterpriseCustomerUser,
)
FAKER = FakerFactory.create()

View File

@@ -1,15 +1,17 @@
"""
Mixins for the EnterpriseApiClient.
"""
from __future__ import absolute_import
import json
import mock
import httpretty
from django.conf import settings
from django.core.cache import cache
from django.urls import reverse
from django.test import SimpleTestCase
from django.urls import reverse
from openedx.features.enterprise_support.tests import FAKE_ENTERPRISE_CUSTOMER

View File

@@ -2,36 +2,38 @@
Test the enterprise support APIs.
"""
from __future__ import absolute_import
import mock
import ddt
import httpretty
import mock
from consent.models import DataSharingConsent
from django.conf import settings
from django.contrib.auth.models import User
from django.core.cache import cache
from django.urls import reverse
from django.http import HttpResponseRedirect
from django.test.utils import override_settings
from consent.models import DataSharingConsent
from django.urls import reverse
from openedx.core.djangolib.testing.utils import CacheIsolationTestCase, skip_unless_lms
from openedx.features.enterprise_support.api import (
ConsentApiClient,
ConsentApiServiceClient,
consent_needed_for_course,
get_consent_required_courses,
data_sharing_consent_required,
EnterpriseApiClient,
EnterpriseApiServiceClient,
consent_needed_for_course,
data_sharing_consent_required,
enterprise_customer_for_request,
enterprise_enabled,
get_consent_required_courses,
get_dashboard_consent_notification,
get_enterprise_consent_url,
insert_enterprise_pipeline_elements,
enterprise_enabled,
insert_enterprise_pipeline_elements
)
from openedx.features.enterprise_support.tests import FEATURES_WITH_ENTERPRISE_ENABLED
from openedx.features.enterprise_support.tests.factories import EnterpriseCustomerUserFactory
from openedx.features.enterprise_support.tests.mixins.enterprise import EnterpriseServiceMockMixin
from openedx.features.enterprise_support.utils import get_cache_key, clear_data_consent_share_cache
from openedx.features.enterprise_support.utils import clear_data_consent_share_cache, get_cache_key
from student.tests.factories import UserFactory

View File

@@ -2,15 +2,17 @@
Tests for Enterprise middleware.
"""
from __future__ import absolute_import
import mock
from django.urls import reverse
from django.test import TestCase
from django.test.utils import override_settings
from django.urls import reverse
from openedx.core.djangolib.testing.utils import skip_unless_lms
from openedx.features.enterprise_support.tests import (
FAKE_ENTERPRISE_CUSTOMER, FEATURES_WITH_ENTERPRISE_ENABLED,
FAKE_ENTERPRISE_CUSTOMER,
FEATURES_WITH_ENTERPRISE_ENABLED,
factories
)
from student.tests.factories import UserFactory

View File

@@ -1,11 +1,14 @@
"""Tests of email marketing signal handlers."""
from __future__ import absolute_import
import logging
import ddt
from django.test import TestCase
from mock import patch
from student.tests.factories import UserFactory
import ddt
from django.test import TestCase
from openedx.features.enterprise_support.tests.factories import EnterpriseCustomerFactory, EnterpriseCustomerUserFactory
from student.tests.factories import UserFactory
log = logging.getLogger(__name__)

View File

@@ -1,19 +1,20 @@
from __future__ import unicode_literals
"""
Utility methods for Enterprise
"""
from __future__ import absolute_import, unicode_literals
import hashlib
import json
import six
from django.conf import settings
from django.utils.translation import ugettext as _
import third_party_auth
from django.conf import settings
from django.utils.translation import ugettext as _
from edx_django_utils.cache import TieredCache
from third_party_auth import pipeline
from enterprise.models import EnterpriseCustomerUser
from openedx.core.djangoapps.user_authn.cookies import standard_cookie_settings
from openedx.core.djangoapps.site_configuration import helpers as configuration_helpers
from openedx.core.djangoapps.user_authn.cookies import standard_cookie_settings
from openedx.core.djangolib.markup import HTML, Text
@@ -176,7 +177,7 @@ def update_third_party_auth_context_for_enterprise(request, context, enterprise_
context['data']['third_party_auth']['providers'] = []
context['data']['third_party_auth']['secondaryProviders'] = []
running_pipeline = pipeline.get(request)
running_pipeline = third_party_auth.pipeline.get(request)
if running_pipeline is not None:
current_provider = third_party_auth.provider.Registry.get_from_pipeline(running_pipeline)
if current_provider is not None and current_provider.skip_registration_form and enterprise_customer: