Skip to content

Commit 9c2ae17

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 6e22e67 commit 9c2ae17

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

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

0 commit comments

Comments
 (0)