[BUGFIX] Reset singletons in Extbase command
[Packages/TYPO3.CMS.git] / typo3 / sysext / core / Tests / Unit / Authentication / AbstractUserAuthenticationTest.php
1 <?php
2 namespace TYPO3\CMS\Core\Tests\Unit\Authentication;
3
4 /***************************************************************
5 * Copyright notice
6 *
7 * (c) 2011-2013 Helmut Hummel <helmut.hummel@typo3.org>
8 * All rights reserved
9 *
10 * This script is part of the TYPO3 project. The TYPO3 project is
11 * free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * The GNU General Public License can be found at
17 * http://www.gnu.org/copyleft/gpl.html.
18 *
19 * This script is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * This copyright notice MUST APPEAR in all copies of the script!
25 ***************************************************************/
26
27 /**
28 * Testcase for class \TYPO3\CMS\Core\Authentication\AbstractUserAuthentication
29 *
30 */
31 class AbstractUserAuthenticationTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
32
33 /**
34 * phpunit still needs some globals that are
35 * reconstructed before $backupGlobals is handled. Those
36 * important globals are handled in tearDown() directly.
37 *
38 * @var array
39 */
40 protected $globals = array();
41
42 public function setUp() {
43 $this->globals = array(
44 'TYPO3_LOADED_EXT' => serialize($GLOBALS['TYPO3_LOADED_EXT'])
45 );
46 }
47
48 public function tearDown() {
49 foreach ($this->globals as $key => $value) {
50 $GLOBALS[$key] = unserialize($value);
51 }
52 }
53
54 ////////////////////////////////////
55 // Tests concerning processLoginData
56 ////////////////////////////////////
57 public function processLoginDataProvider() {
58 return array(
59 'Backend login with securityLevel "normal"' => array(
60 'BE',
61 'normal',
62 'superchallenged',
63 array(
64 'status' => 'login',
65 'uname' => 'admin',
66 'uident' => 'password',
67 'chalvalue' => NULL
68 ),
69 array(
70 'status' => 'login',
71 'uname' => 'admin',
72 'uident' => '651219fccfbe0c9004c7196515d780ce',
73 'chalvalue' => NULL,
74 'uident_text' => 'password',
75 'uident_challenged' => '458203772635d38f05ca9e62d8237974',
76 'uident_superchallenged' => '651219fccfbe0c9004c7196515d780ce'
77 )
78 ),
79 'Backend login with securityLevel "superchallenged"' => array(
80 'BE',
81 'superchallenged',
82 'superchallenged',
83 array(
84 'status' => 'login',
85 'uname' => 'admin',
86 'uident' => '651219fccfbe0c9004c7196515d780ce',
87 'chalvalue' => NULL
88 ),
89 array(
90 'status' => 'login',
91 'uname' => 'admin',
92 'uident' => '651219fccfbe0c9004c7196515d780ce',
93 'chalvalue' => NULL,
94 'uident_text' => '',
95 'uident_challenged' => '',
96 'uident_superchallenged' => '651219fccfbe0c9004c7196515d780ce'
97 )
98 ),
99 'Frontend login with securityLevel "normal"' => array(
100 'FE',
101 'normal',
102 'normal',
103 array(
104 'status' => 'login',
105 'uname' => 'admin',
106 'uident' => 'password',
107 'chalvalue' => NULL
108 ),
109 array(
110 'status' => 'login',
111 'uname' => 'admin',
112 'uident' => 'password',
113 'chalvalue' => NULL,
114 'uident_text' => 'password',
115 'uident_challenged' => '458203772635d38f05ca9e62d8237974',
116 'uident_superchallenged' => '651219fccfbe0c9004c7196515d780ce'
117 )
118 ),
119 'Frontend login with securityLevel "challenged"' => array(
120 'FE',
121 'challenged',
122 'challenged',
123 array(
124 'status' => 'login',
125 'uname' => 'admin',
126 'uident' => '458203772635d38f05ca9e62d8237974',
127 'chalvalue' => NULL
128 ),
129 array(
130 'status' => 'login',
131 'uname' => 'admin',
132 'uident' => '458203772635d38f05ca9e62d8237974',
133 'chalvalue' => NULL,
134 'uident_text' => '',
135 'uident_challenged' => '458203772635d38f05ca9e62d8237974',
136 'uident_superchallenged' => ''
137 )
138 )
139 );
140 }
141
142 /**
143 * @test
144 * @dataProvider processLoginDataProvider
145 */
146 public function processLoginReturnsCorrectData($loginType, $passwordSubmissionStrategy, $passwordCompareStrategy, $originalData, $processedData) {
147 /** @var $mock \TYPO3\CMS\Core\Authentication\AbstractUserAuthentication */
148 $mock = $this->getMock('TYPO3\\CMS\\Core\\Authentication\\AbstractUserAuthentication', array('_dummy'));
149 $mock->security_level = $passwordCompareStrategy;
150 $mock->loginType = $loginType;
151 $this->assertEquals($mock->processLoginData($originalData, $passwordSubmissionStrategy), $processedData);
152 }
153
154 }
155
156 ?>