Skip to content

Commit 173fdf5

Browse files
update share step to expiry
1 parent f8c1fc3 commit 173fdf5

File tree

15 files changed

+249
-280
lines changed

15 files changed

+249
-280
lines changed

tests/acceptance/TestHelpers/GraphHelper.php

+4-1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222

2323
namespace TestHelpers;
2424

25+
use DateTime;
26+
use DateTimeZone;
2527
use GuzzleHttp\Exception\GuzzleException;
2628
use Psr\Http\Message\RequestInterface;
2729
use Psr\Http\Message\ResponseInterface;
@@ -1810,7 +1812,8 @@ public static function createShareInviteBody(
18101812
}
18111813

18121814
if ($expirationDateTime !== null) {
1813-
$body['expirationDateTime'] = $expirationDateTime;
1815+
$dateTime = new DateTime("now", new DateTimeZone("UTC"));
1816+
$body['expirationDateTime'] = $dateTime->modify($expirationDateTime)->format('Y-m-d\TH:i:s\Z');
18141817
}
18151818
return $body;
18161819
}

tests/acceptance/bootstrap/SharingNgContext.php

+25-52
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,16 @@ public function createLinkShare(string $user, TableNode $body): ResponseInterfac
8787

8888
$bodyRows['quickLink'] = $bodyRows['quickLink'] ?? false;
8989
$bodyRows['displayName'] = $bodyRows['displayName'] ?? null;
90-
$bodyRows['expirationDateTime'] = \array_key_exists('expirationDateTime', $bodyRows)
91-
? \date('Y-m-d', \strtotime($bodyRows['expirationDateTime'])) . 'T14:00:00.000Z' : null;
90+
91+
if (\array_key_exists('expirationDateTime', $bodyRows)) {
92+
$dateTime = new DateTime("now", new DateTimeZone("UTC"));
93+
$bodyRows['expirationDateTime'] = $dateTime->modify(
94+
$bodyRows['expirationDateTime']
95+
)->format('Y-m-d\TH:i:s\Z');
96+
} else {
97+
$bodyRows['expirationDateTime'] = null;
98+
}
99+
92100
$bodyRows['password'] = $bodyRows['password'] ?? null;
93101
$permissionsRole = $bodyRows['permissionsRole'];
94102

