Skip to content

Commit a900309

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 b7de544 commit a900309

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

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

0 commit comments

Comments
 (0)