[BUGFIX] UnitTests create SQL error if openid is installed 90/28090/3
authorPhilipp Gampe <philipp.gampe@typo3.org>
Thu, 6 Mar 2014 02:07:16 +0000 (03:07 +0100)
committerWouter Wolters <typo3@wouterwolters.nl>
Thu, 6 Mar 2014 21:33:09 +0000 (22:33 +0100)
AbstractUserAuthenticationTest is actually supposed to test
processLoginData from AuthenticationService from ext:sv.
However it fails to properly setup all auth parameters, therefore auth
services that depend on further settings fail.

This moves the test to the actually tested code (extension sv).
The test is adopted accordingly.

Additionally both tests are cleaned up from unneeded setUp/tearDown
functions.

Resolves: #56586
Releases: 6.2
Change-Id: I7406a56e5274ea54d400c1c116a8ea81c5cf4cea
Reviewed-on: https://review.typo3.org/28090
Reviewed-by: Markus Klein
Tested-by: Markus Klein
Reviewed-by: Wouter Wolters
Tested-by: Wouter Wolters
typo3/sysext/core/Build/UnitTests.xml
typo3/sysext/core/Tests/Unit/Authentication/AbstractUserAuthenticationTest.php
typo3/sysext/sv/Tests/Unit/AuthenticationServiceTest.php [new file with mode: 0644]

index 3fd0b95..49105b8 100644 (file)
@@ -75,6 +75,9 @@
                <testsuite name="EXT:scheduler tests">
                        <directory>../../../../typo3/sysext/scheduler/Tests/Unit/</directory>
                </testsuite>
+               <testsuite name="EXT:sv tests">
+                       <directory>../../../../typo3/sysext/sv/Tests/Unit/</directory>
+               </testsuite>
                <testsuite name="Suite integrity tests">
                        <directory>../../../../typo3/sysext/core/Tests/Integrity/</directory>
                </testsuite>
