Skip to content

Commit d6d0619

Browse files
committed
cors
1 parent 04a7e77 commit d6d0619

File tree

9 files changed

+22
-32
lines changed

9 files changed

+22
-32
lines changed

composer.json

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,6 @@
2121
"daycry/cronjob": "^2.0",
2222
"daycry/settings": "^1"
2323
},
24-
"repositories": [
25-
{
26-
"type": "vcs",
27-
"url" : "git@ssh.dev.azure.com:v3/ImaginaDEVOPS/MEDIAPRO%20-%20Equipo%20Desarrollo/AzureOauthServer"
28-
},
29-
{
30-
"type": "git",
31-
"url": "https://github.com/abraham/phpunit-testlistener-vcr"
32-
}
33-
],
3424
"require-dev":
3525
{
3626
"codeigniter4/devkit": "^1",

phpstan.neon.dist

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ parameters:
2525
- '#Call to deprecated method getMethod\(\) of class CodeIgniter\\HTTP\\Request:#'
2626
- '#Call to deprecated method getStatusCode\(\) of class CodeIgniter\\HTTP\\ResponseInterface:#'
2727
- '#Negated boolean expression is always true.#'
28+
- '#class CodeIgniter\\HTTP\\Request constructor expects Config\\App#'
29+
- '#class CodeIgniter\\HTTP\\Response constructor expects Config\\App#'
2830
universalObjectCratesClasses:
2931
- CodeIgniter\Entity
3032
- CodeIgniter\Entity\Entity

src/Config/RestFul.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ class RestFul extends BaseConfig
254254
* @var boolean
255255
*/
256256
public $supportsCredentials = false;
257-
257+
258258
/**
259259
* --------------------------------------------------------------------------
260260
* Enable block Invalid Attempts

src/Config/Routes.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22

33
/** @var \CodeIgniter\Router\RouteCollection $routes */
44

5-
$routes->options('(:any)', '', ['filter' => 'cors']);
5+
$routes->options('(:any)', '', ['filter' => 'cors']);

src/Filters/CorsFilter.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,13 @@
1010
class CorsFilter implements FilterInterface
1111
{
1212
/**
13-
* @var \Fluent\Cors\ServiceCors $cors
13+
* @var \Daycry\RestFul\Libraries\Cors $cors
1414
*/
1515
protected $cors;
1616

1717
/**
1818
* Constructor.
1919
*
20-
* @param array $options
2120
* @return void
2221
*/
2322
public function __construct()
@@ -55,4 +54,4 @@ public function after(RequestInterface $request, ResponseInterface $response, $a
5554

5655
return $response;
5756
}
58-
}
57+
}

src/Libraries/Cors.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public function __construct(?RestFul $config = null)
4242
}
4343

4444
/**
45-
* @param array|CorsInputOptions $options
45+
* @param RestFul $config
4646
*/
4747
public function setOptions(RestFul $config): void
4848
{
@@ -257,4 +257,4 @@ public function varyHeader(ResponseInterface $response, string $header): Respons
257257

258258
return $response;
259259
}
260-
}
260+
}

src/Validators/Cors.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace Daycry\RestFul\Validators;
44

5-
use Config\Services;
5+
use Daycry\RestFul\Config\Services;
66
use CodeIgniter\HTTP\ResponseInterface;
77

88
class Cors

tests/Filters/CorsTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public function testCorsSuccess(): void
3232

3333
$request = service('request');
3434
$request->setHeader('Origin', 'https://test-cors1.local');
35-
35+
3636
Services::injectMock('request', $request);
3737

3838
$result = $this->call('get', 'example-filter');
@@ -48,13 +48,13 @@ public function testCorsError(): void
4848

4949
$request = service('request');
5050
$request->setHeader('Origin', 'https://test-cors1.local');
51-
51+
5252
Services::injectMock('request', $request);
5353

5454
$result = $this->call('get', 'example-filter');
5555

5656
$response = Services::response();
57-
57+
5858
$this->assertNotEquals(
5959
'https://test-cors1.local',
6060
$response->getHeaderLine('Access-Control-Allow-Origin')
@@ -64,7 +64,7 @@ public function testCorsError(): void
6464
$result->assertHeaderMissing('Access-Control-Allow-Credentials');
6565
}
6666

67-
67+
6868

6969
protected function tearDown(): void
7070
{

tests/Validators/CorsTest.php

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ protected function request()
3232
return new Request(Factories::config('App'));
3333
}
3434

35-
/** @var Response */
3635
protected function response()
3736
{
3837
return new Response(Factories::config('App'));
@@ -62,7 +61,7 @@ public function testIsPreflightRequest()
6261
->withMethod('OPTIONS')
6362
->setHeader('Access-Control-Request-Method', 'GET');
6463

65-
$cors = new Cors(config('RestFul'));
64+
$cors = new Cors(config('RestFul'));
6665

6766
$this->assertTrue($cors->isPreflightRequest($request));
6867
}
@@ -72,7 +71,7 @@ public function testIsNotPreflightRequest()
7271
$request = $this->request()->withMethod('GET')
7372
->setHeader('Access-Control-Request-Method', 'GET');
7473

75-
$cors = new Cors(config('RestFul'));
74+
$cors = new Cors(config('RestFul'));
7675

7776
$this->assertFalse($cors->isPreflightRequest($request));
7877
}
@@ -82,22 +81,22 @@ public function testVaryHeader()
8281
$response = $this->response()
8382
->setHeader('Vary', 'Access-Control-Request-Method');
8483

85-
$cors = new Cors(config('RestFul'));
84+
$cors = new Cors(config('RestFul'));
8685

8786
$vary = $cors->varyHeader($response, 'Access-Control-Request-Method');
8887

8988
$this->assertEquals($response->getHeaderLine('Vary'), $vary->getHeaderLine('Vary'));
9089
}
91-
90+
9291
public function testHandlePreflightRequest()
9392
{
9493
$request = $this->request()
9594
->withMethod('OPTIONS')
9695
->setHeader('Origin', 'http://foobar.com')
9796
->setHeader('Access-Control-Request-Method', 'GET')
9897
->setHeader('Access-Control-Request-Headers', 'X-CSRF-TOKEN');
99-
100-
$cors = new Cors(config('RestFul'));
98+
99+
$cors = new Cors(config('RestFul'));
101100

102101
$expected = $cors->handlePreflightRequest($request);
103102

@@ -123,7 +122,7 @@ public function testHandleRequest()
123122
$response = $this->response()
124123
->setHeader('Access-Control-Allow-Origin', $request->getHeaderLine('Origin'));
125124

126-
$cors = new Cors(config('RestFul'));
125+
$cors = new Cors(config('RestFul'));
127126

128127
$expected = $cors->addPreflightRequestHeaders($response, $request);
129128

@@ -242,7 +241,7 @@ public function testHandlePreflightRequestWithExposeHeadersNotSet()
242241
->setHeader('Origin', 'http://foo.com')
243242
->setHeader('Access-Control-Request-Headers', 'X-CSRF-TOKEN');
244243

245-
$cors = new Cors(config('RestFul'));
244+
$cors = new Cors(config('RestFul'));
246245

247246
$expeted = $cors->addPreflightRequestHeaders($this->response(), $request);
248247

@@ -311,4 +310,4 @@ protected function tearDown(): void
311310
{
312311
parent::tearDown();
313312
}
314-
}
313+
}

0 commit comments

Comments
 (0)