adding test for sharedWithMe endpoint for resource in project space (#8292)

This commit is contained in:
nirajacharya2
2024-03-01 15:36:51 +05:45
committed by GitHub
parent a77f121c89
commit fb1d93342c
2 changed files with 898 additions and 2 deletions
@@ -3539,3 +3539,891 @@ Feature: an user gets the resources shared to them
}
}
"""
Scenario: user lists the file shared with them from project space
Given using spaces DAV path
And the administrator has assigned the role "Space Admin" to user "Alice" using the Graph API
And user "Alice" has created a space "new-space" with the default quota using the Graph API
And user "Alice" has uploaded a file inside space "new-space" with content "some content" to "testfile.txt"
And user "Alice" has sent the following share invitation:
| resource | testfile.txt |
| space | new-space |
| sharee | Brian |
| shareType | user |
| permissionsRole | Viewer |
When user "Brian" lists the shares 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",
"maxItems": 1,
"minItems": 1,
"items": {
"type": "object",
"required": [
"@UI.Hidden",
"@client.synchronize",
"eTag",
"file",
"id",
"lastModifiedDateTime",
"name",
"parentReference",
"remoteItem",
"size"
],
"properties": {
"@UI.Hidden":{
"const": false
},
"@client.synchronize":{
"const": true
},
"eTag": {
"type": "string",
"pattern": "%etag_pattern%"
},
"file": {
"type": "object",
"required": ["mimeType"],
"properties": {
"mimeType": {
"type": "string",
"pattern": "^text/plain"
}
}
},
"id": {
"type": "string",
"pattern": "^%share_id_pattern%$"
},
"name": {
"const": "testfile.txt"
},
"parentReference": {
"type": "object",
"required": [
"driveId",
"driveType",
"id"
],
"properties": {
"driveId": {
"type": "string",
"pattern": "^%space_id_pattern%$"
},
"driveType" : {
"const": "virtual"
},
"id" : {
"type": "string",
"pattern": "%space_id_pattern%"
}
}
},
"remoteItem": {
"type": "object",
"required": [
"eTag",
"file",
"id",
"lastModifiedDateTime",
"name",
"parentReference",
"permissions",
"size"
],
"properties": {
"eTag": {
"type": "string",
"pattern": "%etag_pattern%"
},
"file": {
"type": "object",
"required": ["mimeType"],
"properties": {
"mimeType": {
"type": "string",
"pattern": "^text/plain"
}
}
},
"id": {
"type": "string",
"pattern": "^%file_id_pattern%$"
},
"name": {
"const": "testfile.txt"
},
"parentReference": {
"type": "object",
"required": [
"driveId",
"driveType"
],
"properties": {
"driveId": {
"type": "string",
"pattern": "%space_id_pattern%"
},
"driveType" : {
"const": "project"
}
}
},
"permissions": {
"type": "array",
"maxItems": 1,
"minItems": 1,
"items": {
"type": "object",
"required": [
"grantedToV2",
"id",
"invitation",
"roles"
],
"properties": {
"id": {
"type": "string",
"pattern": "^%permissions_id_pattern%$"
},
"grantedToV2": {
"type": "object",
"required": ["user"],
"properties": {
"user": {
"type": "object",
"properties": {
"displayName": {
"const": "Brian Murphy"
},
"id": {
"type": "string",
"pattern":"^%user_id_pattern%$"
}
},
"required": [
"displayName",
"id"
]
}
}
},
"invitation": {
"type": "object",
"required": ["invitedBy"],
"properties": {
"invitedBy": {
"type": "object",
"required": ["user"],
"properties": {
"user": {
"type": "object",
"required": [
"displayName",
"id"
],
"properties": {
"displayName": {
"const": "Alice Hansen"
},
"id": {
"type": "string",
"pattern": "^%user_id_pattern%$"
}
}
}
}
}
}
},
"roles": {
"type": "array",
"maxItems": 1,
"minItems": 1,
"items": {
"type": "string",
"pattern": "^%role_id_pattern%$"
}
}
}
}
},
"size": {
"const": 12
}
}
},
"size": {
"const": 12
}
}
}
}
}
}
"""
Scenario: user lists the folder shared with them from project space
Given using spaces DAV path
And the administrator has assigned the role "Space Admin" to user "Alice" using the Graph API
And user "Alice" has created a space "new-space" with the default quota using the Graph API
And user "Alice" has created a folder "folder" in space "new-space"
And user "Alice" has sent the following share invitation:
| resource | folder |
| space | new-space |
| sharee | Brian |
| shareType | user |
| permissionsRole | Viewer |
When user "Brian" lists the shares 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",
"maxItems": 1,
"minItems": 1,
"items": {
"type": "object",
"required": [
"@UI.Hidden",
"@client.synchronize",
"eTag",
"folder",
"id",
"lastModifiedDateTime",
"name",
"parentReference",
"remoteItem"
],
"properties": {
"@UI.Hidden":{
"const": false
},
"@client.synchronize":{
"const": true
},
"eTag": {
"type": "string",
"pattern": "%etag_pattern%"
},
"folder": {
"const": {}
},
"id": {
"type": "string",
"pattern": "^%share_id_pattern%$"
},
"name": {
"const": "folder"
},
"parentReference": {
"type": "object",
"required": [
"driveId",
"driveType",
"id"
],
"properties": {
"driveId": {
"type": "string",
"pattern": "^%space_id_pattern%$"
},
"driveType" : {
"const": "virtual"
},
"id" : {
"type": "string",
"pattern": "%space_id_pattern%"
}
}
},
"remoteItem": {
"type": "object",
"required": [
"eTag",
"folder",
"id",
"lastModifiedDateTime",
"name",
"parentReference",
"permissions"
],
"properties": {
"eTag": {
"type": "string",
"pattern": "%etag_pattern%"
},
"folder": {
"const": {}
},
"id": {
"type": "string",
"pattern": "^%file_id_pattern%$"
},
"name": {
"const": "folder"
},
"parentReference": {
"type": "object",
"required": [
"driveId",
"driveType"
],
"properties": {
"driveId": {
"type": "string",
"pattern": "%space_id_pattern%"
},
"driveType" : {
"const": "project"
}
}
},
"permissions": {
"type": "array",
"maxItems": 1,
"minItems": 1,
"items": {
"type": "object",
"required": [
"grantedToV2",
"id",
"invitation",
"roles"
],
"properties": {
"id": {
"type": "string",
"pattern": "^%permissions_id_pattern%$"
},
"grantedToV2": {
"type": "object",
"required": ["user"],
"properties": {
"user": {
"type": "object",
"properties": {
"displayName": {
"const": "Brian Murphy"
},
"id": {
"type": "string",
"pattern":"^%user_id_pattern%$"
}
},
"required": [
"displayName",
"id"
]
}
}
},
"invitation": {
"type": "object",
"required": ["invitedBy"],
"properties": {
"invitedBy": {
"type": "object",
"required": ["user"],
"properties": {
"user": {
"type": "object",
"required": [
"displayName",
"id"
],
"properties": {
"displayName": {
"const": "Alice Hansen"
},
"id": {
"type": "string",
"pattern": "^%user_id_pattern%$"
}
}
}
}
}
}
},
"roles": {
"type": "array",
"maxItems": 1,
"minItems": 1,
"items": {
"type": "string",
"pattern": "^%role_id_pattern%$"
}
}
}
}
}
}
}
}
}
}
}
}
"""
Scenario: user lists the folder shared with them from project space after the sharer is disabled
Given using spaces DAV path
And the administrator has assigned the role "Space Admin" to user "Alice" using the Graph API
And user "Alice" has created a space "new-space" with the default quota using the Graph API
And user "Alice" has created a folder "folder" in space "new-space"
And user "Alice" has sent the following share invitation:
| resource | folder |
| space | new-space |
| sharee | Brian |
| shareType | user |
| permissionsRole | Viewer |
And the user "Admin" has disabled user "Alice"
When user "Brian" lists the shares 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",
"maxItems": 1,
"minItems": 1,
"items": {
"type": "object",
"required": [
"@UI.Hidden",
"@client.synchronize",
"eTag",
"folder",
"id",
"lastModifiedDateTime",
"name",
"parentReference",
"remoteItem"
],
"properties": {
"@UI.Hidden":{
"const": false
},
"@client.synchronize":{
"const": true
},
"eTag": {
"type": "string",
"pattern": "%etag_pattern%"
},
"folder": {
"const": {}
},
"id": {
"type": "string",
"pattern": "^%share_id_pattern%$"
},
"name": {
"const": "folder"
},
"parentReference": {
"type": "object",
"required": [
"driveId",
"driveType",
"id"
],
"properties": {
"driveId": {
"type": "string",
"pattern": "^%space_id_pattern%$"
},
"driveType" : {
"const": "virtual"
},
"id" : {
"type": "string",
"pattern": "%space_id_pattern%"
}
}
},
"remoteItem": {
"type": "object",
"required": [
"eTag",
"folder",
"id",
"lastModifiedDateTime",
"name",
"parentReference",
"permissions"
],
"properties": {
"eTag": {
"type": "string",
"pattern": "%etag_pattern%"
},
"folder": {
"const": {}
},
"id": {
"type": "string",
"pattern": "^%file_id_pattern%$"
},
"name": {
"const": "folder"
},
"parentReference": {
"type": "object",
"required": [
"driveId",
"driveType"
],
"properties": {
"driveId": {
"type": "string",
"pattern": "%space_id_pattern%"
},
"driveType" : {
"const": "project"
}
}
},
"permissions": {
"type": "array",
"maxItems": 1,
"minItems": 1,
"items": {
"type": "object",
"required": [
"grantedToV2",
"id",
"invitation",
"roles"
],
"properties": {
"id": {
"type": "string",
"pattern": "^%permissions_id_pattern%$"
},
"grantedToV2": {
"type": "object",
"required": ["user"],
"properties": {
"user": {
"type": "object",
"properties": {
"displayName": {
"const": "Brian Murphy"
},
"id": {
"type": "string",
"pattern":"^%user_id_pattern%$"
}
},
"required": [
"displayName",
"id"
]
}
}
},
"invitation": {
"type": "object",
"required": ["invitedBy"],
"properties": {
"invitedBy": {
"type": "object",
"required": ["user"],
"properties": {
"user": {
"type": "object",
"required": [
"displayName",
"id"
],
"properties": {
"displayName": {
"const": "Alice Hansen"
},
"id": {
"type": "string",
"pattern": "^%user_id_pattern%$"
}
}
}
}
}
}
},
"roles": {
"type": "array",
"maxItems": 1,
"minItems": 1,
"items": {
"type": "string",
"pattern": "^%role_id_pattern%$"
}
}
}
}
}
}
}
}
}
}
}
}
"""
@env-config @8314
Scenario: user lists the folder shared with them from project space after the sharer is deleted
Given the config "GRAPH_SPACES_USERS_CACHE_TTL" has been set to "1"
And using spaces DAV path
And the administrator has assigned the role "Space Admin" to user "Alice" using the Graph API
And user "Alice" has created a space "new-space" with the default quota using the Graph API
And user "Alice" has created a folder "folder" in space "new-space"
And user "Alice" has sent the following share invitation:
| resource | folder |
| space | new-space |
| sharee | Brian |
| shareType | user |
| permissionsRole | Viewer |
And the user "Admin" has deleted a user "Alice"
When user "Brian" lists the shares shared with him after clearing user cache 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",
"maxItems": 1,
"minItems": 1,
"items": {
"type": "object",
"required": [
"@UI.Hidden",
"@client.synchronize",
"eTag",
"folder",
"id",
"lastModifiedDateTime",
"name",
"parentReference",
"remoteItem"
],
"properties": {
"@UI.Hidden":{
"const": false
},
"@client.synchronize":{
"const": true
},
"eTag": {
"type": "string",
"pattern": "%etag_pattern%"
},
"folder": {
"const": {}
},
"id": {
"type": "string",
"pattern": "^%share_id_pattern%$"
},
"name": {
"const": "folder"
},
"parentReference": {
"type": "object",
"required": [
"driveId",
"driveType",
"id"
],
"properties": {
"driveId": {
"type": "string",
"pattern": "^%space_id_pattern%$"
},
"driveType" : {
"const": "virtual"
},
"id" : {
"type": "string",
"pattern": "^%file_id_pattern%$"
}
}
},
"remoteItem": {
"type": "object",
"required": [
"eTag",
"folder",
"id",
"lastModifiedDateTime",
"name",
"parentReference",
"permissions"
],
"properties": {
"eTag": {
"type": "string",
"pattern": "%etag_pattern%"
},
"folder": {
"const": {}
},
"id": {
"type": "string",
"pattern": "^%file_id_pattern%$"
},
"name": {
"const": "folder"
},
"parentReference": {
"type": "object",
"required": [
"driveId",
"driveType"
],
"properties": {
"driveId": {
"type": "string",
"pattern": "^%file_id_pattern%$"
},
"driveType" : {
"const": "project"
}
}
},
"permissions": {
"type": "array",
"maxItems": 1,
"minItems": 1,
"items": {
"type": "object",
"required": [
"grantedToV2",
"id",
"invitation",
"roles"
],
"properties": {
"id": {
"type": "string",
"pattern": "^%permissions_id_pattern%$"
},
"grantedToV2": {
"type": "object",
"required": ["user"],
"properties": {
"user": {
"type": "object",
"properties": {
"displayName": {
"const": "Brian Murphy"
},
"id": {
"type": "string",
"pattern":"^%user_id_pattern%$"
}
},
"required": [
"displayName",
"id"
]
}
}
},
"invitation": {
"type": "object",
"required": ["invitedBy"],
"properties": {
"invitedBy": {
"type": "object",
"required": ["user"],
"properties": {
"user": {
"type": "object",
"required": [
"displayName",
"id"
],
"properties": {
"displayName": {
"const": ""
},
"id": {
"type": "string",
"pattern": "^%user_id_pattern%$"
}
}
}
}
}
}
},
"roles": {
"type": "array",
"maxItems": 1,
"minItems": 1,
"items": {
"type": "string",
"pattern": "^%role_id_pattern%$"
}
}
}
}
}
}
}
}
}
}
}
}
"""
Scenario: user lists the file shared with them from personal space after the sharer is deleted
Given user "Alice" has uploaded file with content "hello" to "textfile0.txt"
And user "Alice" has sent the following share invitation:
| resource | textfile0.txt |
| space | Personal |
| sharee | Brian |
| shareType | user |
| permissionsRole | Viewer |
And the user "Admin" has deleted a user "Alice"
When user "Brian" lists the shares 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",
"minItems":0,
"maxItems":0
}
}
}
"""
@@ -2511,14 +2511,22 @@ class GraphContext implements Context {
}
/**
* @When user :user lists the shares shared with him/her using the Graph API
* @When /^user "([^"]*)" lists the shares shared with (?:him|her)(| after clearing user cache) using the Graph API$/
*
* @param string $user
* @param string $cacheStepString
*
* @return void
* @throws GuzzleException
*/
public function userListsTheResourcesSharedWithThemUsingGraphApi(string $user): void {
public function userListsTheResourcesSharedWithThemUsingGraphApi(string $user, string $cacheStepString): void {
if ($cacheStepString !== '') {
// ENV (GRAPH_SPACES_GROUPS_CACHE_TTL | GRAPH_SPACES_USERS_CACHE_TTL) is set default to 60 sec
// which means 60 sec is required to clean up all the user|group cache once they are deleted
// for tests we have set the above ENV's to minimum which is 1 sec as we check the details for the deleted users
sleep(1);
}
$credentials = $this->getAdminOrUserCredentials($user);
$this->featureContext->setResponse(
GraphHelper::getSharesSharedWithMe(