summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoeland Jago Douma <roeland@famdouma.nl>2018-01-25 16:10:38 +0100
committerRoeland Jago Douma <roeland@famdouma.nl>2018-01-29 14:37:18 +0100
commit7405dfb5447a324b2f5504b3a540c8d35b0b21cb (patch)
tree6e729b562a8fd1ed050c0d19175f05aed7adb314
parentc0adfa437548a10a0542b6d36ab20011ddfdb93e (diff)
downloadnextcloud-server-7405dfb5447a324b2f5504b3a540c8d35b0b21cb.tar.gz
nextcloud-server-7405dfb5447a324b2f5504b3a540c8d35b0b21cb.zip
Update tests
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
-rw-r--r--tests/lib/AppFramework/Middleware/Security/SecurityMiddlewareTest.php28
1 files changed, 20 insertions, 8 deletions
diff --git a/tests/lib/AppFramework/Middleware/Security/SecurityMiddlewareTest.php b/tests/lib/AppFramework/Middleware/Security/SecurityMiddlewareTest.php
index b68f0cb1981..e36bd727bea 100644
--- a/tests/lib/AppFramework/Middleware/Security/SecurityMiddlewareTest.php
+++ b/tests/lib/AppFramework/Middleware/Security/SecurityMiddlewareTest.php
@@ -387,11 +387,15 @@ class SecurityMiddlewareTest extends \Test\TestCase {
->getMock();
return [
- [$controller, false, true],
- [$controller, true, true],
-
- [$ocsController, false, true],
- [$ocsController, true, false],
+ [$controller, false, false, true],
+ [$controller, false, true, true],
+ [$controller, true, false, true],
+ [$controller, true, true, true],
+
+ [$ocsController, false, false, true],
+ [$ocsController, false, true, false],
+ [$ocsController, true, false, false],
+ [$ocsController, true, true, false],
];
}
@@ -399,13 +403,21 @@ class SecurityMiddlewareTest extends \Test\TestCase {
* @dataProvider dataCsrfOcsController
* @param Controller $controller
* @param bool $hasOcsApiHeader
+ * @param bool $hasBearerAuth
* @param bool $exception
*/
- public function testCsrfOcsController(Controller $controller, $hasOcsApiHeader, $exception) {
+ public function testCsrfOcsController(Controller $controller, bool $hasOcsApiHeader, bool $hasBearerAuth, bool $exception) {
$this->request
->method('getHeader')
- ->with('OCS-APIREQUEST')
- ->willReturn($hasOcsApiHeader ? 'true' : null);
+ ->will(self::returnCallback(function ($header) use ($hasOcsApiHeader, $hasBearerAuth) {
+ if ($header === 'OCS-APIREQUEST' && $hasOcsApiHeader) {
+ return 'true';
+ }
+ if ($header === 'Authorization' && $hasBearerAuth) {
+ return 'Bearer TOKEN!';
+ }
+ return '';
+ }));
$this->request->expects($this->once())
->method('passesStrictCookieCheck')
->willReturn(true);