diff options
author | Thomas Müller <thomas.mueller@tmit.eu> | 2016-01-12 09:12:13 +0100 |
---|---|---|
committer | Thomas Müller <thomas.mueller@tmit.eu> | 2016-01-12 09:12:13 +0100 |
commit | 3ec8789c7708aea2f8b4335af7d496a957a16011 (patch) | |
tree | 669088ff58bb1f727f769e3456af1f4c96bc4fd4 /tests | |
parent | d11d9407cea94ebe430e50b81e01a671ec60f642 (diff) | |
parent | 07fd3889b1e7752131dc0bc746abec7646c89d01 (diff) | |
download | nextcloud-server-3ec8789c7708aea2f8b4335af7d496a957a16011.tar.gz nextcloud-server-3ec8789c7708aea2f8b4335af7d496a957a16011.zip |
Merge pull request #21628 from owncloud/deprecated_secure_random_funcions
Replace deprecated function calls to SecureRandom
Diffstat (limited to 'tests')
-rw-r--r-- | tests/core/lostpassword/controller/lostcontrollertest.php | 10 | ||||
-rw-r--r-- | tests/lib/appframework/http/RequestTest.php | 9 | ||||
-rw-r--r-- | tests/lib/dbschema.php | 2 | ||||
-rw-r--r-- | tests/lib/security/securerandom.php | 6 | ||||
-rw-r--r-- | tests/lib/testcase.php | 2 |
5 files changed, 6 insertions, 23 deletions
diff --git a/tests/core/lostpassword/controller/lostcontrollertest.php b/tests/core/lostpassword/controller/lostcontrollertest.php index eb0447f278b..0843d82da3f 100644 --- a/tests/core/lostpassword/controller/lostcontrollertest.php +++ b/tests/core/lostpassword/controller/lostcontrollertest.php @@ -167,7 +167,6 @@ class LostControllerTest extends \PHPUnit_Framework_TestCase { } public function testEmailSuccessful() { - $randomToken = $this->secureRandom; $this->secureRandom ->expects($this->once()) ->method('generate') @@ -187,10 +186,6 @@ class LostControllerTest extends \PHPUnit_Framework_TestCase { ->expects($this->once()) ->method('getTime') ->will($this->returnValue(12348)); - $this->secureRandom - ->expects($this->once()) - ->method('getMediumStrengthGenerator') - ->will($this->returnValue($randomToken)); $this->config ->expects($this->once()) ->method('setUserValue') @@ -233,7 +228,6 @@ class LostControllerTest extends \PHPUnit_Framework_TestCase { } public function testEmailCantSendException() { - $randomToken = $this->secureRandom; $this->secureRandom ->expects($this->once()) ->method('generate') @@ -249,10 +243,6 @@ class LostControllerTest extends \PHPUnit_Framework_TestCase { ->method('get') ->with('ExistingUser') ->willReturn($this->existingUser); - $this->secureRandom - ->expects($this->once()) - ->method('getMediumStrengthGenerator') - ->will($this->returnValue($randomToken)); $this->config ->expects($this->once()) ->method('setUserValue') diff --git a/tests/lib/appframework/http/RequestTest.php b/tests/lib/appframework/http/RequestTest.php index 32603d0da59..ab79eb498fa 100644 --- a/tests/lib/appframework/http/RequestTest.php +++ b/tests/lib/appframework/http/RequestTest.php @@ -352,18 +352,11 @@ class RequestTest extends \Test\TestCase { } public function testGetIdWithoutModUnique() { - $lowRandomSource = $this->getMockBuilder('\OCP\Security\ISecureRandom') - ->disableOriginalConstructor()->getMock(); - $lowRandomSource->expects($this->once()) + $this->secureRandom->expects($this->once()) ->method('generate') ->with('20') ->will($this->returnValue('GeneratedByOwnCloudItself')); - $this->secureRandom - ->expects($this->once()) - ->method('getLowStrengthGenerator') - ->will($this->returnValue($lowRandomSource)); - $request = new Request( [], $this->secureRandom, diff --git a/tests/lib/dbschema.php b/tests/lib/dbschema.php index d96f8195770..11eacbf397f 100644 --- a/tests/lib/dbschema.php +++ b/tests/lib/dbschema.php @@ -26,7 +26,7 @@ class Test_DBSchema extends \Test\TestCase { $dbfile = OC::$SERVERROOT.'/tests/data/db_structure.xml'; $dbfile2 = OC::$SERVERROOT.'/tests/data/db_structure2.xml'; - $r = '_' . \OC::$server->getSecureRandom()->getMediumStrengthGenerator()-> + $r = '_' . \OC::$server->getSecureRandom()-> generate(4, ISecureRandom::CHAR_LOWER . ISecureRandom::CHAR_DIGITS) . '_'; $content = file_get_contents( $dbfile ); $content = str_replace( '*dbprefix*', '*dbprefix*'.$r, $content ); diff --git a/tests/lib/security/securerandom.php b/tests/lib/security/securerandom.php index af437640805..526066d92ee 100644 --- a/tests/lib/security/securerandom.php +++ b/tests/lib/security/securerandom.php @@ -42,7 +42,7 @@ class SecureRandomTest extends \Test\TestCase { * @dataProvider stringGenerationProvider */ function testGetLowStrengthGeneratorLength($length, $expectedLength) { - $generator = $this->rng->getLowStrengthGenerator(); + $generator = $this->rng; $this->assertEquals($expectedLength, strlen($generator->generate($length))); } @@ -51,7 +51,7 @@ class SecureRandomTest extends \Test\TestCase { * @dataProvider stringGenerationProvider */ function testMediumLowStrengthGeneratorLength($length, $expectedLength) { - $generator = $this->rng->getMediumStrengthGenerator(); + $generator = $this->rng; $this->assertEquals($expectedLength, strlen($generator->generate($length))); } @@ -67,7 +67,7 @@ class SecureRandomTest extends \Test\TestCase { * @dataProvider charCombinations */ public function testScheme($charName, $chars) { - $generator = $this->rng->getMediumStrengthGenerator(); + $generator = $this->rng; $scheme = constant('OCP\Security\ISecureRandom::' . $charName); $randomString = $generator->generate(100, $scheme); $matchesRegex = preg_match('/^'.$chars.'+$/', $randomString); diff --git a/tests/lib/testcase.php b/tests/lib/testcase.php index 93b354863a9..38d5cf49320 100644 --- a/tests/lib/testcase.php +++ b/tests/lib/testcase.php @@ -150,7 +150,7 @@ abstract class TestCase extends \PHPUnit_Framework_TestCase { * @return string */ protected static function getUniqueID($prefix = '', $length = 13) { - return $prefix . \OC::$server->getSecureRandom()->getLowStrengthGenerator()->generate( + return $prefix . \OC::$server->getSecureRandom()->generate( $length, // Do not use dots and slashes as we use the value for file names ISecureRandom::CHAR_DIGITS . ISecureRandom::CHAR_LOWER . ISecureRandom::CHAR_UPPER |