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] Add tests for share expiry #10935

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
26 changes: 18 additions & 8 deletions tests/acceptance/bootstrap/FeatureContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -2500,6 +2500,14 @@ public function substituteInLineCodes(
"getXRequestIdRegex"
],
"parameter" => []
],
[
"code" => "%expirationDateTime%",
"function" => [
$this->spacesContext,
"getLastShareExpirationDateTime"
],
"parameter" => []
]
];
if ($user !== null) {
Expand Down Expand Up @@ -2546,16 +2554,18 @@ public function substituteInLineCodes(
"parameter" => [$user, true]
],
[
"code" => "%user_id%",
"function" =>
[$this, "getUserIdByUserName"],
"parameter" => [$userName]
"code" => "%user_id%",
"function" => [
$this, "getUserIdByUserName"
],
"parameter" => [$userName]
],
[
"code" => "%group_id%",
"function" =>
[$this, "getGroupIdByGroupName"],
"parameter" => [$group]
"code" => "%group_id%",
"function" => [
$this, "getGroupIdByGroupName"
],
"parameter" => [$group]
]
);

Expand Down
36 changes: 25 additions & 11 deletions tests/acceptance/bootstrap/SpacesContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,15 @@ class SpacesContext implements Context {
*/
private array $storedEtags = [];

private string $lastShareExpirationDateTime = '';

/**
* @return string
*/
public function getLastShareExpirationDateTime(): string {
return $this->lastShareExpirationDateTime;
}

/**
* @param string $spaceName
*
Expand Down Expand Up @@ -2666,18 +2675,23 @@ public function userExpiresTheLastShareOfResourceInsideOfTheSpace(
$itemId = $this->getResourceId($user, $spaceName, $resource);
$body['expirationDateTime'] = $rows['expireDate'];
$permissionID = $this->featureContext->shareNgGetLastCreatedUserGroupShareID();
$this->featureContext->setResponse(
GraphHelper::updateShare(
$this->featureContext->getBaseUrl(),
$this->featureContext->getStepLineRef(),
$user,
$this->featureContext->getPasswordForUser($user),
$space["id"],
$itemId,
\json_encode($body),
$permissionID
)
$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) {
$shareExpireResponse = json_decode($response->getBody()->getContents(), true);
$date = new DateTimeImmutable($shareExpireResponse['expirationDateTime']);
$this->lastShareExpirationDateTime = $date->format('Y-m-d H:i:s');
}
$this->featureContext->setResponse($response);
} else {
$rows['permissions'] = (string)$this->featureContext->getLastCreatedUserGroupShare()->permissions;
$this->featureContext->setResponse($this->updateSharedResource($user, $rows));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ Feature: Notification
| username |
| Alice |
| Brian |
| Carol |
And user "Alice" has uploaded file with content "other data" to "/textfile1.txt"
And user "Alice" has created folder "my_data"

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
@notification @email
Feature: Share Expiry Notification
As a user
I want to be notified when share expires
So that I can stay updated about the share

Background:
Given these users have been created with default attributes:
| username |
| Alice |
| Brian |


Scenario: check share expired in-app and mail notifications for Personal space resource
Given using SharingNG
And user "Alice" has uploaded file with content "hello world" to "testfile.txt"
And user "Alice" has sent the following resource share invitation:
| resource | testfile.txt |
| space | Personal |
| sharee | Brian |
| shareType | user |
| permissionsRole | Viewer |
| expirationDateTime | 2025-07-15T14:00:00Z |
When user "Alice" expires the last share of resource "testfile.txt" inside of the space "Personal"
Then the HTTP status code should be "200"
And user "Brian" should get a notification with subject "Membership expired" and message:
| message |
| Access to Space Alice Hansen lost |
Copy link
Member

Choose a reason for hiding this comment

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

Access to Space Alice Hansen lost

the message doesn't seem to align with the action. It should similar to Access to testfile.txt expired

Copy link
Contributor Author

@amrita-shrestha amrita-shrestha Feb 11, 2025

Choose a reason for hiding this comment

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

did you forget our last discussion regarding this current behavior,. I have raise question on bug report but no reply came, so assuming this current behavior, scenario has been written.
Don't forget to ask directly to developer in standup, if you want instant reply 😄

Copy link
Member

Choose a reason for hiding this comment

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

then we should not merge this PR until the expected behavior is confirmed

And user "Brian" should have "2" emails
amrita-shrestha marked this conversation as resolved.
Show resolved Hide resolved
And user "Brian" should have received the following email from user "Alice"
"""
Hello Brian Murphy,

Your membership of space %displayname% has expired at %expirationDateTime%

Even though this membership has expired you still might have access through other shares and/or space memberships
"""