Skip to content

Commit

Permalink
Added implementation for createLink file and folders
Browse files Browse the repository at this point in the history
  • Loading branch information
SagarGi committed Dec 19, 2023
1 parent 261618b commit 63b5506
Show file tree
Hide file tree
Showing 2 changed files with 136 additions and 7 deletions.
132 changes: 126 additions & 6 deletions tests/acceptance/features/apiSharingNg/createLink.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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 | <role> |
| password | L@mbu12345 |
| role | <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": ["<role>"]
},
"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 | <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": ["<role>"]
},
"webUrl": {
"type": "string",
"pattern": "^%base_url%\/s\/[a-zA-Z]{15}$"
}
}
}
}
}
"""
Examples:
| role |
| view |
| role |
| view |
| edit |
11 changes: 10 additions & 1 deletion tests/acceptance/features/bootstrap/SharingNgContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit 63b5506

Please sign in to comment.