-
Notifications
You must be signed in to change notification settings - Fork 797
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Password Checker: Initial Skeleton (#18700)
Co-authored-by: Brad Jorsch <anomiex@users.noreply.github.com>
- Loading branch information
1 parent
d001afc
commit 67c4391
Showing
11 changed files
with
1,612 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# Files not needed to be distributed in the package. | ||
.gitattributes export-ignore | ||
.github/ export-ignore | ||
phpunit.xml.dist export-ignore | ||
tests/ export-ignore | ||
|
||
# Files not needed in the production build. | ||
/changelog/** production-exclude |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
wordpress |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# Changelog | ||
|
||
All notable changes to this project will be documented in this file. | ||
|
||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) | ||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# Password Checker | ||
|
||
Password Checker package. | ||
|
||
### Usage | ||
|
||
Add a new test: | ||
|
||
```php | ||
$tests = array( | ||
'preg_match' => array( | ||
'no_backslashes' => array( | ||
'pattern' => '/^[^\\\\]*$/u', | ||
'error' => __( 'Passwords may not contain the character "\".', 'jetpack' ), | ||
'required' => true, | ||
'fail_immediately' => true, | ||
), | ||
), | ||
'compare_to_list' => array( | ||
'not_a_common_password' => array( | ||
'list_callback' => 'get_common_passwords', | ||
'compare_callback' => 'negative_in_array', | ||
'error' => __( 'This is a very common password. Choose something that will be harder for others to guess.', 'jetpack' ), | ||
'required' => true, | ||
), | ||
) | ||
); | ||
$tests = apply_filters( 'password_checker_tests', $tests ); | ||
``` | ||
|
||
Test a password: | ||
|
||
```php | ||
use Automattic\Jetpack\Password_Checker; | ||
|
||
$user = new WP_User( 1 ); | ||
$password_checker = new Password_Checker( $user ); | ||
$password_checker->test( '123', true ); | ||
``` |
Empty file.
4 changes: 4 additions & 0 deletions
4
projects/packages/password-checker/changelog/add-changelogger-to-password-package
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
Significance: major | ||
Type: added | ||
|
||
Initial release. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
{ | ||
"name": "automattic/jetpack-password-checker", | ||
"description": "Password Checker.", | ||
"type": "library", | ||
"license": "GPL-2.0-or-later", | ||
"require": {}, | ||
"require-dev": { | ||
"automattic/jetpack-changelogger": "1.1.x-dev", | ||
"automattic/wordbless": "@dev", | ||
"yoast/phpunit-polyfills": "0.2.0" | ||
}, | ||
"autoload": { | ||
"classmap": [ | ||
"src/" | ||
] | ||
}, | ||
"scripts": { | ||
"phpunit": [ | ||
"@composer install", | ||
"./vendor/phpunit/phpunit/phpunit --colors=always" | ||
], | ||
"test-coverage": [ | ||
"@composer install", | ||
"phpdbg -d memory_limit=2048M -d max_execution_time=900 -qrr ./vendor/bin/phpunit --coverage-clover \"$COVERAGE_DIR/clover.xml\"" | ||
], | ||
"test-php": [ | ||
"@composer phpunit" | ||
], | ||
"post-update-cmd": "php -r \"copy('vendor/automattic/wordbless/src/dbless-wpdb.php', 'wordpress/wp-content/db.php');\"" | ||
}, | ||
"repositories": [ | ||
{ | ||
"type": "path", | ||
"url": "../*", | ||
"options": { | ||
"monorepo": true | ||
} | ||
} | ||
], | ||
"minimum-stability": "dev", | ||
"prefer-stable": true, | ||
"extra": { | ||
"mirror-repo": "Automattic/jetpack-password-checker", | ||
"changelogger": { | ||
"link-template": "https://github.com/Automattic/jetpack-password-checker/compare/v${old}...v${new}" | ||
}, | ||
"branch-alias": { | ||
"dev-master": "0.1.x-dev" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<phpunit bootstrap="tests/php/bootstrap.php" backupGlobals="false" colors="true"> | ||
<testsuites> | ||
<testsuite name="main"> | ||
<directory prefix="test" suffix=".php">tests/php</directory> | ||
</testsuite> | ||
</testsuites> | ||
<filter> | ||
<whitelist> | ||
<directory suffix=".php">.</directory> | ||
<exclude> | ||
<directory suffix=".php">tests</directory> | ||
<directory suffix=".php">vendor</directory> | ||
<directory suffix=".php">views</directory> | ||
</exclude> | ||
</whitelist> | ||
</filter> | ||
</phpunit> |
Oops, something went wrong.