diff options
author | Lukas Reschke <lukas@owncloud.com> | 2014-09-03 14:13:12 +0200 |
---|---|---|
committer | Lukas Reschke <lukas@owncloud.com> | 2014-09-03 14:13:12 +0200 |
commit | a54af89d8a579ead1b26f617fa0d177925aee6e8 (patch) | |
tree | 29c23170b828cbe4cf63a0dbfed019f78a97da04 /tests | |
parent | 1ccbaae84636dabdd59cb0d9d945a6d2f22d10e8 (diff) | |
download | nextcloud-server-a54af89d8a579ead1b26f617fa0d177925aee6e8.tar.gz nextcloud-server-a54af89d8a579ead1b26f617fa0d177925aee6e8.zip |
Add test for the second argument
Diffstat (limited to 'tests')
-rw-r--r-- | tests/lib/security/securerandom.php | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/lib/security/securerandom.php b/tests/lib/security/securerandom.php index 52c1dec92ea..2920077fa1d 100644 --- a/tests/lib/security/securerandom.php +++ b/tests/lib/security/securerandom.php @@ -22,6 +22,14 @@ class SecureRandomTest extends \PHPUnit_Framework_TestCase { ); } + public static function charCombinations() { + return array( + array('CHAR_LOWER', '[a-z]'), + array('CHAR_UPPER', '[A-Z]'), + array('CHAR_DIGITS', '[0-9]'), + ); + } + /** @var SecureRandom */ protected $rng; @@ -54,4 +62,15 @@ class SecureRandomTest extends \PHPUnit_Framework_TestCase { function testUninitializedGenerate() { $this->rng->generate(30); } + + /** + * @dataProvider charCombinations + */ + public function testScheme($charName, $chars) { + $generator = $this->rng->getMediumStrengthGenerator(); + $scheme = constant('OCP\Security\ISecureRandom::' . $charName); + $randomString = $generator->generate(100, $scheme); + $matchesRegex = preg_match('/^'.$chars.'+$/', $randomString); + $this->assertSame(1, $matchesRegex); + } } |