Skip to content

Commit

Permalink
Used expirationDateTime key for graph api (#9278)
Browse files Browse the repository at this point in the history
  • Loading branch information
grgprarup authored May 30, 2024
1 parent ca79f20 commit a0a3447
Show file tree
Hide file tree
Showing 5 changed files with 86 additions and 87 deletions.
21 changes: 10 additions & 11 deletions tests/TestHelpers/GraphHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -1688,7 +1688,7 @@ public static function getPermissionNameByPermissionRoleId(
* @param array $shareTypes
* @param string|null $permissionsRole
* @param string|null $permissionsAction
* @param string|null $expireDate
* @param string|null $expirationDateTime
*
* @return array
* @throws \Exception
Expand All @@ -1698,7 +1698,7 @@ public static function createShareInviteBody(
array $shareTypes,
?string $permissionsRole,
?string $permissionsAction,
?string $expireDate
?string $expirationDateTime
): array {
$body = [];

Expand All @@ -1719,8 +1719,8 @@ public static function createShareInviteBody(
$body['@libre.graph.permissions.actions'] = ['libre.graph/driveItem/' . $permissionsAction];
}

if ($expireDate !== null) {
$body['expirationDateTime'] = $expireDate;
if ($expirationDateTime !== null) {
$body['expirationDateTime'] = $expirationDateTime;
}
return $body;
}
Expand All @@ -1736,7 +1736,7 @@ public static function createShareInviteBody(
* @param array $shareTypes
* @param string|null $permissionsRole
* @param string|null $permissionsAction
* @param string|null $expireDate
* @param string|null $expirationDateTime
*
* @return ResponseInterface
* @throws \JsonException
Expand All @@ -1753,11 +1753,10 @@ public static function sendSharingInvitation(
array $shareTypes,
?string $permissionsRole,
?string $permissionsAction,
?string $expireDate
?string $expirationDateTime
): ResponseInterface {
$url = self::getBetaFullUrl($baseUrl, "drives/$spaceId/items/$itemId/invite");
$body = self::createShareInviteBody($shareeIds, $shareTypes, $permissionsRole, $permissionsAction, $expireDate);

$body = self::createShareInviteBody($shareeIds, $shareTypes, $permissionsRole, $permissionsAction, $expirationDateTime);
return HttpRequestHelper::post(
$url,
$xRequestId,
Expand Down Expand Up @@ -2115,7 +2114,7 @@ public static function getDrivePermissionsList(
* @param array $shareTypes
* @param string|null $permissionsRole
* @param string|null $permissionsAction
* @param string|null $expireDate
* @param string|null $expirationDateTime
*
* @return ResponseInterface
* @throws \Exception|GuzzleException
Expand All @@ -2130,10 +2129,10 @@ public static function sendSharingInvitationForDrive(
array $shareTypes,
?string $permissionsRole,
?string $permissionsAction,
?string $expireDate
?string $expirationDateTime
): ResponseInterface {
$url = self::getBetaFullUrl($baseUrl, "drives/$spaceId/root/invite");
$body = self::createShareInviteBody($shareeIds, $shareTypes, $permissionsRole, $permissionsAction, $expireDate);
$body = self::createShareInviteBody($shareeIds, $shareTypes, $permissionsRole, $permissionsAction, $expirationDateTime);

return HttpRequestHelper::post(
$url,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -562,12 +562,12 @@ Feature: Send a sharing invitations
Given user "Alice" has uploaded file with content "to share" to "/textfile1.txt"
And user "Alice" has created folder "FolderToShare"
When user "Alice" sends the following resource share invitation using the Graph API:
| resource | <resource> |
| space | Personal |
| sharee | Brian |
| shareType | user |
| permissionsRole | <permissions-role> |
| expireDate | 2043-07-15T14:00:00.000Z |
| resource | <resource> |
| space | Personal |
| sharee | Brian |
| shareType | user |
| permissionsRole | <permissions-role> |
| expirationDateTime | 2043-07-15T14:00:00.000Z |
Then the HTTP status code should be "200"
And the JSON data of the response should match
"""
Expand Down Expand Up @@ -658,12 +658,12 @@ Feature: Send a sharing invitations
And user "Alice" has uploaded file with content "to share" to "/textfile1.txt"
And user "Alice" has created folder "FolderToShare"
When user "Alice" sends the following resource share invitation using the Graph API:
| resource | <resource> |
| space | Personal |
| sharee | grp1 |
| shareType | group |
| permissionsRole | <permissions-role> |
| expireDate | 2043-07-15T14:00:00.000Z |
| resource | <resource> |
| space | Personal |
| sharee | grp1 |
| shareType | group |
| permissionsRole | <permissions-role> |
| expirationDateTime | 2043-07-15T14:00:00.000Z |
Then the HTTP status code should be "200"
And the JSON data of the response should match
"""
Expand Down
60 changes: 30 additions & 30 deletions tests/acceptance/features/apiSpacesShares/shareSpaces.feature
Original file line number Diff line number Diff line change
Expand Up @@ -345,11 +345,11 @@ Feature: Share spaces

Scenario Outline: update the expiration date of a space in user share
Given user "Alice" has sent the following space share invitation:
| space | share space |
| sharee | Brian |
| shareType | user |
| permissionsRole | <space-role> |
| expireDate | 2042-03-25T23:59:59.000Z |
| space | share space |
| sharee | Brian |
| shareType | user |
| permissionsRole | <space-role> |
| expirationDateTime | 2042-03-25T23:59:59.000Z |
When user "Alice" updates the space "share space" with settings:
| shareWith | Brian |
| expireDate | 2044-01-01T23:59:59.999+01:00 |
Expand All @@ -367,11 +367,11 @@ Feature: Share spaces
Given group "sales" has been created
And the administrator has added a user "Brian" to the group "sales" using the Graph API
And user "Alice" has sent the following space share invitation:
| space | share space |
| sharee | sales |
| shareType | group |
| permissionsRole | <space-role> |
| expireDate | 2042-03-25T23:59:59.000Z |
| space | share space |
| sharee | sales |
| shareType | group |
| permissionsRole | <space-role> |
| expirationDateTime | 2042-03-25T23:59:59.000Z |
When user "Alice" updates the space "share space" with settings:
| shareWith | sales |
| shareType | 8 |
Expand All @@ -388,11 +388,11 @@ Feature: Share spaces

Scenario Outline: delete the expiration date of a space in user share
Given user "Alice" has sent the following space share invitation:
| space | share space |
| sharee | Brian |
| shareType | user |
| permissionsRole | <space-role> |
| expireDate | 2042-03-25T23:59:59.000Z |
| space | share space |
| sharee | Brian |
| shareType | user |
| permissionsRole | <space-role> |
| expirationDateTime | 2042-03-25T23:59:59.000Z |
When user "Alice" updates the space "share space" with settings:
| shareWith | Brian |
| expireDate | |
Expand All @@ -410,11 +410,11 @@ Feature: Share spaces
Given group "sales" has been created
And the administrator has added a user "Brian" to the group "sales" using the Graph API
And user "Alice" has sent the following space share invitation:
| space | share space |
| sharee | sales |
| shareType | group |
| permissionsRole | <space-role> |
| expireDate | 2042-03-25T23:59:59.000Z |
| space | share space |
| sharee | sales |
| shareType | group |
| permissionsRole | <space-role> |
| expirationDateTime | 2042-03-25T23:59:59.000Z |
When user "Alice" updates the space "share space" with settings:
| shareWith | sales |
| shareType | 8 |
Expand All @@ -431,11 +431,11 @@ Feature: Share spaces

Scenario Outline: check the end of expiration of a space in user share
Given user "Alice" has sent the following space share invitation:
| space | share space |
| sharee | Brian |
| shareType | user |
| permissionsRole | <space-role> |
| expireDate | 2042-03-25T23:59:59.000Z |
| space | share space |
| sharee | Brian |
| shareType | user |
| permissionsRole | <space-role> |
| expirationDateTime | 2042-03-25T23:59:59.000Z |
When user "Alice" expires the user share of space "share space" for user "Brian"
Then the HTTP status code should be "200"
And the user "Brian" should not have a space called "share space"
Expand All @@ -450,11 +450,11 @@ Feature: Share spaces
Given group "sales" has been created
And the administrator has added a user "Brian" to the group "sales" using the Graph API
And user "Alice" has sent the following space share invitation:
| space | share space |
| sharee | sales |
| shareType | group |
| permissionsRole | <space-role> |
| expireDate | 2042-03-25T23:59:59.000Z |
| space | share space |
| sharee | sales |
| shareType | group |
| permissionsRole | <space-role> |
| expirationDateTime | 2042-03-25T23:59:59.000Z |
When user "Alice" expires the group share of space "share space" for group "sales"
Then the HTTP status code should be "200"
And the user "Brian" should not have a space called "share space"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,12 +125,12 @@ Feature: Share a file or folder that is inside a space
Scenario: user changes the expiration date
Given using SharingNG
And user "Alice" has sent the following resource share invitation:
| resource | folder |
| space | share sub-item |
| sharee | Brian |
| shareType | user |
| permissionsRole | Viewer |
| expireDate | 2042-01-01T23:59:59.000Z |
| resource | folder |
| space | share sub-item |
| sharee | Brian |
| shareType | user |
| permissionsRole | Viewer |
| expirationDateTime | 2042-01-01T23:59:59.000Z |
When user "Alice" changes the last share with settings:
| expireDate | 2044-01-01T23:59:59.999+01:00 |
| role | viewer |
Expand All @@ -142,12 +142,12 @@ Feature: Share a file or folder that is inside a space
Scenario: user deletes the expiration date
Given using SharingNG
And user "Alice" has sent the following resource share invitation:
| resource | folder |
| space | share sub-item |
| sharee | Brian |
| shareType | user |
| permissionsRole | Viewer |
| expireDate | 2042-01-01T23:59:59.000Z |
| resource | folder |
| space | share sub-item |
| sharee | Brian |
| shareType | user |
| permissionsRole | Viewer |
| expirationDateTime | 2042-01-01T23:59:59.000Z |
When user "Alice" changes the last share with settings:
| expireDate | |
| role | viewer |
Expand All @@ -160,12 +160,12 @@ Feature: Share a file or folder that is inside a space
Given using OCS API version "<ocs_api_version>"
And using SharingNG
And user "Alice" has sent the following resource share invitation:
| resource | folder |
| space | share sub-item |
| sharee | Brian |
| shareType | user |
| permissionsRole | Viewer |
| expireDate | 2042-01-01T23:59:59.000Z |
| resource | folder |
| space | share sub-item |
| sharee | Brian |
| shareType | user |
| permissionsRole | Viewer |
| expirationDateTime | 2042-01-01T23:59:59.000Z |
When user "Alice" changes the last share with settings:
| role | |
Then the HTTP status code should be "400"
Expand All @@ -174,12 +174,12 @@ Feature: Share a file or folder that is inside a space
Scenario: check the end of expiration date in user share
Given using SharingNG
And user "Alice" has sent the following resource share invitation:
| resource | folder |
| space | share sub-item |
| sharee | Brian |
| shareType | user |
| permissionsRole | Viewer |
| expireDate | 2042-01-01T23:59:59.000Z |
| resource | folder |
| space | share sub-item |
| sharee | Brian |
| shareType | user |
| permissionsRole | Viewer |
| expirationDateTime | 2042-01-01T23:59:59.000Z |
When user "Alice" expires the last share of resource "folder" inside of the space "share sub-item"
Then the HTTP status code should be "200"
And as "Brian" folder "Shares/folder" should not exist
Expand All @@ -190,12 +190,12 @@ Feature: Share a file or folder that is inside a space
And using SharingNG
And the administrator has added a user "Brian" to the group "sales" using the Graph API
And user "Alice" has sent the following resource share invitation:
| resource | folder |
| space | share sub-item |
| sharee | sales |
| shareType | group |
| permissionsRole | Viewer |
| expireDate | 2042-01-01T23:59:59.000Z |
| resource | folder |
| space | share sub-item |
| sharee | sales |
| shareType | group |
| permissionsRole | Viewer |
| expirationDateTime | 2042-01-01T23:59:59.000Z |
When user "Alice" expires the last share of resource "folder" inside of the space "share sub-item"
Then the HTTP status code should be "200"
And as "Brian" folder "Shares/folder" should not exist
8 changes: 4 additions & 4 deletions tests/acceptance/features/bootstrap/SharingNgContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ public function sendShareInvitation(string $user, TableNode $table, string $file

$permissionsRole = $rows['permissionsRole'] ?? null;
$permissionsAction = $rows['permissionsAction'] ?? null;
$expireDate = $rows["expireDate"] ?? null;
$expirationDateTime = $rows["expirationDateTime"] ?? null;

$response = GraphHelper::sendSharingInvitation(
$this->featureContext->getBaseUrl(),
Expand All @@ -302,7 +302,7 @@ public function sendShareInvitation(string $user, TableNode $table, string $file
$shareTypes,
$permissionsRole,
$permissionsAction,
$expireDate
$expirationDateTime
);
if ($response->getStatusCode() === 200) {
$this->featureContext->shareNgAddToCreatedUserGroupShares($response);
Expand Down Expand Up @@ -354,7 +354,7 @@ public function sendDriveShareInvitation(string $user, TableNode $table): Respon

$permissionsRole = $rows['permissionsRole'] ?? null;
$permissionsAction = $rows['permissionsAction'] ?? null;
$expireDate = $rows["expireDate"] ?? null;
$expirationDateTime = $rows["expirationDateTime"] ?? null;

return GraphHelper::sendSharingInvitationForDrive(
$this->featureContext->getBaseUrl(),
Expand All @@ -366,7 +366,7 @@ public function sendDriveShareInvitation(string $user, TableNode $table): Respon
$shareTypes,
$permissionsRole,
$permissionsAction,
$expireDate
$expirationDateTime
);
}

Expand Down

0 comments on commit a0a3447

Please sign in to comment.