Update tests
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
This commit is contained in:
parent
f1cd334281
commit
55d5868da5
|
@ -387,11 +387,15 @@ class SecurityMiddlewareTest extends \Test\TestCase {
|
||||||
->getMock();
|
->getMock();
|
||||||
|
|
||||||
return [
|
return [
|
||||||
[$controller, false, true],
|
[$controller, false, false, true],
|
||||||
[$controller, true, true],
|
[$controller, false, true, true],
|
||||||
|
[$controller, true, false, true],
|
||||||
|
[$controller, true, true, true],
|
||||||
|
|
||||||
[$ocsController, false, true],
|
[$ocsController, false, false, true],
|
||||||
[$ocsController, true, false],
|
[$ocsController, false, true, false],
|
||||||
|
[$ocsController, true, false, false],
|
||||||
|
[$ocsController, true, true, false],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -399,13 +403,21 @@ class SecurityMiddlewareTest extends \Test\TestCase {
|
||||||
* @dataProvider dataCsrfOcsController
|
* @dataProvider dataCsrfOcsController
|
||||||
* @param Controller $controller
|
* @param Controller $controller
|
||||||
* @param bool $hasOcsApiHeader
|
* @param bool $hasOcsApiHeader
|
||||||
|
* @param bool $hasBearerAuth
|
||||||
* @param bool $exception
|
* @param bool $exception
|
||||||
*/
|
*/
|
||||||
public function testCsrfOcsController(Controller $controller, $hasOcsApiHeader, $exception) {
|
public function testCsrfOcsController(Controller $controller, $hasOcsApiHeader, $hasBearerAuth, $exception) {
|
||||||
$this->request
|
$this->request
|
||||||
->method('getHeader')
|
->method('getHeader')
|
||||||
->with('OCS-APIREQUEST')
|
->will(self::returnCallback(function ($header) use ($hasOcsApiHeader, $hasBearerAuth) {
|
||||||
->willReturn($hasOcsApiHeader ? 'true' : null);
|
if ($header === 'OCS-APIREQUEST' && $hasOcsApiHeader) {
|
||||||
|
return 'true';
|
||||||
|
}
|
||||||
|
if ($header === 'Authorization' && $hasBearerAuth) {
|
||||||
|
return 'Bearer TOKEN!';
|
||||||
|
}
|
||||||
|
return '';
|
||||||
|
}));
|
||||||
$this->request->expects($this->once())
|
$this->request->expects($this->once())
|
||||||
->method('passesStrictCookieCheck')
|
->method('passesStrictCookieCheck')
|
||||||
->willReturn(true);
|
->willReturn(true);
|
||||||
|
|
Loading…
Reference in New Issue