Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[tests-only][full-ci] Test for flaky share expiration email #11010

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
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
44 changes: 22 additions & 22 deletions .drone.star
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,13 @@ config = {
"apiLocks",
"apiActivities",
],
"skip": False,
"skip": True,
},
"settings": {
"suites": [
"apiSettings",
],
"skip": False,
"skip": True,
"withRemotePhp": [True],
"emailNeeded": True,
"extraEnvironment": {
Expand All @@ -122,45 +122,45 @@ config = {
"apiGraph",
"apiServiceAvailability",
],
"skip": False,
"skip": True,
"withRemotePhp": [True],
},
"graphUserGroup": {
"suites": [
"apiGraphUserGroup",
],
"skip": False,
"skip": True,
"withRemotePhp": [True],
},
"spaces": {
"suites": [
"apiSpaces",
],
"skip": False,
"skip": True,
},
"spacesShares": {
"suites": [
"apiSpacesShares",
],
"skip": False,
"skip": True,
},
"spacesDavOperation": {
"suites": [
"apiSpacesDavOperation",
],
"skip": False,
"skip": True,
},
"search1": {
"suites": [
"apiSearch1",
],
"skip": False,
"skip": True,
},
"search2": {
"suites": [
"apiSearch2",
],
"skip": False,
"skip": True,
},
"sharingNg": {
"suites": [
Expand All @@ -169,23 +169,23 @@ config = {
"apiSharingNg2",
"apiOptionalShareRole",
],
"skip": False,
"skip": True,
},
"sharingNgShareInvitation": {
"suites": [
"apiSharingNgShareInvitation",
],
"skip": False,
"skip": True,
},
"sharingNgLinkShare": {
"suites": [
"apiSharingNgLinkSharePermission",
"apiSharingNgLinkShareRoot",
],
"skip": False,
"skip": True,
},
"accountsHashDifficulty": {
"skip": False,
"skip": True,
"suites": [
"apiAccountsHashDifficulty",
],
Expand Down Expand Up @@ -215,7 +215,7 @@ config = {
"suites": [
"apiAntivirus",
],
"skip": False,
"skip": True,
"antivirusNeeded": True,
"extraServerEnvironment": {
"ANTIVIRUS_SCANNER_TYPE": "clamav",
Expand All @@ -230,14 +230,14 @@ config = {
"suites": [
"apiSearchContent",
],
"skip": False,
"skip": True,
"tikaNeeded": True,
},
"ocm": {
"suites": [
"apiOcm",
],
"skip": False,
"skip": True,
"withRemotePhp": [True],
"federationServer": True,
"emailNeeded": True,
Expand All @@ -263,7 +263,7 @@ config = {
"suites": [
"apiCollaboration",
],
"skip": False,
"skip": True,
"collaborationServiceNeeded": True,
"extraServerEnvironment": {
"GATEWAY_GRPC_ADDR": "0.0.0.0:9142",
Expand All @@ -273,7 +273,7 @@ config = {
"suites": [
"apiAuthApp",
],
"skip": False,
"skip": True,
"withRemotePhp": [True],
"extraServerEnvironment": {
"OCIS_ADD_RUN_SERVICES": "auth-app",
Expand Down Expand Up @@ -307,24 +307,24 @@ config = {
},
"apiTests": {
"numberOfParts": 7,
"skip": False,
"skip": True,
"skipExceptParts": [],
},
"e2eTests": {
"part": {
"skip": False,
"skip": True,
"totalParts": 4, # divide and run all suites in parts (divide pipelines)
"xsuites": ["search", "app-provider", "oidc", "ocm"], # suites to skip
},
"search": {
"skip": False,
"skip": True,
"suites": ["search"], # suites to run
"tikaNeeded": True,
},
},
"e2eMultiService": {
"testSuites": {
"skip": False,
"skip": True,
"suites": [
"smoke",
"shares",
Expand Down
83 changes: 57 additions & 26 deletions tests/acceptance/bootstrap/SpacesContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -2695,32 +2695,8 @@ public function userExpiresTheLastShareOfResourceInsideOfTheSpace(
string $resource,
string $spaceName
): void {
$dateTime = new DateTime('yesterday');
$rows['expireDate'] = $dateTime->format('Y-m-d\\TH:i:sP');
if ($this->featureContext->isUsingSharingNG()) {
$space = $this->getSpaceByName($user, $spaceName);
$itemId = $this->getResourceId($user, $spaceName, $resource);
$body['expirationDateTime'] = $rows['expireDate'];
$permissionID = $this->featureContext->shareNgGetLastCreatedUserGroupShareID();
$response = GraphHelper::updateShare(
$this->featureContext->getBaseUrl(),
$this->featureContext->getStepLineRef(),
$user,
$this->featureContext->getPasswordForUser($user),
$space["id"],
$itemId,
\json_encode($body),
$permissionID
);

if ($response->getStatusCode() === 200) {
$this->featureContext->shareNgAddToCreatedUserGroupShares($response);
}
$this->featureContext->setResponse($response);
} else {
$rows['permissions'] = (string)$this->featureContext->getLastCreatedUserGroupShare()->permissions;
$this->featureContext->setResponse($this->updateSharedResource($user, $rows));
}
$response = $this->expireResourceShare($user, $resource, $spaceName);
$this->featureContext->setResponse($response);
}

/**
Expand Down Expand Up @@ -4829,4 +4805,59 @@ public function userHasExpiredTheMembershipOfUserFromSpace(
$rows['shareWith'] = $memberUser;
$this->featureContext->setResponse($this->shareSpace($user, $spaceName, $rows));
}

/**
* @param string $user
* @param string $resource
* @param string $spaceName
*
* @return ResponseInterface
* @throws GuzzleException|JsonException
*/
public function expireResourceShare(string $user, string $resource, string $spaceName): ResponseInterface {
$rows['expireDate'] = $this->featureContext->formatExpiryDateTime('Y-m-d\\TH:i:sP');
if ($this->featureContext->isUsingSharingNG()) {
$space = $this->getSpaceByName($user, $spaceName);
$itemId = $this->getResourceId($user, $spaceName, $resource);
$body['expirationDateTime'] = $rows['expireDate'];
$permissionID = $this->featureContext->shareNgGetLastCreatedUserGroupShareID();
$response = GraphHelper::updateShare(
$this->featureContext->getBaseUrl(),
$this->featureContext->getStepLineRef(),
$user,
$this->featureContext->getPasswordForUser($user),
$space["id"],
$itemId,
\json_encode($body),
$permissionID
);

if ($response->getStatusCode() === 200) {
$this->featureContext->shareNgAddToCreatedUserGroupShares($response);
}
return $response;
} else {
$rows['permissions'] = (string)$this->featureContext->getLastCreatedUserGroupShare()->permissions;
return $this->updateSharedResource($user, $rows);
}
}

/**
* @Given user :user has expired the last share of resource :resource inside of the space :spaceName
*
* @param string $user
* @param string $resource
* @param string $spaceName
*
* @return void
* @throws GuzzleException|JsonException
*/
public function userHasExpiredTheLastShareOfResourceInsideOfTheSpace(
string $user,
string $resource,
string $spaceName
): void {
$response = $this->expireResourceShare($user, $resource, $spaceName);
$this->featureContext->theHTTPStatusCodeShouldBe(200, "", $response);
}
}
16 changes: 16 additions & 0 deletions tests/acceptance/features/cliCommands/emailNotification.feature
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,14 @@ Feature: get grouped email notification
| shareType | user |
| permissionsRole | Viewer |
And user "Alice" has removed the access of user "Brian" from resource "lorem.txt" of space "Personal"
And user "Alice" has sent the following resource share invitation:
| resource | lorem.txt |
| space | Personal |
| sharee | Brian |
| shareType | user |
| permissionsRole | Viewer |
| expirationDateTime | 2042-01-01T23:59:59.000Z |
And user "Alice" has expired the last share of resource "lorem.txt" inside of the space "Personal"
And user "Alice" has sent the following space share invitation:
| space | New-Space |
| sharee | Brian |
Expand Down Expand Up @@ -80,6 +88,14 @@ Feature: get grouped email notification
| shareType | user |
| permissionsRole | Viewer |
And user "Alice" has removed the access of user "Brian" from resource "lorem.txt" of space "Personal"
And user "Alice" has sent the following resource share invitation:
| resource | lorem.txt |
| space | Personal |
| sharee | Brian |
| shareType | user |
| permissionsRole | Viewer |
| expirationDateTime | 2042-01-01T23:59:59.000Z |
And user "Alice" has expired the last share of resource "lorem.txt" inside of the space "Personal"
And user "Alice" has sent the following space share invitation:
| space | New-Space |
| sharee | Brian |
Expand Down