[tests-only]test: add test for shared with me (#8010)
* test: add test for shared with me * test: add test for shared with me shared file * add missing field and add test to expected to fail * address review * test: move file * tests: make differente funtion for regex fileid pattern matching
This commit is contained in:
@@ -67,6 +67,27 @@ class GraphHelper {
|
|||||||
return self::getUUIDv4Regex() . ':' . self::getUUIDv4Regex() . ':' . self::getUUIDv4Regex();
|
return self::getUUIDv4Regex() . ':' . self::getUUIDv4Regex() . ':' . self::getUUIDv4Regex();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public static function getFileIdRegex(): string {
|
||||||
|
return self::getUUIDv4Regex() . '\\\$' . self::getUUIDv4Regex() . '!' . self::getUUIDv4Regex();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public static function getShareIdRegex(): string {
|
||||||
|
return self::getUUIDv4Regex() . '\\\$' . self::getUUIDv4Regex() . '!' . self::getUUIDv4Regex() . ':' . self::getUUIDv4Regex() . ':' . self::getUUIDv4Regex();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public static function getEtagRegex(): string {
|
||||||
|
return "^\\\"[a-f0-9:.]{1,32}\\\"$";
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Key name can consist of @@@
|
* Key name can consist of @@@
|
||||||
* This function separate such key and return its actual value from actual drive response which can be used for assertion
|
* This function separate such key and return its actual value from actual drive response which can be used for assertion
|
||||||
|
|||||||
@@ -0,0 +1,476 @@
|
|||||||
|
Feature: an user gets the resources shared to them
|
||||||
|
As a user
|
||||||
|
I want to get resources shared with me
|
||||||
|
So that I can know about what resources I have access to
|
||||||
|
|
||||||
|
https://owncloud.dev/libre-graph-api/#/me.drive/ListSharedWithMe
|
||||||
|
|
||||||
|
Background:
|
||||||
|
Given these users have been created with default attributes and without skeleton files:
|
||||||
|
| username |
|
||||||
|
| Alice |
|
||||||
|
| Brian |
|
||||||
|
|
||||||
|
|
||||||
|
Scenario: user lists the file shared with them
|
||||||
|
Given user "Alice" has uploaded file with content "hello world" to "/textfile0.txt"
|
||||||
|
And user "Alice" has shared file "textfile0.txt" with user "Brian"
|
||||||
|
When user "Brian" lists the resources shared with him using the Graph API
|
||||||
|
Then the HTTP status code should be "200"
|
||||||
|
And the JSON data of the response should match
|
||||||
|
"""
|
||||||
|
{
|
||||||
|
"type": "object",
|
||||||
|
"required": [
|
||||||
|
"value"
|
||||||
|
],
|
||||||
|
"properties": {
|
||||||
|
"value": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"type": "object",
|
||||||
|
"required": [
|
||||||
|
"createdBy",
|
||||||
|
"eTag",
|
||||||
|
"file",
|
||||||
|
"id",
|
||||||
|
"lastModifiedDateTime",
|
||||||
|
"name",
|
||||||
|
"parentReference",
|
||||||
|
"remoteItem"
|
||||||
|
],
|
||||||
|
"properties": {
|
||||||
|
"createdBy": {
|
||||||
|
"type": "object",
|
||||||
|
"required": [
|
||||||
|
"user"
|
||||||
|
],
|
||||||
|
"properties": {
|
||||||
|
"user": {
|
||||||
|
"type": "object",
|
||||||
|
"required": ["displayName", "id"],
|
||||||
|
"properties": {
|
||||||
|
"displayName": {
|
||||||
|
"type": "string",
|
||||||
|
"enum": ["Alice Hansen"]
|
||||||
|
},
|
||||||
|
"id": {
|
||||||
|
"type": "string",
|
||||||
|
"pattern": "^%user_id_pattern%$"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"eTag": {
|
||||||
|
"type": "string",
|
||||||
|
"pattern": "%eTag%"
|
||||||
|
},
|
||||||
|
"file": {
|
||||||
|
"type": "object",
|
||||||
|
"required": ["mimeType"],
|
||||||
|
"properties": {
|
||||||
|
"mimeType": {
|
||||||
|
"type": "string",
|
||||||
|
"enum": ["text/plain"]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"id": {
|
||||||
|
"type": "string",
|
||||||
|
"pattern": "^%share_id_pattern%$"
|
||||||
|
},
|
||||||
|
"name": {
|
||||||
|
"type": "string",
|
||||||
|
"enum": [
|
||||||
|
"textfile0.txt"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"parentReference": {
|
||||||
|
"type": "object",
|
||||||
|
"required": [
|
||||||
|
"driveId",
|
||||||
|
"driveType"
|
||||||
|
],
|
||||||
|
"properties": {
|
||||||
|
"driveId": {
|
||||||
|
"type": "string",
|
||||||
|
"pattern": "^%space_id_pattern%$"
|
||||||
|
},
|
||||||
|
"driveType" : {
|
||||||
|
"type": "string",
|
||||||
|
"enum": ["virtual"]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"remoteItem": {
|
||||||
|
"type": "object",
|
||||||
|
"required": [
|
||||||
|
"createdBy",
|
||||||
|
"eTag",
|
||||||
|
"file",
|
||||||
|
"id",
|
||||||
|
"lastModifiedDateTime",
|
||||||
|
"name",
|
||||||
|
"parentReference",
|
||||||
|
"permissions",
|
||||||
|
"shared",
|
||||||
|
"size"
|
||||||
|
],
|
||||||
|
"properties": {
|
||||||
|
"createdBy": {
|
||||||
|
"type": "object",
|
||||||
|
"required": [
|
||||||
|
"user"
|
||||||
|
],
|
||||||
|
"properties": {
|
||||||
|
"user": {
|
||||||
|
"type": "object",
|
||||||
|
"required": [
|
||||||
|
"id",
|
||||||
|
"displayName"
|
||||||
|
],
|
||||||
|
"properties": {
|
||||||
|
"id": {
|
||||||
|
"type": "string",
|
||||||
|
"pattern": "^%user_id_pattern%$"
|
||||||
|
},
|
||||||
|
"displayName": {
|
||||||
|
"type": "string",
|
||||||
|
"enum": [
|
||||||
|
"Alice Hansen"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"eTag": {
|
||||||
|
"type": "string",
|
||||||
|
"pattern": "%eTag%"
|
||||||
|
},
|
||||||
|
"file": {
|
||||||
|
"type": "object",
|
||||||
|
"required": [
|
||||||
|
"mimeType"
|
||||||
|
],
|
||||||
|
"properties": {
|
||||||
|
"mimeType": {
|
||||||
|
"type": "string",
|
||||||
|
"pattern": "text/plain"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"id": {
|
||||||
|
"type": "string",
|
||||||
|
"pattern": "^%file_id_pattern%$"
|
||||||
|
},
|
||||||
|
"name": {
|
||||||
|
"type": "string",
|
||||||
|
"enum": [
|
||||||
|
"textfile0.txt"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"shared": {
|
||||||
|
"type": "object",
|
||||||
|
"required": [
|
||||||
|
"sharedBy",
|
||||||
|
"owner"
|
||||||
|
],
|
||||||
|
"properties": {
|
||||||
|
"owner": {
|
||||||
|
"type": "object",
|
||||||
|
"required": [
|
||||||
|
"user"
|
||||||
|
],
|
||||||
|
"properties": {
|
||||||
|
"user": {
|
||||||
|
"type": "object",
|
||||||
|
"required": [
|
||||||
|
"id",
|
||||||
|
"displayName"
|
||||||
|
],
|
||||||
|
"properties": {
|
||||||
|
"id": {
|
||||||
|
"type": "string",
|
||||||
|
"pattern": "^%user_id_pattern%$"
|
||||||
|
},
|
||||||
|
"displayName": {
|
||||||
|
"type": "string",
|
||||||
|
"enum": [
|
||||||
|
"Alice Hansen"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"sharedBy": {
|
||||||
|
"type": "object",
|
||||||
|
"required": [
|
||||||
|
"user"
|
||||||
|
],
|
||||||
|
"properties": {
|
||||||
|
"user": {
|
||||||
|
"type": "object",
|
||||||
|
"required": [
|
||||||
|
"id",
|
||||||
|
"displayName"
|
||||||
|
],
|
||||||
|
"properties": {
|
||||||
|
"id": {
|
||||||
|
"type": "string",
|
||||||
|
"pattern": "^%user_id_pattern%$"
|
||||||
|
},
|
||||||
|
"displayName": {
|
||||||
|
"type": "string",
|
||||||
|
"enum": [
|
||||||
|
"Alice Hansen"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"size": {
|
||||||
|
"type": "number",
|
||||||
|
"enum": [
|
||||||
|
11
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
Scenario: user lists the folder shared with them
|
||||||
|
Given user "Alice" has created folder "folder"
|
||||||
|
And user "Alice" has shared folder "folder" with user "Brian"
|
||||||
|
When user "Brian" lists the resources shared with him using the Graph API
|
||||||
|
Then the HTTP status code should be "200"
|
||||||
|
And the JSON data of the response should match
|
||||||
|
"""
|
||||||
|
{
|
||||||
|
"type": "object",
|
||||||
|
"required": [
|
||||||
|
"value"
|
||||||
|
],
|
||||||
|
"properties": {
|
||||||
|
"value": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"type": "object",
|
||||||
|
"required": [
|
||||||
|
"createdBy",
|
||||||
|
"eTag",
|
||||||
|
"folder",
|
||||||
|
"id",
|
||||||
|
"lastModifiedDateTime",
|
||||||
|
"name",
|
||||||
|
"parentReference",
|
||||||
|
"remoteItem"
|
||||||
|
],
|
||||||
|
"properties": {
|
||||||
|
"createdBy": {
|
||||||
|
"type": "object",
|
||||||
|
"required": [
|
||||||
|
"user"
|
||||||
|
],
|
||||||
|
"properties": {
|
||||||
|
"user": {
|
||||||
|
"type": "object",
|
||||||
|
"required": ["displayName", "id"],
|
||||||
|
"properties": {
|
||||||
|
"displayName": {
|
||||||
|
"type": "string",
|
||||||
|
"enum": ["Alice Hansen"]
|
||||||
|
},
|
||||||
|
"id": {
|
||||||
|
"type": "string",
|
||||||
|
"pattern": "^%user_id_pattern%$"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"eTag": {
|
||||||
|
"type": "string",
|
||||||
|
"pattern": "%eTag%"
|
||||||
|
},
|
||||||
|
"folder": {
|
||||||
|
"type": "object",
|
||||||
|
"required": [],
|
||||||
|
"properties": {}
|
||||||
|
},
|
||||||
|
"id": {
|
||||||
|
"type": "string",
|
||||||
|
"pattern": "^%share_id_pattern%$"
|
||||||
|
},
|
||||||
|
"name": {
|
||||||
|
"type": "string",
|
||||||
|
"enum": [
|
||||||
|
"folder"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"parentReference": {
|
||||||
|
"type": "object",
|
||||||
|
"required": [
|
||||||
|
"driveId",
|
||||||
|
"driveType"
|
||||||
|
],
|
||||||
|
"properties": {
|
||||||
|
"driveId": {
|
||||||
|
"type": "string",
|
||||||
|
"pattern": "^%space_id_pattern%$"
|
||||||
|
},
|
||||||
|
"driveType" : {
|
||||||
|
"type": "string",
|
||||||
|
"enum": ["virtual"]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"remoteItem": {
|
||||||
|
"type": "object",
|
||||||
|
"required": [
|
||||||
|
"createdBy",
|
||||||
|
"eTag",
|
||||||
|
"folder",
|
||||||
|
"id",
|
||||||
|
"lastModifiedDateTime",
|
||||||
|
"name",
|
||||||
|
"parentReference",
|
||||||
|
"permissions",
|
||||||
|
"shared"
|
||||||
|
],
|
||||||
|
"properties": {
|
||||||
|
"createdBy": {
|
||||||
|
"type": "object",
|
||||||
|
"required": [
|
||||||
|
"user"
|
||||||
|
],
|
||||||
|
"properties": {
|
||||||
|
"user": {
|
||||||
|
"type": "object",
|
||||||
|
"required": [
|
||||||
|
"id",
|
||||||
|
"displayName"
|
||||||
|
],
|
||||||
|
"properties": {
|
||||||
|
"id": {
|
||||||
|
"type": "string",
|
||||||
|
"pattern": "^%user_id_pattern%$"
|
||||||
|
},
|
||||||
|
"displayName": {
|
||||||
|
"type": "string",
|
||||||
|
"enum": [
|
||||||
|
"Alice Hansen"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"eTag": {
|
||||||
|
"type": "string",
|
||||||
|
"pattern": "%eTag%"
|
||||||
|
},
|
||||||
|
"file": {
|
||||||
|
"type": "object",
|
||||||
|
"required": [
|
||||||
|
"mimeType"
|
||||||
|
],
|
||||||
|
"properties": {
|
||||||
|
"mimeType": {
|
||||||
|
"type": "string",
|
||||||
|
"pattern": "text/plain"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"id": {
|
||||||
|
"type": "string",
|
||||||
|
"pattern": "^%file_id_pattern%$"
|
||||||
|
},
|
||||||
|
"name": {
|
||||||
|
"type": "string",
|
||||||
|
"enum": [
|
||||||
|
"folder"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"shared": {
|
||||||
|
"type": "object",
|
||||||
|
"required": [
|
||||||
|
"sharedBy",
|
||||||
|
"owner"
|
||||||
|
],
|
||||||
|
"properties": {
|
||||||
|
"owner": {
|
||||||
|
"type": "object",
|
||||||
|
"required": [
|
||||||
|
"user"
|
||||||
|
],
|
||||||
|
"properties": {
|
||||||
|
"user": {
|
||||||
|
"type": "object",
|
||||||
|
"required": [
|
||||||
|
"id",
|
||||||
|
"displayName"
|
||||||
|
],
|
||||||
|
"properties": {
|
||||||
|
"id": {
|
||||||
|
"type": "string",
|
||||||
|
"pattern": "^%user_id_pattern%$"
|
||||||
|
},
|
||||||
|
"displayName": {
|
||||||
|
"type": "string",
|
||||||
|
"enum": [
|
||||||
|
"Alice Hansen"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"sharedBy": {
|
||||||
|
"type": "object",
|
||||||
|
"required": [
|
||||||
|
"user"
|
||||||
|
],
|
||||||
|
"properties": {
|
||||||
|
"user": {
|
||||||
|
"type": "object",
|
||||||
|
"required": [
|
||||||
|
"id",
|
||||||
|
"displayName"
|
||||||
|
],
|
||||||
|
"properties": {
|
||||||
|
"id": {
|
||||||
|
"type": "string",
|
||||||
|
"pattern": "^%user_id_pattern%$"
|
||||||
|
},
|
||||||
|
"displayName": {
|
||||||
|
"type": "string",
|
||||||
|
"enum": [
|
||||||
|
"Alice Hansen"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
"""
|
||||||
@@ -2799,6 +2799,30 @@ class FeatureContext extends BehatVariablesContext {
|
|||||||
"getPermissionsIdRegex"
|
"getPermissionsIdRegex"
|
||||||
],
|
],
|
||||||
"parameter" => []
|
"parameter" => []
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"code" => "%file_id_pattern%",
|
||||||
|
"function" => [
|
||||||
|
__NAMESPACE__ . '\TestHelpers\GraphHelper',
|
||||||
|
"getFileIdRegex"
|
||||||
|
],
|
||||||
|
"parameter" => []
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"code" => "%share_id_pattern%",
|
||||||
|
"function" => [
|
||||||
|
__NAMESPACE__ . '\TestHelpers\GraphHelper',
|
||||||
|
"getShareIdRegex"
|
||||||
|
],
|
||||||
|
"parameter" => []
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"code" => "%eTag%",
|
||||||
|
"function" => [
|
||||||
|
__NAMESPACE__ . '\TestHelpers\GraphHelper',
|
||||||
|
"getEtagRegex"
|
||||||
|
],
|
||||||
|
"parameter" => []
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
if ($user !== null) {
|
if ($user !== null) {
|
||||||
|
|||||||
@@ -2505,4 +2505,24 @@ class GraphContext implements Context {
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @When user :user lists the resources shared with him/her using the Graph API
|
||||||
|
*
|
||||||
|
* @param string $user
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
* @throws GuzzleException
|
||||||
|
*/
|
||||||
|
public function userListsTheResourcesSharedWithThemUsingGraphApi(string $user): void {
|
||||||
|
$credentials = $this->getAdminOrUserCredentials($user);
|
||||||
|
$this->featureContext->setResponse(
|
||||||
|
GraphHelper::getSharesSharedWithMe(
|
||||||
|
$this->featureContext->getBaseUrl(),
|
||||||
|
$this->featureContext->getStepLineRef(),
|
||||||
|
$credentials['username'],
|
||||||
|
$credentials['password']
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user