-
-
Notifications
You must be signed in to change notification settings - Fork 68
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #41 from johnbillion/return-hash
Ensure the hashed password is always returned
- Loading branch information
Showing
6 changed files
with
92 additions
and
4 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,13 @@ | ||
<?php | ||
|
||
// phpcs:disable PSR1.Classes.ClassDeclaration.MissingNamespace | ||
// phpcs:disable Squiz.Classes.ValidClassName.NotCamelCaps | ||
class WP_Application_Passwords | ||
{ | ||
public const USERMETA_KEY_APPLICATION_PASSWORDS = '_application_passwords'; | ||
|
||
public static function get_user_application_passwords($userId) | ||
{ | ||
return []; | ||
} | ||
} |
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
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,34 @@ | ||
<?php | ||
|
||
namespace Roots\PasswordBcrypt\Tests\Unit; | ||
|
||
use Roots\PasswordBcrypt\Tests\TestCase; | ||
use Roots\PasswordBcrypt\Tests\Constants; | ||
|
||
use function Brain\Monkey\Filters\expectApplied; | ||
|
||
class EmptyApplicationPasswordTest extends TestCase | ||
{ | ||
|
||
/** | ||
* @test | ||
* @runInSeparateProcess | ||
*/ | ||
public function phpass_application_passwords_should_be_verified_and_converted_to_bcrypt() | ||
{ | ||
require_once __DIR__ . '/../EmptyWPApplicationPasswords.php'; | ||
|
||
expectApplied('application_password_is_api_request') | ||
->andReturn(true); | ||
|
||
$this | ||
->wpHasher() | ||
->shouldReceive('CheckPassword') | ||
->times(3) | ||
->andReturnValues([true, true, false]); | ||
|
||
$hash = wp_set_password(Constants::PASSWORD, Constants::USER_ID); | ||
|
||
$this->assertIsString($hash); | ||
} | ||
} |
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,33 @@ | ||
<?php | ||
|
||
namespace Roots\PasswordBcrypt\Tests\Unit; | ||
|
||
use Roots\PasswordBcrypt\Tests\TestCase; | ||
use Roots\PasswordBcrypt\Tests\Constants; | ||
|
||
use function Brain\Monkey\Filters\expectApplied; | ||
|
||
class RESTAPIPasswordTest extends TestCase | ||
{ | ||
|
||
/** | ||
* @test | ||
* @runInSeparateProcess | ||
*/ | ||
public function phpass_application_passwords_should_be_verified_and_converted_to_bcrypt() | ||
{ | ||
expectApplied('application_password_is_api_request') | ||
->andReturn(true); | ||
|
||
$this | ||
->wpHasher() | ||
->shouldReceive('CheckPassword') | ||
->times(3) | ||
->andReturnValues([true, true, false]); | ||
|
||
$hash = wp_set_password(Constants::PASSWORD, Constants::USER_ID); | ||
|
||
$this->assertFalse(class_exists('WP_Application_Passwords')); | ||
$this->assertIsString($hash); | ||
} | ||
} |
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
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