@@ -130,7 +138,12 @@ public function createDriveLinkShare(string $user, TableNode $body): ResponseInt
130138
$permissionsRole = $bodyRows['permissionsRole'];
131139
$bodyRows['quickLink'] = $bodyRows['quickLink'] ?? false;
132140
$bodyRows['displayName'] = $bodyRows['displayName'] ?? null;
133-
$bodyRows['expirationDateTime'] = $bodyRows['expirationDateTime'] ?? null;
141+
142+
$dateTime = new DateTime("now", new DateTimeZone("UTC"));
143+
$bodyRows['expirationDateTime'] = empty($bodyRows['expirationDateTime'])
144+
? null :
145+
$dateTime->modify($bodyRows['expirationDateTime'])->format('Y-m-d\TH:i:s\Z');
146+
134147
$bodyRows['password'] = $bodyRows['password'] ?? null;
135148
$type = GraphHelper::SHARING_LINK_TYPE_MAPPINGS[$permissionsRole] ?? $permissionsRole;
136149
$body = [
@@ -677,8 +690,10 @@ public function updateResourceShare(string $user, TableNode $body, string $perm
677690
}
678691

679692
if (\array_key_exists('expirationDateTime', $bodyRows)) {
693+
$dateTime = new DateTime("now", new DateTimeZone("UTC"));
680694
$body['expirationDateTime'] = empty($bodyRows['expirationDateTime'])
681-
? null : $bodyRows['expirationDateTime'];
695+
? null :
696+
$dateTime->modify($bodyRows['expirationDateTime'])->format('Y-m-d\TH:i:s\Z');
682697
}
683698

684699
return GraphHelper::updateShare(
@@ -851,8 +866,10 @@ public function updateLinkShare(string $user, TableNode $body, string $permissi
851866
}
852867

853868
if (\array_key_exists('expirationDateTime', $bodyRows)) {
869+
$dateTime = new DateTime("now", new DateTimeZone("UTC"));
854870
$body['expirationDateTime'] = empty($bodyRows['expirationDateTime'])
855-
? null : $bodyRows['expirationDateTime'];
871+
? null :
872+
$dateTime->modify($bodyRows['expirationDateTime'])->format('Y-m-d\TH:i:s\Z');
856873
}
857874

858875
if (\array_key_exists('displayName', $bodyRows)) {
@@ -1656,8 +1673,10 @@ public function userUpdatesTheLastDriveShareWithTheFollowingUsingRootEndpointOfT
16561673
}
16571674

16581675
if (\array_key_exists('expirationDateTime', $bodyRows)) {
1676+
$dateTime = new DateTime("now", new DateTimeZone("UTC"));
16591677
$body['expirationDateTime'] = empty($bodyRows['expirationDateTime'])
1660-
? null : $bodyRows['expirationDateTime'];
1678+
? null :
1679+
$dateTime->modify($bodyRows['expirationDateTime'])->format('Y-m-d\TH:i:s\Z');
16611680
}
16621681

16631682
$this->featureContext->setResponse(
@@ -2160,50 +2179,4 @@ public function userListsPermissionsWithFollowingFiltersForFileOrFolderOfTheSpac
21602179
$this->getPermissionsList($user, $fileOrFolder, $space, $resource, $query)
21612180
);
21622181
}
2163-
2164-
/**
2165-
* @When user :user expires the last created share:
2166-
*
2167-
* @param string $user
2168-
* @param TableNode $table
2169-
*
2170-
* @return void
2171-
*/
2172-
public function userExpiresTheLastCreatedShare(string $user, TableNode $table): void {
2173-
$permissionID = $this->featureContext->shareNgGetLastCreatedUserGroupShareID();
2174-
$bodyRows = $table->getRowsHash();
2175-
if ($bodyRows['space'] === 'Personal' || $bodyRows['space'] === 'Shares') {
2176-
$space = $this->spacesContext->getSpaceByName($user, $bodyRows['space']);
2177-
} else {
2178-
$space = $this->spacesContext->getCreatedSpace($bodyRows['space']);
2179-
}
2180-
$spaceId = $space["id"];
2181-
// for updating role of project space shared, we do not need to provide resource
2182-
$resource = $bodyRows['resource'] ?? '';
2183-
if ($resource === '' && !\in_array($bodyRows['space'], ['Personal', 'Shares'])) {
2184-
$itemId = $space['fileId'];
2185-
} else {
2186-
$itemId = $this->spacesContext->getResourceId($user, $bodyRows['space'], $resource);
2187-
}
2188-
$body = [];
2189-
$dateTime = new DateTime("now", new DateTimeZone("UTC"));
2190-
$body['expirationDateTime'] = $dateTime->modify('-5 minutes')->format('Y-m-d\TH:i:s\Z');
2191-
2192-
$response = GraphHelper::updateShare(
2193-
$this->featureContext->getBaseUrl(),
2194-
$this->featureContext->getStepLineRef(),
2195-
$user,
2196-
$this->featureContext->getPasswordForUser($user),
2197-
$spaceId,
2198-
$itemId,
2199-
\json_encode($body),
2200-
$permissionID
2201-
);
2202-
2203-
$this->featureContext->theHttpStatusCodeShouldBe(
2204-
200,
2205-
"Failed to update shared permissions for user '$user'.",
2206-
$response
2207-
);
2208-
}
22092182
}

tests/acceptance/features/apiActivities/shareActivities.feature

