From 8f8ae115bc3cfa7819c2e850b5457876ef0ad38c Mon Sep 17 00:00:00 2001 From: Jake Dallimore Date: Fri, 23 Dec 2016 10:42:01 +0800 Subject: [PATCH 1/2] MDL-57357 auth: fix the remember username feature on login page --- auth/classes/output/login.php | 1 + 1 file changed, 1 insertion(+) diff --git a/auth/classes/output/login.php b/auth/classes/output/login.php index e5e4e7d4f11..5b924bb467b 100644 --- a/auth/classes/output/login.php +++ b/auth/classes/output/login.php @@ -151,6 +151,7 @@ class login implements renderable, templatable { $data->rememberusername = $this->rememberusername; $data->passwordautocomplete = $this->passwordautocomplete; $data->signupurl = $this->signupurl->out(false); + $data->username = $this->username; return $data; } From a545224b9d761c64cc51f449b468b87e26704d0f Mon Sep 17 00:00:00 2001 From: Jake Dallimore Date: Fri, 23 Dec 2016 10:42:16 +0800 Subject: [PATCH 2/2] MDL-57357 auth: add behat coverage for remember username login feature --- auth/tests/behat/rememberusername.feature | 50 +++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 auth/tests/behat/rememberusername.feature diff --git a/auth/tests/behat/rememberusername.feature b/auth/tests/behat/rememberusername.feature new file mode 100644 index 00000000000..754ce8fd217 --- /dev/null +++ b/auth/tests/behat/rememberusername.feature @@ -0,0 +1,50 @@ +@core @core_auth +Feature: Test the 'remember username' feature works. + In order to see my saved username on the login form + As a user + I need to have logged in once before and clicked 'Remember username' + + Background: + Given the following "users" exist: + | username | + | teacher1 | + + # Given the user has logged in and selected 'Remember username', when they log in again, then their username should be remembered. + Scenario: Check that 'remember username' works without javascript for teachers. + # Log in the first time and check the 'remember username' box. + Given I am on homepage + And I click on "Log in" "link" in the ".logininfo" "css_element" + And I set the field "Username" to "teacher1" + And I set the field "Password" to "teacher1" + And I set the field "Remember username" to "1" + And I press "Log in" + And I log out + # Log out and check that the username was remembered. + When I am on homepage + And I click on "Log in" "link" in the ".logininfo" "css_element" + Then the field "username" matches value "teacher1" + And the field "Remember username" matches value "1" + + # Given the user has logged in before and selected 'Remember username', when they log in again and unset 'Remember username', then + # their username should be forgotten for future log in attempts. + Scenario: Check that 'remember username' unsetting works without javascript for teachers. + # Log in the first time and check the 'remember username' box. + Given I am on homepage + And I click on "Log in" "link" in the ".logininfo" "css_element" + And I set the field "Username" to "teacher1" + And I set the field "Password" to "teacher1" + And I set the field "Remember username" to "1" + And I press "Log in" + And I log out + # Log in again, unsetting the 'remember username' field. + When I am on homepage + And I click on "Log in" "link" in the ".logininfo" "css_element" + And I set the field "Password" to "teacher1" + And I set the field "Remember username" to "0" + And I press "Log in" + And I log out + # Check username has been forgotten. + Then I am on homepage + And I click on "Log in" "link" in the ".logininfo" "css_element" + Then the field "username" matches value "" + And the field "Remember username" matches value "0"