[BUGFIX] Fix fatal in RsaAuth-PhpBackendTest with broken openssl config 97/35597/2
authorStephan Großberndt <stephan@grossberndt.de>
Wed, 17 Dec 2014 01:19:31 +0000 (02:19 +0100)
committerChristian Kuhn <lolli@schwarzbu.ch>
Sat, 20 Dec 2014 09:43:47 +0000 (10:43 +0100)
If the openssl environment is not set up correctly (in Install Tool:
"PHP OpenSSL extension not working") the unit test
TYPO3\CMS\Rsaauth\Tests\Unit\Backend\PhpBackendTest causes a fatal PHP
error "Call to a member function isReady() on a non-object". This
happens because $this->subject->createNewKeyPair() returns NULL if
something goes wrong while setting up a openssl keypair.

Assert the keypair is not null before calling $keypair->isReady().

Resolves: #63948
Releases: master, 6.2
Change-Id: Iffde2b7eafe160d387568d08f627a2bb9852f32f
Reviewed-on: http://review.typo3.org/35597
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
typo3/sysext/rsaauth/Tests/Unit/Backend/PhpBackendTest.php

index 9944191..cb43b24 100644 (file)
@@ -35,18 +35,21 @@ class PhpBackendTest extends \TYPO3\CMS\Core\Tests\UnitTestCase  {
         * @test
         */
        public function createNewKeyPairCreatesReadyKeyPair() {
-               $this->assertTrue(
-                       $this->subject->createNewKeyPair()->isReady()
-               );
+               $keyPair = $this->subject->createNewKeyPair();
+               $this->assertNotNull($keyPair, 'Test fails because of broken environment: PHP OpenSSL extension is not working properly.');
+               $this->assertTrue($keyPair->isReady());
        }
 
        /**
         * @test
         */
        public function createNewKeyPairCalledTwoTimesReturnsSameKeyPairInstance() {
+               $keyPair1 = $this->subject->createNewKeyPair();
+               $this->assertNotNull($keyPair1, 'Test fails because of broken environment: PHP OpenSSL extension is not working properly.');
                $this->assertSame(
-                       $this->subject->createNewKeyPair(),
+                       $keyPair1,
                        $this->subject->createNewKeyPair()
                );
        }
+
 }
\ No newline at end of file