+22-22
Original file line numberDiff line numberDiff line change
@@ -1070,9 +1070,9 @@ Feature: check share activity
10701070
| permissionsRole | View |
10711071
| password | %public% |
10721072
And user "Alice" has updated the last resource link share with
1073-
| space | new-space |
1074-
| permissionsRole | Edit |
1075-
| expirationDateTime | 2200-07-15T14:00:00.000Z |
1073+
| space | new-space |
1074+
| permissionsRole | Edit |
1075+
| expirationDateTime | +200 years |
10761076
And user "Alice" has set the following password for the last link share:
10771077
| resource | |
10781078
| space | new-space |
@@ -1360,10 +1360,10 @@ Feature: check share activity
13601360
| shareType | user |
13611361
| permissionsRole | Viewer |
13621362
And user "Alice" has updated the last resource share with the following properties:
1363-
| permissionsRole | Editor |
1364-
| expirationDateTime | 2200-07-15T14:00:00.000Z |
1365-
| space | new-space |
1366-
| resource | folderToShare |
1363+
| permissionsRole | Editor |
1364+
| expirationDateTime | +200 years |
1365+
| space | new-space |
1366+
| resource | folderToShare |
13671367
When user "Alice" lists the activities of folder "folderToShare" from space "new-space" using the Graph API
13681368
Then the HTTP status code should be "200"
13691369
And the JSON data of the response should match
@@ -1546,10 +1546,10 @@ Feature: check share activity
15461546
| permissionsRole | View |
15471547
| password | %public% |
15481548
And user "Alice" has updated the last resource link share with
1549-
| resource | textfile.txt |
1550-
| space | new-space |
1551-
| permissionsRole | Edit |
1552-
| expirationDateTime | 2200-07-15T14:00:00.000Z |
1549+
| resource | textfile.txt |
1550+
| space | new-space |
1551+
| permissionsRole | Edit |
1552+
| expirationDateTime | +200 years |
15531553
And user "Alice" has set the following password for the last link share:
15541554
| resource | textfile.txt |
15551555
| space | new-space |
@@ -1852,9 +1852,9 @@ Feature: check share activity
18521852
| permissionsRole | View |
18531853
| password | %public% |
18541854
And user "Alice" has updated the last resource link share with
1855-
| space | new-space |
1856-
| permissionsRole | Edit |
1857-
| expirationDateTime | 2200-07-15T14:00:00.000Z |
1855+
| space | new-space |
1856+
| permissionsRole | Edit |
1857+
| expirationDateTime | +200 years |
18581858
And user "Alice" has set the following password for the last link share:
18591859
| resource | |
18601860
| space | new-space |
@@ -1874,10 +1874,10 @@ Feature: check share activity
18741874
| permissionsRole | View |
18751875
| password | %public% |
18761876
And user "Alice" has updated the last resource link share with
1877-
| resource | textfile.txt |
1878-
| space | new-space |
1879-
| permissionsRole | Edit |
1880-
| expirationDateTime | 2200-07-15T14:00:00.000Z |
1877+
| resource | textfile.txt |
1878+
| space | new-space |
1879+
| permissionsRole | Edit |
1880+
| expirationDateTime | +200 years |
18811881
And user "Alice" has set the following password for the last link share:
18821882
| resource | textfile.txt |
18831883
| space | new-space |
@@ -1897,10 +1897,10 @@ Feature: check share activity
18971897
| permissionsRole | View |
18981898
| password | %public% |
18991899
And user "Alice" has updated the last resource link share with
1900-
| resource | project-folder |
1901-
| space | new-space |
1902-
| permissionsRole | Edit |
1903-
| expirationDateTime | 2200-07-15T14:00:00.000Z |
1900+
| resource | project-folder |
1901+
| space | new-space |
1902+
| permissionsRole | Edit |
1903+
| expirationDateTime | +20 years |
19041904
And user "Alice" has set the following password for the last link share:
19051905
| resource | project-folder |
19061906
| space | new-space |

tests/acceptance/features/apiAntivirus/antivirus.feature

