diff --git a/tests/acceptance/features/apiSharingNg/createLink.feature b/tests/acceptance/features/apiSharingNg/createLink.feature index 99caaa33d9e..87a2f2b3f6a 100644 --- a/tests/acceptance/features/apiSharingNg/createLink.feature +++ b/tests/acceptance/features/apiSharingNg/createLink.feature @@ -6,13 +6,133 @@ Feature: Create a share link for a resource | username | | Alice | - - Scenario Outline: create a sharing link for a folder + Scenario Outline: create a sharing link for a folder with password enforced Given user "Alice" has created folder "folder" When user "Alice" creates a share link for a folder "folder" of the space "Personal" using the Graph API with settings: - | role | | - | password | L@mbu12345 | + | role | | + | password | %public% | + Then the HTTP status code should be "200" + And the JSON data of the response should match + """ + { + "type": "object", + "required": [ + "hasPassword", + "id", + "link" + ], + "properties": { + "hasPassword": { + "type": "boolean", + "enum": [true] + }, + "id": { + "type": "string", + "pattern": "^[a-zA-Z]{15}$" + }, + "link": { + "type": "object", + "required": [ + "@libre.graph.displayName", + "@libre.graph.quickLink", + "preventsDownload", + "type", + "webUrl" + ], + "properties": { + "@libre.graph.displayName": { + "type": "string", + "enum": [""] + }, + "@libre.graph.quickLink": { + "type": "boolean", + "enum": [false] + }, + "preventsDownload": { + "type": "boolean", + "enum": [false] + }, + "type": { + "type": "string", + "enum": [""] + }, + "webUrl": { + "type": "string", + "pattern": "^%base_url%\/s\/[a-zA-Z]{15}$" + } + } + } + } + } + """ + Examples: + | role | + | view | + | edit | + | upload | + | createOnly | + + + Scenario Outline: create a sharing link for a file with password enforced + Given user "Alice" has uploaded file with content "other data" to "/textfile1.txt" + When user "Alice" creates a share link for a file "textfile1.txt" of the space "Personal" using the Graph API with settings: + | role | | + | password | %public% | Then the HTTP status code should be "200" + And the JSON data of the response should match + """ + { + "type": "object", + "required": [ + "hasPassword", + "id", + "link" + ], + "properties": { + "hasPassword": { + "type": "boolean", + "enum": [true] + }, + "id": { + "type": "string", + "pattern": "^[a-zA-Z]{15}$" + }, + "link": { + "type": "object", + "required": [ + "@libre.graph.displayName", + "@libre.graph.quickLink", + "preventsDownload", + "type", + "webUrl" + ], + "properties": { + "@libre.graph.displayName": { + "type": "string", + "enum": [""] + }, + "@libre.graph.quickLink": { + "type": "boolean", + "enum": [false] + }, + "preventsDownload": { + "type": "boolean", + "enum": [false] + }, + "type": { + "type": "string", + "enum": [""] + }, + "webUrl": { + "type": "string", + "pattern": "^%base_url%\/s\/[a-zA-Z]{15}$" + } + } + } + } + } + """ Examples: - | role | - | view | + | role | + | view | + | edit | diff --git a/tests/acceptance/features/bootstrap/SharingNgContext.php b/tests/acceptance/features/bootstrap/SharingNgContext.php index 350d65a3a74..01e61e4f118 100644 --- a/tests/acceptance/features/bootstrap/SharingNgContext.php +++ b/tests/acceptance/features/bootstrap/SharingNgContext.php @@ -21,6 +21,7 @@ use Behat\Behat\Context\Context; use Behat\Behat\Hook\Scope\BeforeScenarioScope; +use PHPUnit\Framework\Assert; use TestHelpers\GraphHelper; require_once 'bootstrap.php'; @@ -101,9 +102,17 @@ public function userCreatesAPublicLinkShareWithSettings($user, $fileOrFolder, $r $itemId = $this->spacesContext->getFileId($user, $space, $resource); } $bodyRows = $body->getRowsHash(); + Assert::assertTrue( + \array_key_exists('password', $bodyRows), + '"Password" needs to be set by default while creating a share link' + ); + $bodyRows['displayName'] = \array_key_exists('displayName', $bodyRows) ? $bodyRows['displayName'] : null; + $bodyRows['expirationDateTime'] = \array_key_exists('expirationDateTime', $bodyRows) ? $bodyRows['expirationDateTime'] : null; $body = [ 'type' => $bodyRows['role'], - 'password' => $bodyRows['password'] + 'displayName' => $bodyRows['displayName'], + 'expirationDateTime' => $bodyRows['expirationDateTime'], + 'password' => $this->featureContext->getActualPassword($bodyRows['password']) ]; $this->featureContext->setResponse(