Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions tests/acceptance/TestHelpers/GraphHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -1799,29 +1799,33 @@ public static function sendSharingInvitation(

/**
* @param string $baseUrl
* @param string $user
* @param string $password
* @param string|null $user
* @param string|null $password
* @param string $spaceId
* @param string $itemId
* @param mixed $body
* @param array $headers
* @param boolean $isVault
*
* @return ResponseInterface
* @throws GuzzleException
*/
public static function createLinkShare(
string $baseUrl,
string $user,
string $password,
?string $user,
?string $password,
string $spaceId,
string $itemId,
$body,
array $headers = [],
bool $isVault = false,
): ResponseInterface {
$url = self::getBetaFullUrl($baseUrl, "drives/$spaceId/items/$itemId/createLink");
$url = self::getBetaFullUrl($baseUrl, "drives/$spaceId/items/$itemId/createLink", $isVault);
return HttpRequestHelper::post(
$url,
$user,
$password,
self::getRequestHeaders(),
array_merge(self::getRequestHeaders(), $headers),
$body,
);
}
Expand Down
19 changes: 16 additions & 3 deletions tests/acceptance/bootstrap/SharingNgContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,15 @@ public function before(BeforeScenarioScope $scope): void {
public function createLinkShare(string $user, TableNode $body): ResponseInterface {
$bodyRows = $body->getRowsHash();
$resource = $bodyRows['resource'] ?? "";
$isVault = isset($bodyRows['storage']) && $bodyRows['storage'] === 'vault';

$space = $this->spacesContext->getSpaceByName($user, $bodyRows['space']);
$space = $this->spacesContext->getSpaceByName($user, $bodyRows['space'], $isVault);
$spaceId = $space['id'];

if ($resource === '' && !\in_array($bodyRows['space'], ['Personal', 'Shares'])) {
$itemId = $space['fileId'];
} else {
$itemId = $this->spacesContext->getResourceId($user, $bodyRows['space'], $resource);
$itemId = $this->spacesContext->getResourceId($user, $bodyRows['space'], $resource, $isVault);
}

$bodyRows['quickLink'] = $bodyRows['quickLink'] ?? false;
Expand All @@ -97,13 +98,25 @@ public function createLinkShare(string $user, TableNode $body): ResponseInterfac
'password' => $this->featureContext->getActualPassword($bodyRows['password']),
];

$headers = [];
if (KeycloakHelper::isTestingWithKeycloak()) {
$accessToken = $this->featureContext->getOcisUserToken($user)['token']['accessToken'];
$headers['Authorization'] = 'Bearer ' . $accessToken;
$user = null;
$password = null;
} else {
$password = $this->featureContext->getPasswordForUser($user);
}

$response = GraphHelper::createLinkShare(
$this->featureContext->getBaseUrl(),
$user,
$this->featureContext->getPasswordForUser($user),
$password,
$spaceId,
$itemId,
\json_encode($body),
$headers,
$isVault,
);

if ($response->getStatusCode() == 200) {
Expand Down
117 changes: 117 additions & 0 deletions tests/acceptance/features/apiVault/vault.feature
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,123 @@ Feature: vault
| testfile.txt |


Scenario: user tries to create a public link of a folder inside vault
Given user "Alice" has logged in via web UI
And user "Alice" has created a folder "vaultFolder" in space "Personal" in vault
When user "Alice" creates the following resource link share using the Graph API:
| resource | vaultFolder |
| space | Personal |
| permissionsRole | View |
| storage | vault |
Then the HTTP status code should be "400"
And the JSON data of the response should match
"""
{
"type": "object",
"required": ["error"],
"properties": {
"error": {
"type": "object",
"required": ["code", "innererror", "message"],
"properties": {
"code": {
"const": "invalidRequest"
},
"innererror": {
"type": "object",
"required": [
"date",
"request-id"
]
},
"message": {
"const": "public links are not allowed for vault resources"
}
}
}
}
}
"""


Scenario: user tries to create a public link of a file inside vault
Given user "Alice" has logged in via web UI
And user "Alice" has uploaded a file inside space "Personal" with content "some content" to "testfile.txt" in vault
When user "Alice" creates the following resource link share using the Graph API:
| resource | testfile.txt |
| space | Personal |
| permissionsRole | View |
| storage | vault |
Then the HTTP status code should be "400"
And the JSON data of the response should match
"""
{
"type": "object",
"required": ["error"],
"properties": {
"error": {
"type": "object",
"required": ["code", "innererror", "message"],
"properties": {
"code": {
"const": "invalidRequest"
},
"innererror": {
"type": "object",
"required": [
"date",
"request-id"
]
},
"message": {
"const": "public links are not allowed for vault resources"
}
}
}
}
}
"""


Scenario: user tries to create a public link of a space root inside vault
Given the administrator has assigned the role "Space Admin" to user "Alice" using the Graph API
And user "Alice" has logged in via web UI
And user "Alice" has created a space "vault-space" in vault with the default quota using the Graph API
When user "Alice" tries to create the following space link share using permissions endpoint of the Graph API:
| space | vault-space |
| permissionsRole | View |
| storage | vault |
Then the HTTP status code should be "400"
And the JSON data of the response should match
"""
{
"type": "object",
"required": ["error"],
"properties": {
"error": {
"type": "object",
"required": ["code", "innererror", "message"],
"properties": {
"code": {
"const": "invalidRequest"
},
"innererror": {
"type": "object",
"required": [
"date",
"request-id"
]
},
"message": {
"const": "public links are not allowed for vault resources"
}
}
}
}
}
"""


Scenario Outline: send share invitation for project space in vault to user with different roles (permissions endpoint)
Given the administrator has assigned the role "Space Admin" to user "Alice" using the Graph API
And user "Alice" has logged in via web UI
Expand Down
Loading