fix issue/10059

This commit is contained in:
Viktor Scharf
2024-09-16 14:51:36 +02:00
parent 052644a1a2
commit 0c4242d4bb
4 changed files with 42 additions and 4 deletions

View File

@@ -513,17 +513,41 @@ class NotificationContext implements Context {
$this->assertEmailContains($user, $expectedEmailBodyContent);
}
/**
* @Then user :user should have received the following email from user :sender ignoring whitespaces
*
* @param string $user
* @param string $sender
* @param PyStringNode $content
*
* @return void
* @throws Exception
*/
public function userShouldHaveReceivedTheFollowingEmailFromUserIgnoringWhitespaces(string $user, string $sender, PyStringNode $content):void {
$rawExpectedEmailBodyContent = \str_replace("\r\n", "\n", $content->getRaw());
$expectedEmailBodyContent = $this->featureContext->substituteInLineCodes(
$rawExpectedEmailBodyContent,
$sender
);
$this->assertEmailContains($user, $expectedEmailBodyContent, true);
}
/***
* @param string $user
* @param string $expectedEmailBodyContent
* @param bool $ignoreWhiteSpace
*
* @return void
* @throws GuzzleException
*/
public function assertEmailContains(string $user, string $expectedEmailBodyContent):void {
public function assertEmailContains(string $user, string $expectedEmailBodyContent, $ignoreWhiteSpace = false):void {
$address = $this->featureContext->getEmailAddressForUser($user);
$this->featureContext->pushEmailRecipientAsMailBox($address);
$actualEmailBodyContent = EmailHelper::getBodyOfLastEmail($address, $this->featureContext->getStepLineRef());
if ($ignoreWhiteSpace) {
$expectedEmailBodyContent = preg_replace('/\s+/', '', $expectedEmailBodyContent);
$actualEmailBodyContent = preg_replace('/\s+/', '', $actualEmailBodyContent);
}
Assert::assertStringContainsString(
$expectedEmailBodyContent,
$actualEmailBodyContent,

View File

@@ -32,6 +32,7 @@ use TestHelpers\WebDavHelper;
*/
class OcmContext implements Context {
private FeatureContext $featureContext;
private NotificationContext $notificationContext;
private string $invitationToken;
/**
@@ -52,6 +53,18 @@ class OcmContext implements Context {
$environment = $scope->getEnvironment();
// Get all the contexts you need in this context from here
$this->featureContext = $environment->getContext('FeatureContext');
$this->notificationContext = $environment->getContext('NotificationContext');
}
/**
* Delete all the inbucket emails
*
* @AfterScenario @email
*
* @return void
*/
public function clearInbucketMessages():void {
$this->notificationContext->clearInbucketMessages();
}
/**

View File

@@ -200,6 +200,7 @@ default:
- SettingsContext:
- OcisConfigContext:
- SharingNgContext:
- OcmContext:
apiAntivirus:
paths:

View File

@@ -134,17 +134,17 @@ Feature: create invitation
| @domain.com | 400 |
| user@domain..com | 400 |
@email @skip
@email @issue-10059
Scenario: federated user gets an email notification if their email was specified when creating the federation share invitation
Given using server "LOCAL"
When "Alice" has created the federation share invitation with email "brian@example.com" and description "a share invitation from Alice"
And user "Brian" should have received the following email from user "Alice"
And user "Brian" should have received the following email from user "Alice" ignoring whitespaces
"""
Hi,
Alice Hansen (alice@example.org) wants to start sharing collaboration resources with you.
Please visit your federation provider and use the following details:
Please visit your federation settings and use the following details:
Token: %fed_invitation_token%
ProviderDomain: https://ocis-server:9200
"""