Skip to content

Commit 779dc1a

Browse files
committed
test: Add PHP_AUTH_PW test for strict password confirmation
Signed-off-by: Marcel Müller <marcel-mueller@gmx.de>
1 parent 2051c7b commit 779dc1a

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
@@ -213,4 +213,34 @@ public function testSSO(): void {
213213

214214
$this->assertSame(false, $thrown);
215215
}
216+
217+
public function testAuthHeader(): void {
218+
$this->reflector->reflect($this->controller, __FUNCTION__);
219+
220+
$this->user->method('getBackendClassName')
221+
->willReturn('fictional_backend');
222+
$this->userSession->method('getUser')
223+
->willReturn($this->user);
224+
225+
$this->session->method('get')
226+
->with('loginname')
227+
->willReturn('user');
228+
229+
$this->request->method('getHeader')
230+
->with('PHP_AUTH_PW')
231+
->willReturn('password');
232+
233+
$this->userManager->expects($this->once())
234+
->method('checkPassword')
235+
->with('user', 'password');
236+
237+
$thrown = false;
238+
try {
239+
$this->middleware->beforeController($this->controller, __FUNCTION__);
240+
} catch (NotConfirmedException) {
241+
$thrown = true;
242+
}
243+
244+
$this->assertSame(false, $thrown);
245+
}
216246
}

0 commit comments

Comments
 (0)