Skip to content

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

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

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
83 changes: 57 additions & 26 deletions tests/acceptance/bootstrap/SpacesContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -2700,32 +2700,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 @@ -4834,4 +4810,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');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$rows['expireDate'] = $this->featureContext->formatExpiryDateTime('Y-m-d\\TH:i:sP');
$rows['expireDate'] = $this->featureContext->formatExpiryDateTime('Y-m-d\\TH:i:sP');

Can we run tests locally with this format?
Do we even care about timezone P represents the timezone offset (e.g., +00:00, -05:00).
Could you try this format $date->format('Y-m-d H:i:s');

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);
}
}
26 changes: 26 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 @@ -54,6 +62,11 @@ Feature: get grouped email notification
Even though this share has been revoked you still might have access through other shares and/or space memberships.


Your share to "lorem.txt" has expired at %expiry_date_in_mail%

Even though this share has been revoked you still might have access through other shares and/or space memberships.


Alice Hansen has invited you to join "New-Space".


Expand All @@ -80,6 +93,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 @@ -108,6 +129,11 @@ Feature: get grouped email notification
Even though this share has been revoked you still might have access through other shares and/or space memberships.


Your share to "lorem.txt" has expired at %expiry_date_in_mail%

Even though this share has been revoked you still might have access through other shares and/or space memberships.


Alice Hansen has invited you to join "New-Space".


Expand Down