Skip to content

Commit

Permalink
Merge branch 'MDL-69371-master-4' of git://github.com/bmbrands/moodle
Browse files Browse the repository at this point in the history
  • Loading branch information
abgreeve committed Oct 21, 2021
2 parents 453db3d + cf630f0 commit ca229df
Show file tree
Hide file tree
Showing 31 changed files with 805 additions and 515 deletions.
22 changes: 11 additions & 11 deletions admin/tool/policy/tests/behat/consent.feature
Expand Up @@ -11,7 +11,7 @@ Feature: User must accept policy managed by this plugin when logging in and sign
| sitepolicyhandler | tool_policy |
And I am on site homepage
And I follow "Log in"
When I press "Create new account"
When I click on "Create new account" "link"
Then I should not see "I understand and agree"
And I set the following fields to these values:
| Username | user1 |
Expand Down Expand Up @@ -45,7 +45,7 @@ Feature: User must accept policy managed by this plugin when logging in and sign
| P1 | This privacy policy | | full text2 | short text2 | draft |
And I am on site homepage
And I follow "Log in"
When I press "Create new account"
When I click on "Create new account" "link"
Then I should not see "I understand and agree"
And I set the following fields to these values:
| Username | user1 |
Expand Down Expand Up @@ -80,7 +80,7 @@ Feature: User must accept policy managed by this plugin when logging in and sign
| P1 | This site policy | | full text3 | short text3 | draft |
And I am on site homepage
And I follow "Log in"
When I press "Create new account"
When I click on "Create new account" "link"
Then I should see "This site policy" in the "region-main" "region"
And I should see "short text2"
And I should see "full text2"
Expand Down Expand Up @@ -128,7 +128,7 @@ Feature: User must accept policy managed by this plugin when logging in and sign
| This guests policy | 0 | | full text4 | short text4 | active | guest |
And I am on site homepage
And I follow "Log in"
When I press "Create new account"
When I click on "Create new account" "link"
Then I should see "This site policy" in the "region-main" "region"
And I should see "short text2"
And I should see "full text2"
Expand Down Expand Up @@ -188,7 +188,7 @@ Feature: User must accept policy managed by this plugin when logging in and sign
| This site policy | | full text2 | short text2 | active |
And I am on site homepage
And I follow "Log in"
When I press "Create new account"
When I click on "Create new account" "link"
Then I should see "Age and location verification"
And I set the field "What is your age?" to "16"
And I set the field "In which country do you live?" to "DZ"
Expand Down Expand Up @@ -239,7 +239,7 @@ Feature: User must accept policy managed by this plugin when logging in and sign
| This privacy policy | 1 | | full text3 | short text3 | active | loggedin |
And I am on site homepage
And I follow "Log in"
And I press "Create new account"
And I click on "Create new account" "link"
And I should see "This site policy"
And I press "Next"
And I should see "This privacy policy"
Expand Down Expand Up @@ -494,7 +494,7 @@ Feature: User must accept policy managed by this plugin when logging in and sign
| This guests policy | 0 | | full text4 | short text4 | active | guest |
And I am on site homepage
And I follow "Log in"
When I press "Create new account"
When I click on "Create new account" "link"
Then I should see "This site policy" in the "region-main" "region"
And I should see "short text2"
And I should see "full text2"
Expand Down Expand Up @@ -526,7 +526,7 @@ Feature: User must accept policy managed by this plugin when logging in and sign
Then I should see "Confirm your account"
And I should see "An email should have been sent to your address at user1@address.invalid"
And I follow "Log in"
When I press "Create new account"
When I click on "Create new account" "link"
# Confirm that the user can view and accept policies when attempting to create another account.
Then I should see "This site policy" in the "region-main" "region"
And I should see "short text2"
Expand Down Expand Up @@ -628,7 +628,7 @@ Feature: User must accept policy managed by this plugin when logging in and sign
And I press "Log in as a guest"
# Now sign up
And I follow "Log in"
When I press "Create new account"
When I click on "Create new account" "link"
Then I should see "This site policy"
And I should see "short text2"
And I should see "full text2"
Expand Down Expand Up @@ -677,7 +677,7 @@ Feature: User must accept policy managed by this plugin when logging in and sign
| Terms of Service | We teach, you learn | Here goes content. | 1 |
And I am on site homepage
And I follow "Log in"
When I press "Create new account"
When I click on "Create new account" "link"
# The first policy with the agreement style "on its own page" must be accepted first.
Then I should see "Digital maturity declaration" in the "region-main" "region"
And I should see "You declare be old enough"
Expand Down Expand Up @@ -841,7 +841,7 @@ Feature: User must accept policy managed by this plugin when logging in and sign
| Terms of Service | We teach, you learn | Here goes content. | 1 | guest |
And I am on site homepage
And I follow "Log in"
When I press "Create new account"
When I click on "Create new account" "link"
# All the policies to be displayed one by one with a button to accept each of them prior seeing the next.
Then I should see "Digital maturity declaration" in the "region-main" "region"
And I should see "You declare be old enough"
Expand Down
2 changes: 1 addition & 1 deletion admin/tool/policy/tests/behat/optional.feature
Expand Up @@ -65,7 +65,7 @@ Feature: Optional policies
| OwnPageOptional1 | full text5 | short text5 | 1 | 1 |
And I am on site homepage
And I follow "Log in"
And I press "Create new account"
And I click on "Create new account" "link"
# Compulsory policies displayed on own page are shown first and must be agreed.
And I should see "OwnPageCompulsory1" in the "region-main" "region"
And I should see "short text4" in the "region-main" "region"
Expand Down
16 changes: 13 additions & 3 deletions auth/classes/output/login.php
Expand Up @@ -70,6 +70,8 @@ class login implements renderable, templatable {
public $signupurl;
/** @var string The user name to pre-fill the form with. */
public $username;
/** @var string The language selector menu. */
public $languagemenu;
/** @var string The csrf token to limit login to requests that come from the login form. */
public $logintoken;
/** @var string Maintenance message, if Maintenance is enabled. */
Expand All @@ -82,10 +84,13 @@ class login implements renderable, templatable {
* @param string $username The username to display.
*/
public function __construct(array $authsequence, $username = '') {
global $CFG;
global $CFG, $OUTPUT, $PAGE;

$this->username = $username;

$languagedata = new \core\output\language_menu($PAGE);

$this->languagemenu = $languagedata->export_for_action_menu($OUTPUT);
$this->canloginasguest = $CFG->guestloginbutton and !isguestuser();
$this->canloginbyemail = !empty($CFG->authloginviaemail);
$this->cansignup = $CFG->registerauth == 'email' || !empty($CFG->registerauth);
Expand All @@ -111,8 +116,12 @@ public function __construct(array $authsequence, $username = '') {
$this->instructions = get_string('loginsteps', 'core', 'signup.php');
}

if ($CFG->maintenance_enabled == true && !empty($CFG->maintenance_message)) {
$this->maintenance = $CFG->maintenance_message;
if ($CFG->maintenance_enabled == true) {
if (!empty($CFG->maintenance_message)) {
$this->maintenance = $CFG->maintenance_message;
} else {
$this->maintenance = get_string('sitemaintenance', 'admin');
}
}

// Identity providers.
Expand Down Expand Up @@ -152,6 +161,7 @@ public function export_for_template(renderer_base $output) {
$data->username = $this->username;
$data->logintoken = $this->logintoken;
$data->maintenance = format_text($this->maintenance, FORMAT_MOODLE);
$data->languagemenu = $this->languagemenu;

return $data;
}
Expand Down
6 changes: 3 additions & 3 deletions auth/email/tests/behat/signup.feature
Expand Up @@ -10,7 +10,7 @@ Feature: User must accept policy when logging in and signing up
| passwordpolicy | 0 |
And I am on site homepage
And I follow "Log in"
When I press "Create new account"
When I click on "Create new account" "link"
Then I should not see "I understand and agree"
And I set the following fields to these values:
| Username | user1 |
Expand Down Expand Up @@ -40,7 +40,7 @@ Feature: User must accept policy when logging in and signing up
| sitepolicy | https://moodle.org |
And I am on site homepage
And I follow "Log in"
When I press "Create new account"
When I click on "Create new account" "link"
Then the field "I understand and agree" matches value "0"
And I set the following fields to these values:
| Username | user1 |
Expand Down Expand Up @@ -74,7 +74,7 @@ Feature: User must accept policy when logging in and signing up
| s1 | John | Doe | s1@example.com |
And I am on site homepage
And I follow "Log in"
When I press "Create new account"
When I click on "Create new account" "link"
And I set the following fields to these values:
| Username | s2 |
| Password | test |
Expand Down
104 changes: 104 additions & 0 deletions auth/tests/behat/loginform.feature
@@ -0,0 +1,104 @@
@auth @core_auth @javascript
Feature: Test if the login form provides the correct feedback
In order to check if the login form provides correct feedback
As a user
I need to go on login page and see feedback on incorrect username or password.

Background:
Given the following "users" exist:
| username |
| teacher1 |

Scenario: Check invalid login message
Given I follow "Log in"
And I set the field "Username" to "teacher1"
And I set the field "Password" to "incorrect"
When I press "Log in"
Then I should see "Invalid login, please try again"

Scenario: Test login language selector
Given I log in as "admin"
And I navigate to "Language > Language packs" in site administration
And I set the field "Available language packs" to "nl,es"
And I press "Install selected language pack(s)"
And I trigger cron
And I am on homepage
And I log out
And I follow "Log in"
And I open the action menu in "region-main" "region"
# The line below contains the unicode character U+200E before and after the brackets, please be very careful editing this line.
And I choose "Nederlands ‎(nl)‎" in the open action menu
Then I should see "Gebruikersnaam"

@_file_upload
Scenario: Set logo for loginpage
Given I log in as "admin"
And I navigate to "Appearance > Logos" in site administration
And I upload "course/tests/fixtures/image.jpg" file to "Logo" filemanager
And I press "Save changes"
And I log out
And I follow "Log in"
Then "//img[@id='logoimage']" "xpath_element" should exist

Scenario: Add a custom welcome message
Given the following config values are set as admin:
| auth_instructions | Lorem ipsum dolor sit amet |
And I follow "Log in"
Then I should see "Lorem ipsum dolor sit amet"

Scenario: Show the maintenance mode message
Given the following config values are set as admin:
| maintenance_enabled | Disabled |
| maintenance_message | Back online tomorrow |
And I follow "Log in"
Then I should see "Back online tomorrow"

Scenario: User self registration
Given the following config values are set as admin:
| registerauth | Email-based self-registration |
And I follow "Log in"
Then I should see "Create new account"

Scenario: Set OAuth providers
Given I log in as "admin"
And I navigate to "Plugins > Authentication > Manage authentication" in site administration
And I click on "Enable" "link" in the "OAuth 2" "table_row"
And I navigate to "Server > OAuth 2 services" in site administration
And I press "Google"
And I set the field "Client ID" to "1234"
And I set the field "Client secret" to "1234"
And I press "Save changes"
And I press "Facebook"
And I set the field "Client ID" to "1234"
And I set the field "Client secret" to "1234"
And I press "Save changes"
And I press "Microsoft"
And I set the field "Client ID" to "1234"
And I set the field "Client secret" to "1234"
And I press "Save changes"
And I log out
And I follow "Log in"
Then I should see "Google"
And I should see "Facebook"
And I should see "Microsoft"

Scenario: Test the login page auto focus feature
Given the following config values are set as admin:
| loginpageautofocus | Enabled |
And I follow "Log in"
Then the focused element is "Username" "field"
And I set the field "Username" to "admin"
And I set the field "Password" to "admin"
And I set the field "Remember username" to "1"
And I press "Log in"
And I log out
And I follow "Log in"
Then the focused element is "Password" "field"

Scenario: Test the login page focus after error feature
Given I follow "Log in"
And I set the field "Username" to "admin"
And I set the field "Password" to "wrongpassword"
And I press "Log in"
And I press the tab key
Then the focused element is "Username" "field"
12 changes: 6 additions & 6 deletions auth/tests/behat/verifyageofconsent.feature
Expand Up @@ -13,24 +13,24 @@ Feature: Test the 'Digital age of consent verification' feature works.
# Try to access the sign up page.
Given I am on homepage
When I click on "Log in" "link" in the ".logininfo" "css_element"
And I press "Create new account"
And I click on "Create new account" "link"
Then I should see "Age and location verification"
When I set the field "What is your age?" to "16"
And I set the field "In which country do you live?" to "DZ"
And I press "Proceed"
Then I should see "New account"
And I should see "Choose your username and password"
And I should see "Username"
# Try to access the sign up page again.
When I press "Cancel"
And I press "Create new account"
And I click on "Create new account" "link"
Then I should see "New account"
And I should see "Choose your username and password"
And I should see "Username"

Scenario: User that is considered a digital minor attempts to self-register on the site.
# Try to access the sign up page.
Given I am on homepage
When I click on "Log in" "link" in the ".logininfo" "css_element"
And I press "Create new account"
And I click on "Create new account" "link"
Then I should see "Age and location verification"
When I set the field "What is your age?" to "12"
And I set the field "In which country do you live?" to "AT"
Expand All @@ -40,6 +40,6 @@ Feature: Test the 'Digital age of consent verification' feature works.
# Try to access the sign up page again.
When I click on "Back to the site home" "link"
And I click on "Log in" "link" in the ".logininfo" "css_element"
And I press "Create new account"
And I click on "Create new account" "link"
Then I should see "You are too young to create an account on this site."
And I should see "Please ask your parent/guardian to contact:"
2 changes: 2 additions & 0 deletions lang/en/deprecated.txt
Expand Up @@ -161,3 +161,5 @@ coursepage,core_admin
invalidpersistenterror,core_competency
mediapluginswf,core_admin
mediapluginswfnote,core_admin
createuserandpass,core
supplyinfo,core
4 changes: 2 additions & 2 deletions lang/en/moodle.php
Expand Up @@ -419,7 +419,6 @@
$string['createnewcourse'] = 'Create new course';
$string['createnewsubcategory'] = 'Create new subcategory';
$string['createsubcategoryof'] = 'Create subcategory of {$a}';
$string['createuserandpass'] = 'Choose your username and password';
$string['createuser'] = 'Create user';
$string['createziparchive'] = 'Create zip archive';
$string['creatingblocks'] = 'Creating blocks';
Expand Down Expand Up @@ -2064,7 +2063,6 @@
$string['summary'] = 'Summary';
$string['summary_help'] = 'The idea of a summary is a short text to prepare students for the activities within the topic or week. The text is shown on the course page under the section name.';
$string['summaryof'] = 'Summary of {$a}';
$string['supplyinfo'] = 'More details';
$string['suspended'] = 'Suspended';
$string['suspendedusers'] = 'Suspended users';
$string['switchdevicedefault'] = 'Switch to the standard theme';
Expand Down Expand Up @@ -2350,4 +2348,6 @@
$string['registrationno'] = 'No, I do not wish to receive any emails';

// Deprecated since Moodle 4.0.
$string['createuserandpass'] = 'Choose your username and password';
$string['descriptiona'] = 'Description: {$a}';
$string['supplyinfo'] = 'More details';

0 comments on commit ca229df

Please sign in to comment.