@@ -387,25 +387,37 @@ public function dataCsrfOcsController() {
387387 ->getMock ();
388388
389389 return [
390- [$ controller , false , true ],
391- [$ controller , true , true ],
392-
393- [$ ocsController , false , true ],
394- [$ ocsController , true , false ],
390+ [$ controller , false , false , true ],
391+ [$ controller , false , true , true ],
392+ [$ controller , true , false , true ],
393+ [$ controller , true , true , true ],
394+
395+ [$ ocsController , false , false , true ],
396+ [$ ocsController , false , true , false ],
397+ [$ ocsController , true , false , false ],
398+ [$ ocsController , true , true , false ],
395399 ];
396400 }
397401
398402 /**
399403 * @dataProvider dataCsrfOcsController
400404 * @param Controller $controller
401405 * @param bool $hasOcsApiHeader
406+ * @param bool $hasBearerAuth
402407 * @param bool $exception
403408 */
404- public function testCsrfOcsController (Controller $ controller , $ hasOcsApiHeader , $ exception ) {
409+ public function testCsrfOcsController (Controller $ controller , bool $ hasOcsApiHeader , bool $ hasBearerAuth , bool $ exception ) {
405410 $ this ->request
406411 ->method ('getHeader ' )
407- ->with ('OCS-APIREQUEST ' )
408- ->willReturn ($ hasOcsApiHeader ? 'true ' : null );
412+ ->will (self ::returnCallback (function ($ header ) use ($ hasOcsApiHeader , $ hasBearerAuth ) {
413+ if ($ header === 'OCS-APIREQUEST ' && $ hasOcsApiHeader ) {
414+ return 'true ' ;
415+ }
416+ if ($ header === 'Authorization ' && $ hasBearerAuth ) {
417+ return 'Bearer TOKEN! ' ;
418+ }
419+ return '' ;
420+ }));
409421 $ this ->request ->expects ($ this ->once ())
410422 ->method ('passesStrictCookieCheck ' )
411423 ->willReturn (true );
0 commit comments