REDROOM
PHP 8.2.31
Path:
Logout
Edit File
Size: 2.41 KB
Close
/opt/alt/php54/usr/share/pear/test/Security/Symfony/Component/Security/Core/Tests/Encoder/BCryptPasswordEncoderTest.php
Text
Base64
<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Security\Core\Tests\Encoder; use Symfony\Component\Security\Core\Encoder\BCryptPasswordEncoder; /** * @author Elnur Abdurrakhimov <elnur@elnur.pro> */ class BCryptPasswordEncoderTest extends \PHPUnit_Framework_TestCase { const PASSWORD = 'password'; const BYTES = '0123456789abcdef'; const VALID_COST = '04'; /** * @expectedException \InvalidArgumentException */ public function testCostBelowRange() { new BCryptPasswordEncoder(3); } /** * @expectedException \InvalidArgumentException */ public function testCostAboveRange() { new BCryptPasswordEncoder(32); } public function testCostInRange() { for ($cost = 4; $cost <= 31; $cost++) { new BCryptPasswordEncoder($cost); } } public function testResultLength() { $this->skipIfPhpVersionIsNotSupported(); $encoder = new BCryptPasswordEncoder(self::VALID_COST); $result = $encoder->encodePassword(self::PASSWORD, null); $this->assertEquals(60, strlen($result)); } public function testValidation() { $this->skipIfPhpVersionIsNotSupported(); $encoder = new BCryptPasswordEncoder(self::VALID_COST); $result = $encoder->encodePassword(self::PASSWORD, null); $this->assertTrue($encoder->isPasswordValid($result, self::PASSWORD, null)); $this->assertFalse($encoder->isPasswordValid($result, 'anotherPassword', null)); } private function skipIfPhpVersionIsNotSupported() { if (version_compare(phpversion(), '5.3.7', '<')) { $this->markTestSkipped('Requires PHP >= 5.3.7'); } } /** * @expectedException \Symfony\Component\Security\Core\Exception\BadCredentialsException */ public function testEncodePasswordLength() { $encoder = new BCryptPasswordEncoder(self::VALID_COST); $encoder->encodePassword(str_repeat('a', 5000), 'salt'); } public function testCheckPasswordLength() { $encoder = new BCryptPasswordEncoder(self::VALID_COST); $this->assertFalse($encoder->isPasswordValid('encoded', str_repeat('a', 5000), 'salt')); } }
Save
Close
Exit & Reset
Text mode: syntax highlighting auto-detects file type.
Directory Contents
Dirs: 0 × Files: 6
Delete Selected
Select All
Select None
Sort:
Name
Size
Modified
Enable drag-to-move
Name
Size
Perms
Modified
Actions
BasePasswordEncoderTest.php
2.97 KB
lrw-r--r--
2019-12-18 11:22:57
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
BCryptPasswordEncoderTest.php
2.41 KB
lrw-r--r--
2019-12-18 11:22:57
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
EncoderFactoryTest.php
3.75 KB
lrw-r--r--
2019-12-18 11:22:57
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
MessageDigestPasswordEncoderTest.php
2.00 KB
lrw-r--r--
2019-12-18 11:22:57
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
Pbkdf2PasswordEncoderTest.php
2.11 KB
lrw-r--r--
2019-12-18 11:22:57
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
PlaintextPasswordEncoderTest.php
1.67 KB
lrw-r--r--
2019-12-18 11:22:57
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
Zip Selected
If ZipArchive is unavailable, a
.tar
will be created (no compression).