blob: 6dea993822546c74b00e634090a618805367954a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
<?php
/**
* SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\AppFramework\Controller;
use OC\AppFramework\Http\Request;
use OCP\AppFramework\ApiController;
use OCP\IConfig;
use OCP\IRequestId;
class ChildApiController extends ApiController {
};
class ApiControllerTest extends \Test\TestCase {
/** @var ChildApiController */
protected $controller;
public function testCors() {
$request = new Request(
['server' => ['HTTP_ORIGIN' => 'test']],
$this->createMock(IRequestId::class),
$this->createMock(IConfig::class)
);
$this->controller = new ChildApiController('app', $request, 'verbs',
'headers', 100);
$response = $this->controller->preflightedCors();
$headers = $response->getHeaders();
$this->assertEquals('test', $headers['Access-Control-Allow-Origin']);
$this->assertEquals('verbs', $headers['Access-Control-Allow-Methods']);
$this->assertEquals('headers', $headers['Access-Control-Allow-Headers']);
$this->assertEquals('false', $headers['Access-Control-Allow-Credentials']);
$this->assertEquals(100, $headers['Access-Control-Max-Age']);
}
}
|