Skip to content

Commit 70d9751

Browse files
SystemKeeperbackportbot[bot]
authored andcommitted
test: Add PHP_AUTH_PW test for strict password confirmation
Signed-off-by: Marcel Müller <marcel-mueller@gmx.de>
1 parent e623f76 commit 70d9751

2 files changed

Lines changed: 34 additions & 0 deletions

File tree

tests/lib/AppFramework/Middleware/Security/Mock/PasswordConfirmationMiddlewareController.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,8 @@ public function testAttribute() {
3535
#[PasswordConfirmationRequired]
3636
public function testSSO() {
3737
}
38+
39+
#[PasswordConfirmationRequired(strict: true)]
40+
public function testAuthHeader() {
41+
}
3842
}

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

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,4 +202,34 @@ public function testSSO(): void {
202202

203203
$this->assertSame(false, $thrown);
204204
}
205+
206+
public function testAuthHeader(): void {
207+
$this->reflector->reflect($this->controller, __FUNCTION__);
208+
209+
$this->user->method('getBackendClassName')
210+
->willReturn('fictional_backend');
211+
$this->userSession->method('getUser')
212+
->willReturn($this->user);
213+
214+
$this->session->method('get')
215+
->with('loginname')
216+
->willReturn('user');
217+
218+
$this->request->method('getHeader')
219+
->with('PHP_AUTH_PW')
220+
->willReturn('password');
221+
222+
$this->userManager->expects($this->once())
223+
->method('checkPassword')
224+
->with('user', 'password');
225+
226+
$thrown = false;
227+
try {
228+
$this->middleware->beforeController($this->controller, __FUNCTION__);
229+
} catch (NotConfirmedException) {
230+
$thrown = true;
231+
}
232+
233+
$this->assertSame(false, $thrown);
234+
}
205235
}

0 commit comments

Comments
 (0)