Skip to content

Commit ee7ef88

Browse files
committed
Merge branch '2.4'
2 parents b350647 + 9ad81f8 commit ee7ef88

File tree

13 files changed

+51
-47
lines changed

13 files changed

+51
-47
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ high performance API-first projects. Extend or override everything you want.
1111

1212
[![Build Status](https://travis-ci.org/api-platform/core.svg?branch=master)](https://travis-ci.org/api-platform/core)
1313
[![Build status](https://ci.appveyor.com/api/projects/status/grwuyprts3wdqx5l?svg=true)](https://ci.appveyor.com/project/dunglas/dunglasapibundle)
14-
[![Coverage Status](https://coveralls.io/repos/github/api-platform/core/badge.svg)](https://coveralls.io/github/api-platform/core)
14+
[![codecov](https://codecov.io/gh/api-platform/core/branch/master/graph/badge.svg)](https://codecov.io/gh/api-platform/core)
1515
[![SymfonyInsight](https://insight.symfony.com/projects/92d78899-946c-4282-89a3-ac92344f9a93/mini.svg)](https://insight.symfony.com/projects/92d78899-946c-4282-89a3-ac92344f9a93)
1616
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/api-platform/core/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/api-platform/core/?branch=master)
1717

features/security/validate_incoming_content-types.feature

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@ Feature: Validate incoming content type
1111
"""
1212
something
1313
"""
14-
Then the response status code should be 406
14+
Then the response status code should be 415
1515
And the header "Content-Type" should be equal to "application/ld+json; charset=utf-8"
1616
And the JSON node "hydra:description" should be equal to 'The content-type "text/plain" is not supported. Supported MIME types are "application/ld+json", "application/hal+json", "application/vnd.api+json", "application/xml", "text/xml", "application/json", "text/html".'

src/Bridge/Symfony/Bundle/Resources/public/init-swagger-ui.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use strict';
22

3-
window.onload = () => {
3+
window.onload = function() {
44
manageWebbyDisplay();
55

66
new MutationObserver(function (mutations, self) {

src/EventListener/DeserializeListener.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
use ApiPlatform\Core\Util\RequestAttributesExtractor;
2323
use Symfony\Component\HttpFoundation\Request;
2424
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
25-
use Symfony\Component\HttpKernel\Exception\NotAcceptableHttpException;
25+
use Symfony\Component\HttpKernel\Exception\UnsupportedMediaTypeHttpException;
2626
use Symfony\Component\Serializer\Normalizer\AbstractNormalizer;
2727
use Symfony\Component\Serializer\SerializerInterface;
2828

@@ -65,6 +65,8 @@ public function __construct(SerializerInterface $serializer, SerializerContextBu
6565

6666
/**
6767
* Deserializes the data sent in the requested format.
68+
*
69+
* @throws UnsupportedMediaTypeHttpException
6870
*/
6971
public function onKernelRequest(GetResponseEvent $event): void
7072
{
@@ -104,7 +106,7 @@ public function onKernelRequest(GetResponseEvent $event): void
104106
/**
105107
* Extracts the format from the Content-Type header and check that it is supported.
106108
*
107-
* @throws NotAcceptableHttpException
109+
* @throws UnsupportedMediaTypeHttpException
108110
*/
109111
private function getFormat(Request $request): string
110112
{
@@ -113,7 +115,7 @@ private function getFormat(Request $request): string
113115
*/
114116
$contentType = $request->headers->get('CONTENT_TYPE');
115117
if (null === $contentType) {
116-
throw new NotAcceptableHttpException('The "Content-Type" header must exist.');
118+
throw new UnsupportedMediaTypeHttpException('The "Content-Type" header must exist.');
117119
}
118120

119121
$format = $this->formatMatcher->getFormat($contentType);
@@ -125,7 +127,7 @@ private function getFormat(Request $request): string
125127
}
126128
}
127129

128-
throw new NotAcceptableHttpException(sprintf(
130+
throw new UnsupportedMediaTypeHttpException(sprintf(
129131
'The content-type "%s" is not supported. Supported MIME types are "%s".',
130132
$contentType,
131133
implode('", "', $supportedMimeTypes)

src/Identifier/CompositeIdentifierParser.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public static function parse(string $identifier): array
3333
{
3434
$matches = [];
3535
$identifiers = [];
36-
$num = preg_match_all('/(\w+)=(?<=\w=)(.+?)(?=;\w+=)|(\w+)=([^;]+);?$/', $identifier, $matches, PREG_SET_ORDER);
36+
$num = preg_match_all('/(\w+)=(?<=\w=)(.*?)(?=;\w+=)|(\w+)=([^;]*);?$/', $identifier, $matches, PREG_SET_ORDER);
3737

3838
foreach ($matches as $i => $match) {
3939
if ($i === $num - 1) {

tests/Annotation/ApiResourceTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class ApiResourceTest extends TestCase
2727
public function testConstruct()
2828
{
2929
$resource = new ApiResource([
30-
'accessControl' => 'has_role("ROLE_FOO")',
30+
'accessControl' => 'is_granted("ROLE_FOO")',
3131
'accessControlMessage' => 'You are not foo.',
3232
'attributes' => ['foo' => 'bar', 'validation_groups' => ['baz', 'qux'], 'cache_headers' => ['max_age' => 0, 'shared_max_age' => 0, 'vary' => ['Custom-Vary-1', 'Custom-Vary-2']]],
3333
'collectionOperations' => ['bar' => ['foo']],
@@ -71,7 +71,7 @@ public function testConstruct()
7171
$this->assertSame([], $resource->subresourceOperations);
7272
$this->assertSame(['query' => ['normalization_context' => ['groups' => ['foo', 'bar']]]], $resource->graphql);
7373
$this->assertEquals([
74-
'access_control' => 'has_role("ROLE_FOO")',
74+
'access_control' => 'is_granted("ROLE_FOO")',
7575
'access_control_message' => 'You are not foo.',
7676
'denormalization_context' => ['groups' => ['foo']],
7777
'fetch_partial' => true,
@@ -118,7 +118,7 @@ public function testApiResourceAnnotation()
118118
$this->assertEquals([
119119
'foo' => 'bar',
120120
'route_prefix' => '/whatever',
121-
'access_control' => "has_role('ROLE_FOO')",
121+
'access_control' => "is_granted('ROLE_FOO')",
122122
'access_control_message' => 'You are not foo.',
123123
'cache_headers' => ['max_age' => 0, 'shared_max_age' => 0, 'vary' => ['Custom-Vary-1', 'Custom-Vary-2']],
124124
], $resource->attributes);

tests/EventListener/DeserializeListenerTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
use Prophecy\Argument;
2424
use Symfony\Component\HttpFoundation\Request;
2525
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
26-
use Symfony\Component\HttpKernel\Exception\NotAcceptableHttpException;
26+
use Symfony\Component\HttpKernel\Exception\UnsupportedMediaTypeHttpException;
2727
use Symfony\Component\Serializer\Normalizer\AbstractNormalizer;
2828
use Symfony\Component\Serializer\SerializerInterface;
2929

@@ -227,7 +227,7 @@ public function testContentNegotiation()
227227

228228
public function testNotSupportedContentType()
229229
{
230-
$this->expectException(NotAcceptableHttpException::class);
230+
$this->expectException(UnsupportedMediaTypeHttpException::class);
231231
$this->expectExceptionMessage('The content-type "application/rdf+xml" is not supported. Supported MIME types are "application/ld+json", "text/xml".');
232232

233233
$eventProphecy = $this->prophesize(GetResponseEvent::class);
@@ -257,7 +257,7 @@ public function testNotSupportedContentType()
257257

258258
public function testNoContentType()
259259
{
260-
$this->expectException(NotAcceptableHttpException::class);
260+
$this->expectException(UnsupportedMediaTypeHttpException::class);
261261
$this->expectExceptionMessage('The "Content-Type" header must exist.');
262262

263263
$eventProphecy = $this->prophesize(GetResponseEvent::class);

tests/Fixtures/AnnotatedClass.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
* graphql={"query"={"normalization_context"={"groups"={"foo", "bar"}}}},
2626
* attributes={"foo"="bar", "route_prefix"="/whatever", "cache_headers"={"max_age"=0, "shared_max_age"=0, "vary"={"Custom-Vary-1", "Custom-Vary-2"}}},
2727
* routePrefix="/foo",
28-
* accessControl="has_role('ROLE_FOO')",
28+
* accessControl="is_granted('ROLE_FOO')",
2929
* accessControlMessage="You are not foo."
3030
* )
3131
*

tests/Fixtures/TestBundle/Document/SecuredDummy.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,20 +24,20 @@
2424
* @author Alan Poulain <[email protected]>
2525
*
2626
* @ApiResource(
27-
* attributes={"access_control"="has_role('ROLE_USER')"},
27+
* attributes={"access_control"="is_granted('ROLE_USER')"},
2828
* collectionOperations={
2929
* "get",
30-
* "post"={"access_control"="has_role('ROLE_ADMIN')"}
30+
* "post"={"access_control"="is_granted('ROLE_ADMIN')"}
3131
* },
3232
* itemOperations={
33-
* "get"={"access_control"="has_role('ROLE_USER') and object.getOwner() == user"},
34-
* "put"={"access_control"="has_role('ROLE_USER') and previous_object.getOwner() == user"},
33+
* "get"={"access_control"="is_granted('ROLE_USER') and object.getOwner() == user"},
34+
* "put"={"access_control"="is_granted('ROLE_USER') and previous_object.getOwner() == user"},
3535
* },
3636
* graphql={
37-
* "query"={"access_control"="has_role('ROLE_USER') and object.getOwner() == user"},
37+
* "query"={"access_control"="is_granted('ROLE_USER') and object.getOwner() == user"},
3838
* "delete"={},
39-
* "update"={"access_control"="has_role('ROLE_USER') and previous_object.getOwner() == user"},
40-
* "create"={"access_control"="has_role('ROLE_ADMIN')", "access_control_message"="Only admins can create a secured dummy."}
39+
* "update"={"access_control"="is_granted('ROLE_USER') and previous_object.getOwner() == user"},
40+
* "create"={"access_control"="is_granted('ROLE_ADMIN')", "access_control_message"="Only admins can create a secured dummy."}
4141
* }
4242
* )
4343
* @ODM\Document

tests/Fixtures/TestBundle/Entity/SecuredDummy.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,20 +23,20 @@
2323
* @author Kévin Dunglas <[email protected]>
2424
*
2525
* @ApiResource(
26-
* attributes={"access_control"="has_role('ROLE_USER')"},
26+
* attributes={"access_control"="is_granted('ROLE_USER')"},
2727
* collectionOperations={
2828
* "get",
29-
* "post"={"access_control"="has_role('ROLE_ADMIN')"}
29+
* "post"={"access_control"="is_granted('ROLE_ADMIN')"}
3030
* },
3131
* itemOperations={
32-
* "get"={"access_control"="has_role('ROLE_USER') and object.getOwner() == user"},
33-
* "put"={"access_control"="has_role('ROLE_USER') and previous_object.getOwner() == user"},
32+
* "get"={"access_control"="is_granted('ROLE_USER') and object.getOwner() == user"},
33+
* "put"={"access_control"="is_granted('ROLE_USER') and previous_object.getOwner() == user"},
3434
* },
3535
* graphql={
36-
* "query"={"access_control"="has_role('ROLE_USER') and object.getOwner() == user"},
36+
* "query"={"access_control"="is_granted('ROLE_USER') and object.getOwner() == user"},
3737
* "delete"={},
38-
* "update"={"access_control"="has_role('ROLE_USER') and previous_object.getOwner() == user"},
39-
* "create"={"access_control"="has_role('ROLE_ADMIN')", "access_control_message"="Only admins can create a secured dummy."}
38+
* "update"={"access_control"="is_granted('ROLE_USER') and previous_object.getOwner() == user"},
39+
* "create"={"access_control"="is_granted('ROLE_ADMIN')", "access_control_message"="Only admins can create a secured dummy."}
4040
* }
4141
* )
4242
* @ORM\Entity

0 commit comments

Comments
 (0)