diff options
author | Daniel Friesen <pub-github@nadir-seen-fire.com> | 2012-08-06 23:34:32 -0700 |
---|---|---|
committer | Daniel Friesen <pub-github@nadir-seen-fire.com> | 2012-08-06 23:34:32 -0700 |
commit | 15d9b94e03227c93d530997f166550ac44ce3ce0 (patch) | |
tree | 665df43bb88545faf4e99a0d9f21c4ccd0372baa | |
parent | 0bf5068ccb3c9300d00a188803f6d5af62a216c6 (diff) |
Add a PLAINTEXT password storage type in the test framework.origin/password-hashing
This should ensure proper testing of the password system itself to separate mistakes in the system from mistakes in an individual password implementation.
Change-Id: Ibff05ae95dd82ff95aa5acdcb98253955fe1d3ed
-rw-r--r-- | tests/phpunit/includes/PasswordTest.php | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/phpunit/includes/PasswordTest.php b/tests/phpunit/includes/PasswordTest.php index 1fe6f9e0451d..ebcbdb4f79fa 100644 --- a/tests/phpunit/includes/PasswordTest.php +++ b/tests/phpunit/includes/PasswordTest.php @@ -14,6 +14,36 @@ class PasswordExposed extends Password { } +// PLAINTEXT Password type this is registered before the others as a test case for basic +// functionality rather than for testing a password type itself. +class PasswordTestType_PLAINTEXT extends PasswordType { + + public function crypt( $password ) { + return $password; + } + + public function verify( $data, $password ) { + return $data === $password; + } + + public function needsUpdate( $data ) { + return false; + } + + public function knownPasswordData() { + return array( + array( 'asdf', 'asdf' ), + array( 'test', 'test' ), + array( 'Hello World', 'Hello World' ), + array( 'Passw0rd', 'Passw0rd' ), + array( 'D0g.....................', 'D0g.....................' ), + array( 'KiWVic0F6Le&%Ejn8p3j1vm@#XQclWOV', 'KiWVic0F6Le&%Ejn8p3j1vm@#XQclWOV' ), + ); + } + +} +PasswordExposed::registerType( 'PLAINTEXT', 'PasswordTestType_PLAINTEXT' ); + class PasswordTest extends MediaWikiTestCase { protected $types; |