Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
5d087bfe
Commit
5d087bfe
authored
Oct 04, 2017
by
Bill Filler
Committed by
GitHub
Oct 04, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #16163 from edx/bfiller/fix-dsc-banner
Display banner if user declines data sharing consent
parents
8a5782eb
52685889
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
0 deletions
+19
-0
openedx/features/enterprise_support/api.py
+7
-0
openedx/features/enterprise_support/tests/test_api.py
+12
-0
No files found.
openedx/features/enterprise_support/api.py
View file @
5d087bfe
...
...
@@ -364,6 +364,13 @@ def enterprise_customer_for_request(request):
settings
.
ENTERPRISE_CUSTOMER_COOKIE_NAME
)
if
not
enterprise_customer_uuid
and
request
.
user
.
is_authenticated
():
# If there's no way to get an Enterprise UUID for the request, check to see
# if there's already an Enterprise attached to the requesting user on the backend.
learner_data
=
get_enterprise_learner_data
(
request
.
site
,
request
.
user
)
if
learner_data
:
enterprise_customer_uuid
=
learner_data
[
0
][
'enterprise_customer'
][
'uuid'
]
if
enterprise_customer_uuid
:
# If we were able to obtain an EnterpriseCustomer UUID, go ahead
# and use it to attempt to retrieve EnterpriseCustomer details
...
...
openedx/features/enterprise_support/tests/test_api.py
View file @
5d087bfe
...
...
@@ -171,6 +171,7 @@ class TestEnterpriseApi(EnterpriseServiceMockMixin, CacheIsolationTestCase):
self
.
assertFalse
(
consent_needed_for_course
(
request
,
user
,
'fake-course'
))
@httpretty.activate
@mock.patch
(
'openedx.features.enterprise_support.api.get_enterprise_learner_data'
)
@mock.patch
(
'openedx.features.enterprise_support.api.EnterpriseCustomer'
)
@mock.patch
(
'openedx.features.enterprise_support.api.get_partial_pipeline'
)
@mock.patch
(
'openedx.features.enterprise_support.api.Registry'
)
...
...
@@ -179,6 +180,7 @@ class TestEnterpriseApi(EnterpriseServiceMockMixin, CacheIsolationTestCase):
mock_registry
,
mock_partial
,
mock_enterprise_customer_model
,
mock_get_enterprise_learner_data
,
):
def
mock_get_enterprise_customer
(
**
kwargs
):
uuid
=
kwargs
.
get
(
'enterprise_customer_identity_provider__provider_id'
)
...
...
@@ -227,6 +229,16 @@ class TestEnterpriseApi(EnterpriseServiceMockMixin, CacheIsolationTestCase):
)
self
.
assertEqual
(
enterprise_customer
,
{
'real'
:
'enterprisecustomer'
})
# Verify that we can still get enterprise customer from enterprise
# learner API even if we are unable to get it from preferred sources,
# e.g. url query parameters, third-party auth pipeline, enterprise
# cookie.
mock_get_enterprise_learner_data
.
return_value
=
[{
'enterprise_customer'
:
{
'uuid'
:
'real-ent-uuid'
}}]
enterprise_customer
=
enterprise_customer_for_request
(
mock
.
MagicMock
(
GET
=
{},
COOKIES
=
{},
user
=
self
.
user
,
site
=
1
)
)
self
.
assertEqual
(
enterprise_customer
,
{
'real'
:
'enterprisecustomer'
})
def
check_data_sharing_consent
(
self
,
consent_required
=
False
,
consent_url
=
None
):
"""
Used to test the data_sharing_consent_required view decorator.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment