Skip to content

Commit 739f9d9

Browse files
test(AppFramework): split out exempt cases - PasswordConfirmationMiddleware
Signed-off-by: Josh <josh.t.richards@gmail.com>
1 parent 274adbc commit 739f9d9

1 file changed

Lines changed: 29 additions & 7 deletions

File tree

tests/lib/AppFramework/Middleware/Security/PasswordConfirmationMiddlewareTest.php

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ public function testDifferentAnnotation(): void {
9393
$this->middleware->beforeController($this->controller, __FUNCTION__);
9494
}
9595

96-
#[\PHPUnit\Framework\Attributes\DataProvider('dataProvider')]
96+
#[\PHPUnit\Framework\Attributes\DataProvider('dataProviderNonExemptBackend')]
9797
public function testAnnotation($backend, $lastConfirm, $currentTime, $exception): void {
9898
$this->reflector->reflect($this->controller, __FUNCTION__);
9999

@@ -126,7 +126,7 @@ public function testAnnotation($backend, $lastConfirm, $currentTime, $exception)
126126
$this->assertSame($exception, $thrown);
127127
}
128128

129-
#[\PHPUnit\Framework\Attributes\DataProvider('dataProvider')]
129+
#[\PHPUnit\Framework\Attributes\DataProvider('dataProviderNonExemptBackend')]
130130
public function testAttribute($backend, $lastConfirm, $currentTime, $exception): void {
131131
$this->reflector->reflect($this->controller, __FUNCTION__);
132132

@@ -159,19 +159,41 @@ public function testAttribute($backend, $lastConfirm, $currentTime, $exception):
159159
$this->assertSame($exception, $thrown);
160160
}
161161

162-
163-
164-
public static function dataProvider(): array {
162+
public static function dataProviderNonExemptBackend(): array {
165163
return [
166164
['foo', 2000, 4000, true],
167165
['foo', 2000, 3000, false],
168-
['user_saml', 2000, 4000, false],
169-
['user_saml', 2000, 3000, false],
170166
['foo', 2000, 3815, false],
171167
['foo', 2000, 3816, true],
172168
];
173169
}
174170

171+
/**
172+
* @dataProvider dataProviderLegacyExemptBackends
173+
*/
174+
#[\PHPUnit\Framework\Attributes\DataProvider('dataProviderLegacyExemptBackends')]
175+
public function testLegacyBackendExempt(string $backend): void {
176+
$this->reflector->reflect($this->controller, __FUNCTION__);
177+
178+
$this->user->method('getBackendClassName')
179+
->willReturn($backend);
180+
$this->userSession->method('getUser')
181+
->willReturn($this->user);
182+
183+
// Backend is exempt — getToken() must never be called
184+
$this->tokenProvider->expects($this->never())
185+
->method('getToken');
186+
187+
$this->middleware->beforeController($this->controller, __FUNCTION__);
188+
}
189+
190+
public static function dataProviderLegacyExemptBackends(): array {
191+
return [
192+
['user_saml'],
193+
['user_globalsiteselector'],
194+
];
195+
}
196+
175197
public function testSSO(): void {
176198
static $sessionId = 'mySession1d';
177199

0 commit comments

Comments
 (0)