Skip to content

Commit

Permalink
Fix bugs, add bok-choy. (openedx#1928)
Browse files Browse the repository at this point in the history
* Fix review, add bok-choy.  openedx#1867

* Fix bug for login page message. openedx#1932
  • Loading branch information
ahara121 authored Jun 13, 2017
1 parent 12c60f4 commit f9eddf1
Show file tree
Hide file tree
Showing 8 changed files with 71 additions and 16 deletions.
3 changes: 2 additions & 1 deletion biz/djangoapps/ga_contract_operation/tests/test_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -808,8 +808,9 @@ def test_successful_with_failed_cert_deletion(self):

# delete_cert_pdf should be called 10 times even if previous process had been failed.
self.assertEqual(10, self.mock_delete_cert_pdf.call_count)
self.mock_util_log.error.assert_any_call(
self.mock_util_log.error.assert_called_once_with(
'Failed to delete certificate. user={}, course_id=spoc/course1/run'.format(registers[1].user_id)
)

self._assert_success_message([registers[0], registers[2], registers[3], registers[4]])
self._assert_failed_message([registers[1]])
7 changes: 3 additions & 4 deletions biz/djangoapps/ga_student/management/commands/mask_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ class Command(BaseCommand):
def handle(self, *args, **options):
log.info(u"Command mask_user started at {}.".format(datetime_utils.timezone_now()))

min_datetime, max_datetime = datetime_utils.min_and_max_of_date(days_after=-settings.INTERVAL_DAYS_TO_MASK_UNACTIVATED_USER)
min_datetime, _ = datetime_utils.min_and_max_of_date(days_after=-settings.INTERVAL_DAYS_TO_MASK_UNACTIVATED_USER)
mask_users = User.objects.filter(
is_active=False,
email__contains='@',
email__contains='@', # Do not mask users who have already masked by biz (#1908)
registration__masked=False,
registration__modified__isnull=False,
registration__modified__lt=min_datetime,
Expand All @@ -42,7 +42,6 @@ def handle(self, *args, **options):
mask_utils.mask_name(user)
mask_utils.mask_email(user)
mask_utils.disconnect_third_party_auth(user)
reg = Registration.objects.get(user=user)
reg.update_masked()
Registration.objects.get(user=user).update_masked()

log.info(u"Command mask_user finished at {}.".format(datetime_utils.timezone_now()))
2 changes: 1 addition & 1 deletion cms/envs/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
from lms.envs.common import (
USE_TZ, TECH_SUPPORT_EMAIL, PLATFORM_NAME, BUGS_EMAIL, DOC_STORE_CONFIG, DATA_DIR, ALL_LANGUAGES, WIKI_ENABLED,
update_module_store_settings, ASSET_IGNORE_REGEX, COPYRIGHT_YEAR,
PARENTAL_CONSENT_AGE_LIMIT, COMPREHENSIVE_THEME_DIR, INTERVAL_DAYS_TO_MASK_UNACTIVATED_USER,
PARENTAL_CONSENT_AGE_LIMIT, COMPREHENSIVE_THEME_DIR,
# The following PROFILE_IMAGE_* settings are included as they are
# indirectly accessed through the email opt-in API, which is
# technically accessible through the CMS via legacy URLs.
Expand Down
3 changes: 3 additions & 0 deletions cms/envs/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,3 +299,6 @@
'biz.djangoapps.ga_organization',
'biz.djangoapps.ga_contract',
)

##### Interval day to mask #####
INTERVAL_DAYS_TO_MASK_UNACTIVATED_USER = 1
1 change: 1 addition & 0 deletions common/djangoapps/student/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ def get_next_url_for_login_page(request, initial_mode=None):
redirect_to = request.GET.get('next', None)
if not redirect_to:
try:
# Users who already logged-in should always go to dashboard
if initial_mode == 'register' and not request.user.is_authenticated():
redirect_to = reverse('notice_unactivated')
else:
Expand Down
56 changes: 53 additions & 3 deletions common/test/acceptance/tests/lms/test_ga_register.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,14 @@
"""
End-to-end tests for the LMS registration flow.
"""

import os
import re
import requests
from unittest import skip

from bok_choy.web_app_test import WebAppTest
from lms.envs.ga_bok_choy import EMAIL_FILE_PATH
from ...fixtures.course import CourseFixture
from ...pages.lms import BASE_URL
from ...pages.lms.account_settings import AccountSettingsPage
from ...pages.lms.ga_dashboard import DashboardPage
from ...pages.lms.ga_header_footer import HeaderPage, FooterPage
from ...pages.lms.ga_register import ActivationPage
Expand Down Expand Up @@ -155,3 +153,55 @@ def test_register_and_activate(self):
self.assertFalse(dashboard_page.is_exists_notification())
self.assertIn(self.GLOBAL_COURSE_DISPLAY, dashboard_page.current_courses_text)
self.assertFalse(dashboard_page.is_enable_unenroll(self.GLOBAL_COURSE_DISPLAY))

def test_third_party_register(self):
"""
Test that we can register using third party credentials, and that the
third party account gets linked to the edX account.
"""
# Navigate to the register page and try to authenticate using the "Dummy" provider
self.register_page.visit()
self.register_page.click_third_party_dummy_provider()

# The user will be redirected somewhere and then back to the register page:
msg_text = self.register_page.wait_for_auth_status_message()
self.assertEqual(self.register_page.current_form, "register")
self.assertIn("You've successfully signed into Dummy", msg_text)
self.assertIn("We just need a little more information", msg_text)

# Now the form should be pre-filled with the data from the Dummy provider:
self.assertEqual(self.register_page.email_value, "adama@fleet.colonies.gov")
self.assertEqual(self.register_page.full_name_value, "William Adama")
self.assertEqual("", self.register_page.username_value)

# Set username, country, accept the terms, and submit the form:
self.register_page.register(username="Galactica1", country="US", terms_of_service=True)
self.register_page.wait_for_ajax()

# Check activation email.
activation_message = self.email_client.get_latest_message()
self.assertEqual('adama@fleet.colonies.gov', activation_message['to_addresses'])
self.assertEqual("Information of edX Member Registration", activation_message['subject'])
self.assertIn("Information of gacco Member Registration", activation_message['body'])

# Visit activation page.
activation_key = self._get_activation_key_from_message(activation_message['body'])
activation_page = ActivationPage(self.browser, activation_key)
activation_page.visit()
self.assertIn("Thanks for activating your account.", activation_page.complete_message)

activation_page.click_login_button()
login_page = CombinedLoginAndRegisterPage(self.browser, start_page="login")
login_page.wait_for_page()
login_page.click_third_party_dummy_provider()

dashboard_page = DashboardPage(self.browser)
dashboard_page.wait_for_page()

# Now unlink the account (To test the account settings view and also to prevent cross-test side effects)
account_settings = AccountSettingsPage(self.browser).visit()
field_id = "auth-oa2-dummy"
account_settings.wait_for_field(field_id)
self.assertEqual("Unlink", account_settings.link_title_for_link_field(field_id))
account_settings.click_on_link_in_link_field(field_id)
account_settings.wait_for_message(field_id, "Successfully unlinked")
8 changes: 6 additions & 2 deletions common/test/acceptance/tests/lms/test_lms.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ def test_toggle_to_login_form(self):
self.register_page.visit().toggle_form()
self.assertEqual(self.register_page.current_form, "login")

@skip("This won't work with mod #1867")
@skip("gacco use test_ga_register")
def test_third_party_register(self):
"""
Test that we can register using third party credentials, and that the
Expand All @@ -323,8 +323,12 @@ def test_third_party_register(self):
# Set username, country, accept the terms, and submit the form:
self.register_page.register(username="Galactica1", country="US", terms_of_service=True)

# Expect that we reach the dashboard and we're auto-enrolled in the course
course_names = self.dashboard_page.wait_for_page().available_courses
self.assertIn(self.course_info["display_name"], course_names)

# Now logout and check that we can log back in instantly (because the account is linked):
# LogoutPage(self.browser).visit()
LogoutPage(self.browser).visit()

login_page = CombinedLoginAndRegisterPage(self.browser, start_page="login")
login_page.visit()
Expand Down
7 changes: 2 additions & 5 deletions ga/conf/locale/ja_JP/LC_MESSAGES/gaccojs.po
Original file line number Diff line number Diff line change
Expand Up @@ -355,8 +355,9 @@ msgid "Including tax"
msgstr "税込"

#: lms/templates/verify_student/make_payment_step.underscore
#: lms/templates/student_account/login.underscore
msgid "You're almost there!"
msgstr "会員登録が完了しておりません。"
msgstr "会員登録はまだ完了しておりません。"

#: lms/templates/verify_student/make_payment_step.underscore
msgid ""
Expand Down Expand Up @@ -490,10 +491,6 @@ msgstr "分:"
msgid "Please enter the date on and after 1900."
msgstr "1900年以降の日付を入力して下さい。"

#: lms/templates/student_account/login.underscore
msgid "You're almost there!"
msgstr "会員登録はまだ完了しておりません。"

#: lms/templates/student_account/login.underscore
msgid "Before you enroll in a course, you need to activate your account. We've sent an e-mail to your registered e-mail address with instructions for activating your account."
msgstr "会員登録時に入力されたメールアドレス宛に会員登録のご案内メールを送信しました。メール内のURLをクリックし、会員登録を完了してください。"

0 comments on commit f9eddf1

Please sign in to comment.