diff --git a/core/modules/user/lib/Drupal/user/Tests/UserLoginTest.php b/core/modules/user/lib/Drupal/user/Tests/UserLoginTest.php index 36c5f47..cc9994c 100644 --- a/core/modules/user/lib/Drupal/user/Tests/UserLoginTest.php +++ b/core/modules/user/lib/Drupal/user/Tests/UserLoginTest.php @@ -23,6 +23,45 @@ public static function getInfo() { } /** + * Test creating a user with long password. + */ + function testPasswordLength() { + $password_lengths = array(128, 129); + + foreach ($password_lengths as $password_length) { + $test_name = $this->randomName(); + $test_pass = user_password($password_length); + + // Create the base user, based on drupalCreateUser(). + $account = entity_create('user', array( + 'name' => $test_name, + 'mail' => $test_name . '@example.com', + 'pass' => $test_pass, + 'status' => 1, + )); + $account->save(); + + $auth = array( + 'name' => $account->name, + 'pass' => $test_pass, + ); + + $this->drupalPost('user/login', $auth, t('Log in')); + + if ($password_length === 128) { + $this->assertNoText(t('User login'), 'Logged in with 127 character length password.'); + $this->assertPattern('!!', 'Redirected to /user'); + $this->drupalLogout(); + } + + if ($password_length === 129) { + $this->assertText(t('Log in'), 'Couldn\'t log in with 255 character long password.'); + $this->assertText('Password cannot be longer than', 'Error message appeared.'); + } + } + } + + /** * Test the global login flood control. */ function testGlobalLoginFloodControl() {