-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Tests] Added REST integration coverage for NodeExtendedInfo endpoint
- Loading branch information
Showing
9 changed files
with
326 additions
and
0 deletions.
There are no files selected for viewing
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
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,71 @@ | ||
<?php | ||
|
||
/** | ||
* @copyright Copyright (C) Ibexa AS. All rights reserved. | ||
* @license For full copyright and license information view LICENSE file distributed with this source code. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace Ibexa\Tests\Integration\AdminUi\REST; | ||
|
||
use Ibexa\Contracts\Core\Repository\Values\User\Limitation\ContentTypeLimitation; | ||
use Ibexa\Contracts\Core\Repository\Values\User\Limitation\LanguageLimitation; | ||
use Ibexa\Contracts\Test\Rest\Request\Value\EndpointRequestDefinition; | ||
|
||
/** | ||
* Coverage for /location/tree/{locationId}/extended-info REST endpoint. | ||
*/ | ||
final class GetContentTreeExtendedInfoTest extends BaseAdminUiRestWebTestCase | ||
{ | ||
/** | ||
* @throws \Ibexa\Contracts\Core\Repository\Exceptions\NotFoundException | ||
* @throws \Ibexa\Contracts\Core\Repository\Exceptions\UnauthorizedException | ||
* @throws \Ibexa\Contracts\Core\Repository\Exceptions\ForbiddenException | ||
*/ | ||
protected function setUp(): void | ||
{ | ||
parent::setUp(); | ||
|
||
// to create a new user before logging-in via REST | ||
$this->getIbexaTestCore()->setAdministratorUser(); | ||
|
||
$this->loginAsUser( | ||
$this->createUserWithPolicies( | ||
'editor', | ||
[ | ||
'user/login' => [], | ||
'content/read' => [], | ||
'content/create' => [ | ||
new ContentTypeLimitation( | ||
['limitationValues' => ['1', '16']] | ||
), | ||
new LanguageLimitation( | ||
['limitationValues' => ['eng-GB', 'eng-US']] | ||
), | ||
], | ||
'content/edit' => [ | ||
new LanguageLimitation( | ||
['limitationValues' => ['eng-GB']] | ||
), | ||
], | ||
] | ||
) | ||
); | ||
} | ||
|
||
protected static function getEndpointsToTest(): iterable | ||
{ | ||
foreach (self::REQUIRED_FORMATS as $format) { | ||
yield new EndpointRequestDefinition( | ||
'GET', | ||
'/api/ibexa/v2/location/tree/2/extended-info', | ||
'ContentTreeNodeExtendedInfo', | ||
"application/vnd.ibexa.api.ContentTreeNodeExtendedInfo+$format", | ||
['HTTP_X-SiteAccess' => 'admin'], | ||
null, | ||
null, | ||
'ContentTreeNodeExtendedInfo' | ||
); | ||
} | ||
} | ||
} |
67 changes: 67 additions & 0 deletions
67
tests/integration/Resources/REST/Schemas/ContentTreeNodeExtendedInfo.json
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,67 @@ | ||
{ | ||
"$schema": "http://json-schema.org/draft-04/schema#", | ||
"type": "object", | ||
"properties": { | ||
"ContentTreeNodeExtendedInfo": { | ||
"type": "object", | ||
"properties": { | ||
"_media-type": { | ||
"type": "string" | ||
}, | ||
"permissions": { | ||
"type": "array", | ||
"items": { | ||
"type": "object", | ||
"properties": { | ||
"_name": { | ||
"type": "string" | ||
}, | ||
"hasAccess": { | ||
"type": "boolean" | ||
}, | ||
"restrictedContentTypeIdsList": { | ||
"type": "object", | ||
"properties": { | ||
"restrictedContentTypeIds": { | ||
"type": "array", | ||
"items": { | ||
"type": "string" | ||
} | ||
} | ||
}, | ||
"required": [ | ||
"restrictedContentTypeIds" | ||
] | ||
}, | ||
"restrictedLanguageCodesList": { | ||
"type": "object", | ||
"properties": { | ||
"restrictedLanguageCodes": { | ||
"type": "array", | ||
"items": { | ||
"type": "string" | ||
} | ||
} | ||
}, | ||
"required": [ | ||
"restrictedLanguageCodes" | ||
] | ||
} | ||
}, | ||
"required": [ | ||
"_name", | ||
"hasAccess" | ||
] | ||
} | ||
} | ||
}, | ||
"required": [ | ||
"_media-type", | ||
"permissions" | ||
] | ||
} | ||
}, | ||
"required": [ | ||
"ContentTreeNodeExtendedInfo" | ||
] | ||
} |
33 changes: 33 additions & 0 deletions
33
tests/integration/Resources/REST/Schemas/ContentTreeNodeExtendedInfo.xsd
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,33 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<!-- Created with Liquid Technologies Online Tools 1.0 (https://www.liquid-technologies.com) --> | ||
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema"> | ||
<xs:element name="ContentTreeNodeExtendedInfo"> | ||
<xs:complexType> | ||
<xs:sequence> | ||
<xs:element maxOccurs="unbounded" name="function"> | ||
<xs:complexType> | ||
<xs:sequence> | ||
<xs:element name="hasAccess" type="xs:boolean" /> | ||
<xs:element minOccurs="0" name="restrictedContentTypeIdsList"> | ||
<xs:complexType> | ||
<xs:sequence> | ||
<xs:element maxOccurs="unbounded" name="value" type="xs:unsignedByte" /> | ||
</xs:sequence> | ||
</xs:complexType> | ||
</xs:element> | ||
<xs:element minOccurs="0" name="restrictedLanguageCodesList"> | ||
<xs:complexType> | ||
<xs:sequence> | ||
<xs:element maxOccurs="unbounded" name="value" type="xs:string" /> | ||
</xs:sequence> | ||
</xs:complexType> | ||
</xs:element> | ||
</xs:sequence> | ||
<xs:attribute name="name" type="xs:string" use="required" /> | ||
</xs:complexType> | ||
</xs:element> | ||
</xs:sequence> | ||
<xs:attribute name="media-type" type="xs:string" use="required" /> | ||
</xs:complexType> | ||
</xs:element> | ||
</xs:schema> |
40 changes: 40 additions & 0 deletions
40
tests/integration/Resources/REST/Snapshots/ContentTreeNodeExtendedInfo.json
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,40 @@ | ||
{ | ||
"ContentTreeNodeExtendedInfo": { | ||
"_media-type": "application\/vnd.ibexa.api.ContentTreeNodeExtendedInfo+json", | ||
"permissions": [ | ||
{ | ||
"_name": "create", | ||
"hasAccess": true, | ||
"restrictedContentTypeIdsList": { | ||
"restrictedContentTypeIds": [ | ||
"1", | ||
"16" | ||
] | ||
}, | ||
"restrictedLanguageCodesList": { | ||
"restrictedLanguageCodes": [ | ||
"eng-GB", | ||
"eng-US" | ||
] | ||
} | ||
}, | ||
{ | ||
"_name": "edit", | ||
"hasAccess": true, | ||
"restrictedLanguageCodesList": { | ||
"restrictedLanguageCodes": [ | ||
"eng-GB" | ||
] | ||
} | ||
}, | ||
{ | ||
"_name": "delete", | ||
"hasAccess": false | ||
}, | ||
{ | ||
"_name": "hide", | ||
"hasAccess": false | ||
} | ||
] | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
tests/integration/Resources/REST/Snapshots/ContentTreeNodeExtendedInfo.xml
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,26 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<ContentTreeNodeExtendedInfo media-type="application/vnd.ibexa.api.ContentTreeNodeExtendedInfo+xml"> | ||
<function name="create"> | ||
<hasAccess>true</hasAccess> | ||
<restrictedContentTypeIdsList> | ||
<value>1</value> | ||
<value>16</value> | ||
</restrictedContentTypeIdsList> | ||
<restrictedLanguageCodesList> | ||
<value>eng-GB</value> | ||
<value>eng-US</value> | ||
</restrictedLanguageCodesList> | ||
</function> | ||
<function name="edit"> | ||
<hasAccess>true</hasAccess> | ||
<restrictedLanguageCodesList> | ||
<value>eng-GB</value> | ||
</restrictedLanguageCodesList> | ||
</function> | ||
<function name="delete"> | ||
<hasAccess>false</hasAccess> | ||
</function> | ||
<function name="hide"> | ||
<hasAccess>false</hasAccess> | ||
</function> | ||
</ContentTreeNodeExtendedInfo> |