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
f6ec9360
Commit
f6ec9360
authored
Aug 27, 2015
by
Zia Fazal
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use microsite platform_name and email_from_address if available
fixed broken test fixes for broken tests
parent
d8f484ac
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
9 deletions
+24
-9
common/djangoapps/student/tests/test_microsite.py
+2
-0
common/djangoapps/student/tests/test_reset_password.py
+15
-3
common/djangoapps/student/views.py
+7
-6
No files found.
common/djangoapps/student/tests/test_microsite.py
View file @
f6ec9360
...
...
@@ -12,6 +12,8 @@ FAKE_MICROSITE = {
"SITE_NAME"
:
"openedx.localhost"
,
"university"
:
"fakeuniversity"
,
"course_org_filter"
:
"fakeorg"
,
"platform_name"
:
"Fake University"
,
"email_from_address"
:
"no-reply@fakeuniversity.com"
,
"REGISTRATION_EXTRA_FIELDS"
:
{
"address1"
:
"required"
,
"city"
:
"required"
,
...
...
common/djangoapps/student/tests/test_reset_password.py
View file @
f6ec9360
...
...
@@ -12,6 +12,7 @@ from django.test.client import RequestFactory
from
django.contrib.auth.models
import
User
from
django.contrib.auth.hashers
import
UNUSABLE_PASSWORD
from
django.contrib.auth.tokens
import
default_token_generator
from
django.utils.http
import
int_to_base36
from
mock
import
Mock
,
patch
...
...
@@ -22,7 +23,7 @@ from student.tests.factories import UserFactory
from
student.tests.test_email
import
mock_render_to_string
from
util.testing
import
EventTestMixin
from
test_microsite
import
fake_site_nam
e
from
.test_microsite
import
fake_microsite_get_valu
e
@ddt.ddt
...
...
@@ -185,7 +186,7 @@ class ResetPasswordTests(EventTestMixin, TestCase):
)
@unittest.skipUnless
(
settings
.
ROOT_URLCONF
==
'lms.urls'
,
"Test only valid in LMS"
)
@patch
(
"microsite_configuration.microsite.get_value"
,
fake_
site_nam
e
)
@patch
(
"microsite_configuration.microsite.get_value"
,
fake_
microsite_get_valu
e
)
@patch
(
'django.core.mail.send_mail'
)
def
test_reset_password_email_microsite
(
self
,
send_email
):
"""
...
...
@@ -198,7 +199,7 @@ class ResetPasswordTests(EventTestMixin, TestCase):
req
.
get_host
=
Mock
(
return_value
=
None
)
req
.
user
=
self
.
user
password_reset
(
req
)
_
,
msg
,
_
,
_
=
send_email
.
call_args
[
0
]
_
,
msg
,
from_addr
,
_
=
send_email
.
call_args
[
0
]
reset_msg
=
"you requested a password reset for your user account at openedx.localhost"
...
...
@@ -207,6 +208,7 @@ class ResetPasswordTests(EventTestMixin, TestCase):
self
.
assert_event_emitted
(
SETTING_CHANGE_INITIATED
,
user_id
=
self
.
user
.
id
,
setting
=
u'password'
,
old
=
None
,
new
=
None
)
self
.
assertEqual
(
from_addr
,
"no-reply@fakeuniversity.com"
)
@patch
(
'student.views.password_reset_confirm'
)
def
test_reset_password_bad_token
(
self
,
reset_confirm
):
...
...
@@ -233,6 +235,16 @@ class ResetPasswordTests(EventTestMixin, TestCase):
self
.
assertTrue
(
self
.
user
.
is_active
)
@patch
(
'student.views.password_reset_confirm'
)
@patch
(
"microsite_configuration.microsite.get_value"
,
fake_microsite_get_value
)
def
test_reset_password_good_token_microsite
(
self
,
reset_confirm
):
"""Tests password reset confirmation page for micro site"""
good_reset_req
=
self
.
request_factory
.
get
(
'/password_reset_confirm/{0}-{1}/'
.
format
(
self
.
uidb36
,
self
.
token
))
password_reset_confirm_wrapper
(
good_reset_req
,
self
.
uidb36
,
self
.
token
)
confirm_kwargs
=
reset_confirm
.
call_args
[
1
]
self
.
assertEquals
(
confirm_kwargs
[
'extra_context'
][
'platform_name'
],
'Fake University'
)
@patch
(
'student.views.password_reset_confirm'
)
def
test_reset_password_with_reused_password
(
self
,
reset_confirm
):
"""Tests good token and uidb36 in password reset"""
...
...
common/djangoapps/student/views.py
View file @
f6ec9360
...
...
@@ -1036,6 +1036,7 @@ def login_user(request, error=""): # pylint: disable=too-many-statements,unused
third_party_auth_successful
=
False
trumped_by_first_party_auth
=
bool
(
request
.
POST
.
get
(
'email'
))
or
bool
(
request
.
POST
.
get
(
'password'
))
user
=
None
platform_name
=
microsite
.
get_value
(
"platform_name"
,
settings
.
PLATFORM_NAME
)
if
third_party_auth_requested
and
not
trumped_by_first_party_auth
:
# The user has already authenticated via third-party auth and has not
...
...
@@ -1057,17 +1058,17 @@ def login_user(request, error=""): # pylint: disable=too-many-statements,unused
username
=
username
,
backend_name
=
backend_name
))
return
HttpResponse
(
_
(
"You've successfully logged into your {provider_name} account, but this account isn't linked with an {platform_name} account yet."
)
.
format
(
platform_name
=
settings
.
PLATFORM_NAME
,
provider_name
=
requested_provider
.
name
platform_name
=
platform_name
,
provider_name
=
requested_provider
.
name
)
+
"<br/><br/>"
+
_
(
"Use your {platform_name} username and password to log into {platform_name} below, "
"and then link your {platform_name} account with {provider_name} from your dashboard."
)
.
format
(
platform_name
=
settings
.
PLATFORM_NAME
,
provider_name
=
requested_provider
.
name
platform_name
=
platform_name
,
provider_name
=
requested_provider
.
name
)
+
"<br/><br/>"
+
_
(
"If you don't have an {platform_name} account yet, "
"click <strong>Register</strong> at the top of the page."
)
.
format
(
platform_name
=
settings
.
PLATFORM_NAME
),
platform_name
=
platform_name
),
content_type
=
"text/plain"
,
status
=
403
)
...
...
@@ -1907,7 +1908,7 @@ def password_reset(request):
form
=
PasswordResetFormNoActive
(
request
.
POST
)
if
form
.
is_valid
():
form
.
save
(
use_https
=
request
.
is_secure
(),
from_email
=
settings
.
DEFAULT_FROM_EMAIL
,
from_email
=
microsite
.
get_value
(
'email_from_address'
,
settings
.
DEFAULT_FROM_EMAIL
)
,
request
=
request
,
domain_override
=
request
.
get_host
())
# When password change is complete, a "edx.user.settings.changed" event will be emitted.
...
...
@@ -1993,12 +1994,12 @@ def password_reset_confirm_wrapper(
'form'
:
None
,
'title'
:
_
(
'Password reset unsuccessful'
),
'err_msg'
:
err_msg
,
'platform_name'
:
settings
.
PLATFORM_NAME
,
'platform_name'
:
microsite
.
get_value
(
'platform_name'
,
settings
.
PLATFORM_NAME
)
,
}
return
TemplateResponse
(
request
,
'registration/password_reset_confirm.html'
,
context
)
else
:
# we also want to pass settings.PLATFORM_NAME in as extra_context
extra_context
=
{
"platform_name"
:
settings
.
PLATFORM_NAME
}
extra_context
=
{
"platform_name"
:
microsite
.
get_value
(
'platform_name'
,
settings
.
PLATFORM_NAME
)
}
if
request
.
method
==
'POST'
:
# remember what the old password hash is before we call down
...
...
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