index 8df72aa..0138d9f 100644 (file)
@@ -31,123 +31,6 @@ namespace TYPO3\CMS\Core\Tests\Unit\Authentication;
 class AbstractUserAuthenticationTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
 
        /**
-        * phpunit still needs some globals that are
-        * reconstructed before $backupGlobals is handled. Those
-        * important globals are handled in tearDown() directly.
-        *
-        * @var array
-        */
-       protected $globals = array();
-
-       public function setUp() {
-               $this->globals = array(
-                       'TYPO3_LOADED_EXT' => serialize($GLOBALS['TYPO3_LOADED_EXT'])
-               );
-       }
-
-       public function tearDown() {
-               foreach ($this->globals as $key => $value) {
-                       $GLOBALS[$key] = unserialize($value);
-               }
-               parent::tearDown();
-       }
-
-       ////////////////////////////////////
-       // Tests concerning processLoginData
-       ////////////////////////////////////
-       public function processLoginDataProvider() {
-               return array(
-                       'Backend login with securityLevel "normal"' => array(
-                               'BE',
-                               'normal',
-                               array(
-                                       'status' => 'login',
-                                       'uname' => 'admin',
-                                       'uident' => 'password',
-                                       'chalvalue' => NULL
-                               ),
-                               array(
-                                       'status' => 'login',
-                                       'uname' => 'admin',
-                                       'uident' => 'password',
-                                       'chalvalue' => NULL,
-                                       'uident_text' => 'password',
-                                       'uident_challenged' => '458203772635d38f05ca9e62d8237974',
-                                       'uident_superchallenged' => '651219fccfbe0c9004c7196515d780ce'
-                               )
-                       ),
-                       'Backend login with securityLevel "superchallenged"' => array(
-                               'BE',
-                               'superchallenged',
-                               array(
-                                       'status' => 'login',
-                                       'uname' => 'admin',
-                                       'uident' => '651219fccfbe0c9004c7196515d780ce',
-                                       'chalvalue' => NULL
-                               ),
-                               array(
-                                       'status' => 'login',
-                                       'uname' => 'admin',
-                                       'uident' => '651219fccfbe0c9004c7196515d780ce',
-                                       'chalvalue' => NULL,
-                                       'uident_text' => '',
-                                       'uident_challenged' => '',
-                                       'uident_superchallenged' => '651219fccfbe0c9004c7196515d780ce'
-                               )
-                       ),
-                       'Frontend login with securityLevel "normal"' => array(
-                               'FE',
-                               'normal',
-                               array(
-                                       'status' => 'login',
-                                       'uname' => 'admin',
-                                       'uident' => 'password',
-                                       'chalvalue' => NULL
-                               ),
-                               array(
-                                       'status' => 'login',
-                                       'uname' => 'admin',
-                                       'uident' => 'password',
-                                       'chalvalue' => NULL,
-                                       'uident_text' => 'password',
-                                       'uident_challenged' => '458203772635d38f05ca9e62d8237974',
-                                       'uident_superchallenged' => '651219fccfbe0c9004c7196515d780ce'
-                               )
-                       ),
-                       'Frontend login with securityLevel "challenged"' => array(
-                               'FE',
-                               'challenged',
-                               array(
-                                       'status' => 'login',
-                                       'uname' => 'admin',
-                                       'uident' => '458203772635d38f05ca9e62d8237974',
-                                       'chalvalue' => NULL
-                               ),
-                               array(
-                                       'status' => 'login',
-                                       'uname' => 'admin',
-                                       'uident' => '458203772635d38f05ca9e62d8237974',
-                                       'chalvalue' => NULL,
-                                       'uident_text' => '',
-                                       'uident_challenged' => '458203772635d38f05ca9e62d8237974',
-                                       'uident_superchallenged' => ''
-                               )
-                       )
-               );
-       }
-
-       /**
-        * @test
-        * @dataProvider processLoginDataProvider
-        */
-       public function processLoginReturnsCorrectData($loginType, $passwordSubmissionStrategy, $originalData, $processedData) {
-               /** @var $mock \TYPO3\CMS\Core\Authentication\AbstractUserAuthentication */
-               $mock = $this->getMock('TYPO3\\CMS\\Core\\Authentication\\AbstractUserAuthentication', array('_dummy'));
-               $mock->loginType = $loginType;
-               $this->assertEquals($mock->processLoginData($originalData, $passwordSubmissionStrategy), $processedData);
-       }
-
-       /**
         * @test
         */
        public function getAuthInfoArrayReturnsEmptyPidListIfNoCheckPidValueIsGiven() {
diff --git a/typo3/sysext/sv/Tests/Unit/AuthenticationServiceTest.php b/typo3/sysext/sv/Tests/Unit/AuthenticationServiceTest.php
new file mode 100644 (file)
index 0000000..8bcf936
--- /dev/null
@@ -0,0 +1,127 @@
+<?php
+namespace TYPO3\CMS\Sv\Tests\Unit;
+
+/***************************************************************
+ *  Copyright notice
+ *
+ *  (c) 2011-2013 Helmut Hummel <helmut.hummel@typo3.org>
+ *  All rights reserved
+ *
+ *  This script is part of the TYPO3 project. The TYPO3 project is
+ *  free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  The GNU General Public License can be found at
+ *  http://www.gnu.org/copyleft/gpl.html.
+ *
+ *  This script is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  This copyright notice MUST APPEAR in all copies of the script!
+ ***************************************************************/
+
+/**
+ * Testcase for class \TYPO3\CMS\Sv\AuthenticationService
+ *
+ */
+class AuthenticationServiceTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
+
+       /**
+        * Date provider for processLoginReturnsCorrectData
+        *
+        * @return array
+        */
+       public function processLoginDataProvider() {
+               return array(
+                       'Backend login with securityLevel "normal"' => array(
+                               'normal',
+                               array(
+                                       'status' => 'login',
+                                       'uname' => 'admin',
+                                       'uident' => 'password',
+                                       'chalvalue' => NULL
+                               ),
+                               array(
+                                       'status' => 'login',
+                                       'uname' => 'admin',
+                                       'uident' => 'password',
+                                       'chalvalue' => NULL,
+                                       'uident_text' => 'password',
+                                       'uident_challenged' => '458203772635d38f05ca9e62d8237974',
+                                       'uident_superchallenged' => '651219fccfbe0c9004c7196515d780ce'
+                               )
+                       ),
+                       'Backend login with securityLevel "superchallenged"' => array(
+                               'superchallenged',
+                               array(
+                                       'status' => 'login',
+                                       'uname' => 'admin',
+                                       'uident' => '651219fccfbe0c9004c7196515d780ce',
+                                       'chalvalue' => NULL
+                               ),
+                               array(
+                                       'status' => 'login',
+                                       'uname' => 'admin',
+                                       'uident' => '651219fccfbe0c9004c7196515d780ce',
+                                       'chalvalue' => NULL,
+                                       'uident_text' => '',
+                                       'uident_challenged' => '',
+                                       'uident_superchallenged' => '651219fccfbe0c9004c7196515d780ce'
+                               )
+                       ),
+                       'Frontend login with securityLevel "normal"' => array(
+                               'normal',
+                               array(
+                                       'status' => 'login',
+                                       'uname' => 'admin',
+                                       'uident' => 'password',
+                                       'chalvalue' => NULL
+                               ),
+                               array(
+                                       'status' => 'login',
+                                       'uname' => 'admin',
+                                       'uident' => 'password',
+                                       'chalvalue' => NULL,
+                                       'uident_text' => 'password',
+                                       'uident_challenged' => '458203772635d38f05ca9e62d8237974',
+                                       'uident_superchallenged' => '651219fccfbe0c9004c7196515d780ce'
+                               )
+                       ),
+                       'Frontend login with securityLevel "challenged"' => array(
+                               'challenged',
+                               array(
+                                       'status' => 'login',
+                                       'uname' => 'admin',
+                                       'uident' => '458203772635d38f05ca9e62d8237974',
+                                       'chalvalue' => NULL
+                               ),
+                               array(
+                                       'status' => 'login',
+                                       'uname' => 'admin',
+                                       'uident' => '458203772635d38f05ca9e62d8237974',
+                                       'chalvalue' => NULL,
+                                       'uident_text' => '',
+                                       'uident_challenged' => '458203772635d38f05ca9e62d8237974',
+                                       'uident_superchallenged' => ''
+                               )
+                       )
+               );
+       }
+
+       /**
+        * @test
+        * @dataProvider processLoginDataProvider
+        */
+       public function processLoginReturnsCorrectData($passwordSubmissionStrategy, $loginData, $expectedProcessedData) {
+               /** @var $authenticationService \TYPO3\CMS\Sv\AuthenticationService */
+               $authenticationService = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Sv\\AuthenticationService');
+               // Login data is modified by reference
+               $authenticationService->processLoginData($loginData, $passwordSubmissionStrategy);
+               $this->assertEquals($expectedProcessedData, $loginData);
+       }
+
+}