+9-9
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,10 @@ Feature: antivirus
9999
And using SharingNG
100100
And user "Alice" has created folder "/uploadFolder"
101101
And user "Alice" has created the following resource link share:
102-
| resource | uploadFolder |
103-
| space | Personal |
104-
| permissionsRole | Edit |
105-
| expirationDateTime | 2040-01-01T23:59:59.000Z |
102+
| resource | uploadFolder |
103+
| space | Personal |
104+
| permissionsRole | Edit |
105+
| expirationDateTime | +20 years |
106106
When the public uploads file "filesForUpload/filesWithVirus/<file-name>" to "<new-file-name>" inside last link shared folder using the public WebDAV API
107107
Then the HTTP status code should be "201"
108108
And user "Alice" should get a notification with subject "Virus found" and message:
@@ -124,11 +124,11 @@ Feature: antivirus
124124
And using SharingNG
125125
And user "Alice" has created folder "/uploadFolder"
126126
And user "Alice" has created the following resource link share:
127-
| resource | uploadFolder |
128-
| space | Personal |
129-
| permissionsRole | Edit |
130-
| password | %public% |
131-
| expirationDateTime | 2040-01-01T23:59:59.000Z |
127+
| resource | uploadFolder |
128+
| space | Personal |
129+
| permissionsRole | Edit |
130+
| password | %public% |
131+
| expirationDateTime | +20 years |
132132
When the public uploads file "filesForUpload/filesWithVirus/<file-name>" to "<new-file-name>" inside last link shared folder with password "%public%" using the public WebDAV API
133133
Then the HTTP status code should be "201"
134134
And user "Alice" should get a notification with subject "Virus found" and message:

tests/acceptance/features/apiOcm/share.feature

+4-4
Original file line numberDiff line numberDiff line change
@@ -1130,10 +1130,10 @@ Feature: an user shares resources using ScienceMesh application
11301130
| shareType | user |
11311131
| permissionsRole | Viewer |
11321132
And user "Alice" has updated the last resource share with the following properties:
1133-
| permissionsRole | File Editor |
1134-
| expirationDateTime | 2200-07-15T14:00:00.000Z |
1135-
| space | Personal |
1136-
| resource | textfile.txt |
1133+
| permissionsRole | File Editor |
1134+
| expirationDateTime | +20 years |
1135+
| space | Personal |
1136+
| resource | textfile.txt |
11371137
And using server "REMOTE"
11381138
When user "Brian" updates the content of federated share "textfile.txt" with "this is a new content" using the WebDAV API
11391139
Then the HTTP status code should be "500"

tests/acceptance/features/apiSettings/notificationSetting.feature

+12-11
Original file line numberDiff line numberDiff line change
@@ -612,16 +612,17 @@ Feature: Notification Settings
612612
Scenario: check share expired in-app and mail notification for Personal space resource
613613
Given user "Alice" has uploaded file with content "hello world" to "testfile.txt"
614614
And user "Alice" has sent the following resource share invitation:
615-
| resource | testfile.txt |
616-
| space | Personal |
617-
| sharee | Brian |
618-
| shareType | user |
619-
| permissionsRole | Viewer |
620-
| expirationDateTime | 2025-07-15T14:00:00Z |
621-
When user "Alice" expires the last created share:
622-
| space | Personal |
623-
| resource | testfile.txt |
624-
Then user "Brian" should have "2" emails
625-
And user "Brian" should get a notification with subject "Membership expired" and message:
615+
| resource | testfile.txt |
616+
| space | Personal |
617+
| sharee | Brian |
618+
| shareType | user |
619+
| permissionsRole | Viewer |
620+
| expirationDateTime | +5 days |
621+
When user "Alice" updates the last resource share with the following properties using the Graph API:
622+
| space | Personal |
623+
| resource | testfile.txt |
624+
| expirationDateTime | -5 minutes |
625+
Then user "Brian" should get a notification with subject "Membership expired" and message:
626626
| message |
627627
| Access to Space Alice Hansen lost |
628+
And user "Brian" should have "2" emails

