[BUGFIX] Deprecated functions used in on fresh 6.0 final
authorStefan Froemken <froemken@gmail.com>
Tue, 11 Dec 2012 21:20:05 +0000 (22:20 +0100)
committerAlexander Schnitzler <typo3@alexanderschnitzler.de>
Wed, 12 Dec 2012 10:00:53 +0000 (11:00 +0100)
There are some deprecated function calls I have
changed to the new functions

Resolves: #43528
Releases: 6.0, 6.1
Change-Id: I1acde2c8250192732030d2137e251ac79e5db81d
Reviewed-on: https://review.typo3.org/17116
Reviewed-by: Alexander Schnitzler
Tested-by: Alexander Schnitzler
typo3/sysext/extbase/Classes/Security/Channel/RequestHashService.php
typo3/sysext/extbase/Tests/Unit/Security/Channel/RequestHashServiceTest.php
typo3/sysext/extbase/Tests/Unit/Security/Cryptography/HashServiceTest.php

index 2bbd9b6..cc1d184 100644 (file)
@@ -118,7 +118,7 @@ class RequestHashService implements \TYPO3\CMS\Core\SingletonInterface {
         */
        protected function serializeAndHashFormFieldArray($formFieldArray) {
                $serializedFormFieldArray = serialize($formFieldArray);
-               return $serializedFormFieldArray . $this->hashService->generateHash($serializedFormFieldArray);
+               return $serializedFormFieldArray . $this->hashService->generateHmac($serializedFormFieldArray);
        }
 
        /**
@@ -142,7 +142,7 @@ class RequestHashService implements \TYPO3\CMS\Core\SingletonInterface {
                $serializedFieldNames = substr($hmac, 0, -40);
                // TODO: Constant for hash length needs to be introduced
                $hash = substr($hmac, -40);
-               if ($this->hashService->validateHash($serializedFieldNames, $hash)) {
+               if ($this->hashService->validateHmac($serializedFieldNames, $hash)) {
                        $requestArguments = $request->getArguments();
                        // Unset framework arguments
                        unset($requestArguments['__referrer']);
index 4891dc7..08edc47 100644 (file)
@@ -158,8 +158,8 @@ class RequestHashServiceTest extends \TYPO3\CMS\Extbase\Tests\Unit\BaseTestCase
                        )
                );
                $mockHash = '12345';
-               $hashService = $this->getAccessibleMock('TYPO3\\CMS\\Extbase\\Security\\Cryptography\\HashService', array('generateHash'));
-               $hashService->expects($this->once())->method('generateHash')->with(serialize($formFieldArray))->will($this->returnValue($mockHash));
+               $hashService = $this->getAccessibleMock('TYPO3\\CMS\\Extbase\\Security\\Cryptography\\HashService', array('generateHmac'));
+               $hashService->expects($this->once())->method('generateHmac')->with(serialize($formFieldArray))->will($this->returnValue($mockHash));
                $requestHashService = $this->getAccessibleMock('TYPO3\\CMS\\Extbase\\Security\\Channel\\RequestHashService', array('dummy'));
                $requestHashService->_set('hashService', $hashService);
                $expected = serialize($formFieldArray) . $mockHash;
@@ -199,8 +199,8 @@ class RequestHashServiceTest extends \TYPO3\CMS\Extbase\Tests\Unit\BaseTestCase
                $request = $this->getAccessibleMock('TYPO3\\CMS\\Extbase\\Mvc\\Web\\Request', array('getInternalArgument', 'setHmacVerified'));
                $request->expects($this->any())->method('getInternalArgument')->with('__hmac')->will($this->returnValue('11111' . '0000000000000000000000000000000000000000'));
                $request->expects($this->once())->method('setHmacVerified')->with(FALSE);
-               $hashService = $this->getMock('TYPO3\\CMS\\Extbase\\Security\\Cryptography\\HashService', array('validateHash'));
-               $hashService->expects($this->once())->method('validateHash')->with('11111', '0000000000000000000000000000000000000000')->will($this->returnValue(FALSE));
+               $hashService = $this->getMock('TYPO3\\CMS\\Extbase\\Security\\Cryptography\\HashService', array('validateHmac'));
+               $hashService->expects($this->once())->method('validateHmac')->with('11111', '0000000000000000000000000000000000000000')->will($this->returnValue(FALSE));
                $requestHashService = $this->getAccessibleMock('TYPO3\\CMS\\Extbase\\Security\\Channel\\RequestHashService', array('dummy'));
                $requestHashService->_set('hashService', $hashService);
                $requestHashService->verifyRequest($request);
@@ -220,8 +220,8 @@ class RequestHashServiceTest extends \TYPO3\CMS\Extbase\Tests\Unit\BaseTestCase
                        'a' => 'bla'
                )));
                $request->expects($this->once())->method('setHmacVerified')->with(TRUE);
-               $hashService = $this->getMock('TYPO3\\CMS\\Extbase\\Security\\Cryptography\\HashService', array('validateHash'));
-               $hashService->expects($this->once())->method('validateHash')->with($data, '0000000000000000000000000000000000000000')->will($this->returnValue(TRUE));
+               $hashService = $this->getMock('TYPO3\\CMS\\Extbase\\Security\\Cryptography\\HashService', array('validateHmac'));
+               $hashService->expects($this->once())->method('validateHmac')->with($data, '0000000000000000000000000000000000000000')->will($this->returnValue(TRUE));
                $requestHashService = $this->getAccessibleMock('TYPO3\\CMS\\Extbase\\Security\\Channel\\RequestHashService', array('checkFieldNameInclusion'));
                $requestHashService->expects($this->once())->method('checkFieldNameInclusion')->with(array('a' => 'bla'), array('a' => 1))->will($this->returnValue(TRUE));
                $requestHashService->_set('hashService', $hashService);
@@ -243,8 +243,8 @@ class RequestHashServiceTest extends \TYPO3\CMS\Extbase\Tests\Unit\BaseTestCase
                        'b' => 'blubb'
                )));
                $request->expects($this->once())->method('setHmacVerified')->with(FALSE);
-               $hashService = $this->getMock('TYPO3\\CMS\\Extbase\\Security\\Cryptography\\HashService', array('validateHash'));
-               $hashService->expects($this->once())->method('validateHash')->with($data, '0000000000000000000000000000000000000000')->will($this->returnValue(TRUE));
+               $hashService = $this->getMock('TYPO3\\CMS\\Extbase\\Security\\Cryptography\\HashService', array('validateHmac'));
+               $hashService->expects($this->once())->method('validateHmac')->with($data, '0000000000000000000000000000000000000000')->will($this->returnValue(TRUE));
                $requestHashService = $this->getAccessibleMock('TYPO3\\CMS\\Extbase\\Security\\Channel\\RequestHashService', array('checkFieldNameInclusion'));
                $requestHashService->expects($this->once())->method('checkFieldNameInclusion')->with(array('a' => 'bla', 'b' => 'blubb'), array('a' => 1))->will($this->returnValue(FALSE));
                $requestHashService->_set('hashService', $hashService);
index 2780728..e7b2e46 100644 (file)
@@ -40,8 +40,8 @@ class HashServiceTest extends \TYPO3\CMS\Extbase\Tests\Unit\BaseTestCase {
         * @test
         * @author Sebastian Kurfürst
         */
-       public function generateHashReturnsHashStringIfStringIsGiven() {
-               $hash = $this->hashService->generateHash('asdf');
+       public function generateHmacReturnsHashStringIfStringIsGiven() {
+               $hash = $this->hashService->generateHmac('asdf');
                $this->assertTrue(is_string($hash));
        }
 
@@ -49,8 +49,8 @@ class HashServiceTest extends \TYPO3\CMS\Extbase\Tests\Unit\BaseTestCase {
         * @test
         * @author Sebastian Kurfürst
         */
-       public function generateHashReturnsHashStringWhichContainsSomeSalt() {
-               $hash = $this->hashService->generateHash('asdf');
+       public function generateHmacReturnsHashStringWhichContainsSomeSalt() {
+               $hash = $this->hashService->generateHmac('asdf');
                $this->assertNotEquals(sha1('asdf'), $hash);
        }
 
@@ -58,9 +58,9 @@ class HashServiceTest extends \TYPO3\CMS\Extbase\Tests\Unit\BaseTestCase {
         * @test
         * @author Sebastian Kurfürst
         */
-       public function generateHashReturnsDifferentHashStringsForDifferentInputStrings() {
-               $hash1 = $this->hashService->generateHash('asdf');
-               $hash2 = $this->hashService->generateHash('blubb');
+       public function generateHmacReturnsDifferentHashStringsForDifferentInputStrings() {
+               $hash1 = $this->hashService->generateHmac('asdf');
+               $hash2 = $this->hashService->generateHmac('blubb');
                $this->assertNotEquals($hash1, $hash2);
        }
 
@@ -69,28 +69,28 @@ class HashServiceTest extends \TYPO3\CMS\Extbase\Tests\Unit\BaseTestCase {
         * @expectedException \TYPO3\CMS\Extbase\Security\Exception\InvalidArgumentForHashGenerationException
         * @author Sebastian Kurfürst
         */
-       public function generateHashThrowsExceptionIfNoStringGiven() {
-               $hash = $this->hashService->generateHash(NULL);
+       public function generateHmacThrowsExceptionIfNoStringGiven() {
+               $hash = $this->hashService->generateHmac(NULL);
        }
 
        /**
         * @test
         * @author Sebastian Kurfürst <sebastian@typo3.org>
         */
-       public function generatedHashCanBeValidatedAgain() {
+       public function generatedHmacCanBeValidatedAgain() {
                $string = 'asdf';
-               $hash = $this->hashService->generateHash($string);
-               $this->assertTrue($this->hashService->validateHash($string, $hash));
+               $hash = $this->hashService->generateHmac($string);
+               $this->assertTrue($this->hashService->validateHmac($string, $hash));
        }
 
        /**
         * @test
         * @author Sebastian Kurfürst <sebastian@typo3.org>
         */
-       public function generatedHashWillNotBeValidatedIfHashHasBeenChanged() {
+       public function generatedHmacWillNotBeValidatedIfHashHasBeenChanged() {
                $string = 'asdf';
                $hash = 'myhash';
-               $this->assertFalse($this->hashService->validateHash($string, $hash));
+               $this->assertFalse($this->hashService->validateHmac($string, $hash));
        }
 
        /**