forked from components-web-app/api-components-bundle
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'components-web-app:main' into feature/components-web-ap…
…p#113-additional-tests
- Loading branch information
Showing
48 changed files
with
1,696 additions
and
918 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
php_version: 8.0 | ||
php_version: 8.1 | ||
rules: | ||
doctrine.public_doctrine_property: | ||
enabled: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,10 +3,18 @@ | |
"type": "symfony-bundle", | ||
"description": "Creates a flexible API for a website's structure, reusable components and common functionality.", | ||
"license": "MIT", | ||
"homepage": "https://cwa.rocks", | ||
"authors": [ | ||
{ | ||
"name": "Daniel West", | ||
"email": "[email protected]", | ||
"homepage": "https://silverback.is" | ||
} | ||
], | ||
"repositories": [ | ||
{ | ||
"type": "vcs", | ||
"url": "https://github.com/silverbackdan/contexts" | ||
"type": "git", | ||
"url": "git@github.com:silverbackdan/contexts.git" | ||
} | ||
], | ||
"require": { | ||
|
@@ -16,7 +24,7 @@ | |
"ext-json": "*", | ||
"ext-pdo": "*", | ||
"ext-simplexml": "*", | ||
"api-platform/core": "^3.0", | ||
"api-platform/core": "^3.0.3", | ||
"cocur/slugify": "^4.1", | ||
"doctrine/annotations": "^1.7.0", | ||
"doctrine/dbal": "^3.4", | ||
|
@@ -80,6 +88,7 @@ | |
"symfony/http-client": "^6.1", | ||
"symfony/maker-bundle": "^1.0", | ||
"symfony/mercure-bundle": "^0.3.4", | ||
"symfony/messenger": "^6.1", | ||
"symfony/monolog-bundle": "^3.8", | ||
"symfony/phpunit-bridge": "^6.1.3", | ||
"symfony/stopwatch": "^6.1", | ||
|
@@ -128,6 +137,7 @@ | |
"willdurand/negotiation": "^2", | ||
"symfony/proxy-manager-bridge": "<5.4", | ||
"symfony/serializer": "<=6.1.2", | ||
"symfony/var-exporter": "<6.1", | ||
"symfony/web-link": "<=6.0", | ||
"doctrine/collections": "<1.7", | ||
"doctrine/orm": "<2.13" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
Feature: Mercure authorization cookies and messages are published | ||
In order to restrict access to draft components | ||
As a an application developer | ||
I must be able to configure the ability to access the resource | ||
|
||
Background: | ||
Given I add "Accept" header equal to "application/ld+json" | ||
And I add "Content-Type" header equal to "application/ld+json" | ||
|
||
Scenario: A Mercure authorization cookie is set WITHOUT topic draft access | ||
When I send a "GET" request to "/docs.jsonld" | ||
Then the response status code should be 200 | ||
And the response should have a "mercureAuthorization" cookie | ||
And the mercure cookie should not contain draft resource topics | ||
|
||
@loginAdmin | ||
Scenario: A Mercure authorization cookie is set WITH topic draft access | ||
When I send a "GET" request to "/docs.jsonld" | ||
Then the response status code should be 200 | ||
And the response should have a "mercureAuthorization" cookie | ||
And the mercure cookie should contain draft resource topics |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Silverback API Components Bundle Project | ||
* | ||
* (c) Daniel West <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Silverback\ApiComponentsBundle\ApiPlatform\Api; | ||
|
||
use ApiPlatform\Api\IriConverterInterface; | ||
use ApiPlatform\Api\UrlGeneratorInterface; | ||
use ApiPlatform\Metadata\Operation; | ||
use Silverback\ApiComponentsBundle\Helper\Publishable\PublishableStatusChecker; | ||
|
||
/** | ||
* @author Daniel West <[email protected]> | ||
*/ | ||
class MercureIriConverter implements IriConverterInterface | ||
{ | ||
public function __construct(private IriConverterInterface $decorated, private PublishableStatusChecker $publishableStatusChecker) | ||
{ | ||
} | ||
|
||
public function getResourceFromIri(string $iri, array $context = [], ?Operation $operation = null): object | ||
{ | ||
return $this->decorated->getResourceFromIri($iri, $context, $operation); | ||
} | ||
|
||
public function getIriFromResource($resource, int $referenceType = UrlGeneratorInterface::ABS_PATH, ?Operation $operation = null, array $context = []): ?string | ||
{ | ||
$iri = $this->decorated->getIriFromResource($resource, $referenceType, $operation, $context); | ||
|
||
if (\is_string($resource)) { | ||
return $iri; | ||
} | ||
|
||
if ($this->publishableStatusChecker->getAnnotationReader()->isConfigured($resource) && !$this->publishableStatusChecker->isActivePublishedAt($resource)) { | ||
$iri .= '?draft=1'; | ||
} | ||
|
||
return $iri; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.