Skip to content

Commit

Permalink
increase minimum password length
Browse files Browse the repository at this point in the history
  • Loading branch information
torhoehn committed Nov 18, 2024
1 parent 6acfd6a commit 373bb39
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 17 deletions.
2 changes: 1 addition & 1 deletion app/code/Magento/User/Model/UserValidationRules.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class UserValidationRules
/**
* Minimum length of admin password
*/
public const MIN_PASSWORD_LENGTH = 7;
public const MIN_PASSWORD_LENGTH = 12;

/**
* Adds validation rule for user first name, last name, username and email
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class Bootstrap
* Predefined admin user credentials
*/
public const ADMIN_NAME = 'user';
public const ADMIN_PASSWORD = 'password1';
public const ADMIN_PASSWORD = 'password1234';
public const ADMIN_EMAIL = '[email protected]';
public const ADMIN_FIRSTNAME = 'firstname';
public const ADMIN_LASTNAME = 'lastname';
Expand Down
4 changes: 2 additions & 2 deletions lib/web/mage/validation.js
Original file line number Diff line number Diff line change
Expand Up @@ -685,13 +685,13 @@ define([
return false;
}

if (pass.length < 7) {
if (pass.length < 12) {
return false;
}

return true;
},
$.mage.__('Please enter 7 or more characters, using both numeric and alphabetic.')
$.mage.__('Please enter 12 or more characters, using both numeric and alphabetic.')
],
'validate-customer-password': [
function (v, elm) {
Expand Down
2 changes: 1 addition & 1 deletion setup/src/Magento/Setup/Fixtures/AdminUsersFixture.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public function execute()
->setFirstName('Firstname')
->setLastName('Lastname')
->setUserName('admin' . $i)
->setPassword('123123q')
->setPassword('1234512345q!')
->setIsActive(1);
$adminUser->save();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,14 @@ public function testExecute(): void
{
$options = [
'--' . AdminAccount::KEY_USER => 'user',
'--' . AdminAccount::KEY_PASSWORD => '123123q',
'--' . AdminAccount::KEY_PASSWORD => '1234512345q!',
'--' . AdminAccount::KEY_EMAIL => '[email protected]',
'--' . AdminAccount::KEY_FIRST_NAME => 'John',
'--' . AdminAccount::KEY_LAST_NAME => 'Doe'
];
$data = [
AdminAccount::KEY_USER => 'user',
AdminAccount::KEY_PASSWORD => '123123q',
AdminAccount::KEY_PASSWORD => '1234512345q!',
AdminAccount::KEY_EMAIL => '[email protected]',
AdminAccount::KEY_FIRST_NAME => 'John',
AdminAccount::KEY_LAST_NAME => 'Doe',
Expand All @@ -93,7 +93,7 @@ public function testInteraction(): void

$this->questionHelperMock
->method('ask')
->willReturnOnConsecutiveCalls('admin', 'Password123', '[email protected]', 'John', 'Doe');
->willReturnOnConsecutiveCalls('admin', 'Password1234', '[email protected]', 'John', 'Doe');

// We override the standard helper with our mock
$this->command->getHelperSet()->set($this->questionHelperMock, 'question');
Expand All @@ -102,7 +102,7 @@ public function testInteraction(): void

$expectedData = [
'admin-user' => 'admin',
'admin-password' => 'Password123',
'admin-password' => 'Password1234',
'admin-email' => '[email protected]',
'admin-firstname' => 'John',
'admin-lastname' => 'Doe',
Expand Down Expand Up @@ -189,38 +189,38 @@ public static function validateDataProvider(): array
{
return [
[
[null, 'Doe', 'admin', '[email protected]', '123123q', '123123q'],
[null, 'Doe', 'admin', '[email protected]', '1234512345q!', '1234512345q!'],
['"First Name" is required. Enter and try again.']
],
[
['John', null, null, '[email protected]', '123123q', '123123q'],
['John', null, null, '[email protected]', '1234512345q!', '1234512345q!'],
['"User Name" is required. Enter and try again.', '"Last Name" is required. Enter and try again.'],
],
[['John', 'Doe', 'admin', null, '123123q', '123123q'], ['Please enter a valid email.']],
[['John', 'Doe', 'admin', null, '1234512345q!', '1234512345q!'], ['Please enter a valid email.']],
[
['John', 'Doe', 'admin', 'test', '123123q', '123123q'],
['John', 'Doe', 'admin', 'test', '1234512345q!', '1234512345q!'],
["'test' is not a valid email address in the basic format local-part@hostname"]
],
[
['John', 'Doe', 'admin', '[email protected]', '', ''],
[
'Password is required field.',
'Your password must be at least 7 characters.',
'Your password must be at least 12 characters.',
'Your password must include both numeric and alphabetic characters.'
]
],
[
['John', 'Doe', 'admin', '[email protected]', '123123', '123123'],
[
'Your password must be at least 7 characters.',
'Your password must be at least 12 characters.',
'Your password must include both numeric and alphabetic characters.'
]
],
[
['John', 'Doe', 'admin', '[email protected]', '1231231', '1231231'],
['John', 'Doe', 'admin', '[email protected]', '123123123123', '123123123123'],
['Your password must include both numeric and alphabetic characters.']
],
[['John', 'Doe', 'admin', '[email protected]', '123123q', '123123q'], []],
[['John', 'Doe', 'admin', '[email protected]', '1234512345q!', '1234512345q!'], []],
];
}
}

0 comments on commit 373bb39

Please sign in to comment.