tests/acceptance/features/apiSharingNgLinkSharePermission/createLinkShare.feature

+21-21
Original file line numberDiff line numberDiff line change
@@ -272,12 +272,12 @@ Feature: Create a link share for a resource
272272
Scenario Outline: create a link share of a folder with display name and expiry date using permissions endpoint
273273
Given user "Alice" has created folder "folder"
274274
When user "Alice" creates the following resource link share using the Graph API:
275-
| resource | folder |
276-
| space | Personal |
277-
| permissionsRole | <permissions-role> |
278-
| password | %public% |
279-
| displayName | Homework |
280-
| expirationDateTime | 2200-07-15T14:00:00.000Z |
275+
| resource | folder |
276+
| space | Personal |
277+
| permissionsRole | <permissions-role> |
278+
| password | %public% |
279+
| displayName | Homework |
280+
| expirationDateTime | +200 years |
281281
Then the HTTP status code should be "200"
282282
And the JSON data of the response should match
283283
"""
@@ -298,7 +298,7 @@ Feature: Create a link share for a resource
298298
"pattern": "^[a-zA-Z]{15}$"
299299
},
300300
"expirationDateTime": {
301-
"const": "2200-07-15T23:59:59Z"
301+
"type": "string"
302302
},
303303
"link": {
304304
"type": "object",
@@ -343,12 +343,12 @@ Feature: Create a link share for a resource
343343
Scenario Outline: create a link share of a file with display name and expiry date using permissions endpoint
344344
Given user "Alice" has uploaded file with content "other data" to "textfile1.txt"
345345
When user "Alice" creates the following resource link share using the Graph API:
346-
| resource | textfile1.txt |
347-
| space | Personal |
348-
| permissionsRole | <permissions-role> |
349-
| password | %public% |
350-
| displayName | Homework |
351-
| expirationDateTime | 2200-07-15T14:00:00.000Z |
346+
| resource | textfile1.txt |
347+
| space | Personal |
348+
| permissionsRole | <permissions-role> |
349+
| password | %public% |
350+
| displayName | Homework |
351+
| expirationDateTime | +2 days |
352352
Then the HTTP status code should be "200"
353353
And the JSON data of the response should match
354354
"""
@@ -369,7 +369,7 @@ Feature: Create a link share for a resource
369369
"pattern": "^[a-zA-Z]{15}$"
370370
},
371371
"expirationDateTime": {
372-
"const": "2200-07-15T23:59:59Z"
372+
"type": "string"
373373
},
374374
"link": {
375375
"type": "object",
@@ -695,12 +695,12 @@ Feature: Create a link share for a resource
695695
And user "Alice" has created a space "projectSpace" with the default quota using the Graph API
696696
And user "Alice" has created a folder "folderToShare" in space "projectSpace"
697697
When user "Alice" creates the following resource link share using the Graph API:
698-
| resource | folderToShare |
699-
| space | projectSpace |
700-
| permissionsRole | <permissions-role> |
701-
| password | %public% |
702-
| displayName | Homework |
703-
| expirationDateTime | 2200-07-15T14:00:00.000Z |
698+
| resource | folderToShare |
699+
| space | projectSpace |
700+
| permissionsRole | <permissions-role> |
701+
| password | %public% |
702+
| displayName | Homework |
703+
| expirationDateTime | +3 months |
704704
Then the HTTP status code should be "200"
705705
And the JSON data of the response should match
706706
"""
@@ -721,7 +721,7 @@ Feature: Create a link share for a resource
721721
"pattern": "^[a-zA-Z]{15}$"
722722
},
723723
"expirationDateTime": {
724-
"const": "2200-07-15T23:59:59Z"
724+
"type": "string"
725725
},
726726
"link": {
727727
"type": "object",

0 commit comments

Comments
 (0)