Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
edx-platform-release
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Hsin-Yu Chien
edx-platform-release
Commits
e81fcbf5
Unverified
Commit
e81fcbf5
authored
3 years ago
by
Michael Terry
Committed by
GitHub
3 years ago
Browse files
Options
Downloads
Plain Diff
Merge pull request #27879 from open-craft/mtyaka/FAL-1938-support-learning-mfe-on-subpath
Support Learning MFE hosted on subpath.
parents
6ba12c71
fdf600a5
No related branches found
Branches containing commit
Tags
release-2021-07-16-15.03
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
openedx/features/course_experience/tests/test_url_helpers.py
+30
-0
30 additions, 0 deletions
openedx/features/course_experience/tests/test_url_helpers.py
openedx/features/course_experience/url_helpers.py
+7
-5
7 additions, 5 deletions
openedx/features/course_experience/url_helpers.py
with
37 additions
and
5 deletions
openedx/features/course_experience/tests/test_url_helpers.py
+
30
−
0
View file @
e81fcbf5
...
...
@@ -4,6 +4,9 @@ Test some of the functions in url_helpers
from
unittest
import
mock
import
ddt
from
django.test
import
TestCase
from
django.test.client
import
RequestFactory
from
django.test.utils
import
override_settings
from
xmodule.modulestore
import
ModuleStoreEnum
from
xmodule.modulestore.tests.django_utils
import
SharedModuleStoreTestCase
...
...
@@ -20,6 +23,33 @@ def _patch_courseware_mfe_is_active(ret_val):
)
@ddt.ddt
class
IsLearningMfeTests
(
TestCase
):
"""
Test is_request_from_learning_mfe.
"""
def
setUp
(
self
):
super
().
setUp
()
self
.
request_factory
=
RequestFactory
()
@ddt.data
(
(
''
,
''
,
False
,),
(
'
https://mfe-url/
'
,
'
https://platform-url/course
'
,
False
,),
(
'
https://mfe-url/
'
,
'
https://mfe-url/course
'
,
True
,),
(
'
https://mfe-url/
'
,
'
https://mfe-url/
'
,
True
,),
(
'
https://mfe-url/subpath/
'
,
'
https://platform-url/course
'
,
False
,),
(
'
https://mfe-url/subpath/
'
,
'
https://mfe-url/course
'
,
True
,),
(
'
https://mfe-url/subpath/
'
,
'
https://mfe-url/
'
,
True
,),
)
@ddt.unpack
def
test_is_request_from_learning_mfe
(
self
,
mfe_url
,
referrer_url
,
is_mfe
):
with
override_settings
(
LEARNING_MICROFRONTEND_URL
=
mfe_url
):
request
=
self
.
request_factory
.
get
(
'
/course
'
)
request
.
META
[
'
HTTP_REFERER
'
]
=
referrer_url
assert
url_helpers
.
is_request_from_learning_mfe
(
request
)
==
is_mfe
@ddt.ddt
class
GetCoursewareUrlTests
(
SharedModuleStoreTestCase
):
"""
...
...
This diff is collapsed.
Click to expand it.
openedx/features/course_experience/url_helpers.py
+
7
−
5
View file @
e81fcbf5
...
...
@@ -13,7 +13,7 @@ from django.contrib.auth import get_user_model
from
django.http
import
HttpRequest
from
django.urls
import
reverse
from
opaque_keys.edx.keys
import
CourseKey
,
UsageKey
from
six.moves.urllib.parse
import
urlencode
from
six.moves.urllib.parse
import
urlencode
,
urlparse
from
lms.djangoapps.courseware.toggles
import
courseware_mfe_is_active
from
xmodule.modulestore.django
import
modulestore
...
...
@@ -213,7 +213,9 @@ def is_request_from_learning_mfe(request: HttpRequest):
"""
Returns whether the given request was made by the frontend-app-learning MFE.
"""
return
(
settings
.
LEARNING_MICROFRONTEND_URL
and
request
.
META
.
get
(
'
HTTP_REFERER
'
,
''
).
startswith
(
settings
.
LEARNING_MICROFRONTEND_URL
)
)
if
not
settings
.
LEARNING_MICROFRONTEND_URL
:
return
False
url
=
urlparse
(
settings
.
LEARNING_MICROFRONTEND_URL
)
mfe_url_base
=
f
'
{
url
.
scheme
}
://
{
url
.
netloc
}
'
return
request
.
META
.
get
(
'
HTTP_REFERER
'
,
''
).
startswith
(
mfe_url_base
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment