From 438e445a1cd2d4b0a045ace155124118205d602d Mon Sep 17 00:00:00 2001 From: Viktor Scharf Date: Thu, 12 Sep 2024 10:08:43 +0200 Subject: [PATCH 1/3] fix after review --- .drone.star | 12 ++++++- tests/acceptance/TestHelpers/OcmHelper.php | 2 +- tests/acceptance/bootstrap/FeatureContext.php | 9 +++-- tests/acceptance/bootstrap/OcmContext.php | 9 ++++- .../features/apiOcm/createInvitation.feature | 34 +++++++++++++------ 5 files changed, 50 insertions(+), 16 deletions(-) diff --git a/.drone.star b/.drone.star index b8cc719fbc..15dc8c882f 100644 --- a/.drone.star +++ b/.drone.star @@ -148,13 +148,23 @@ config = { ], "skip": False, "federationServer": True, + "emailNeeded": True, + "extraEnvironment": { + "EMAIL_HOST": "email", + "EMAIL_PORT": "9000", + }, "extraServerEnvironment": { - "OCIS_ADD_RUN_SERVICES": "ocm", + "OCIS_ADD_RUN_SERVICES": "ocm,notifications", "OCIS_ENABLE_OCM": True, "OCM_OCM_INVITE_MANAGER_INSECURE": True, "OCM_OCM_SHARE_PROVIDER_INSECURE": True, "OCM_OCM_STORAGE_PROVIDER_INSECURE": True, "OCM_OCM_PROVIDER_AUTHORIZER_PROVIDERS_FILE": "%s" % dirs["ocmProviders"], + # mail notifications + "NOTIFICATIONS_SMTP_HOST": "email", + "NOTIFICATIONS_SMTP_PORT": "2500", + "NOTIFICATIONS_SMTP_INSECURE": "true", + "NOTIFICATIONS_SMTP_SENDER": "ownCloud ", }, }, "apiWopi": { diff --git a/tests/acceptance/TestHelpers/OcmHelper.php b/tests/acceptance/TestHelpers/OcmHelper.php index 045372b398..9387a285d4 100644 --- a/tests/acceptance/TestHelpers/OcmHelper.php +++ b/tests/acceptance/TestHelpers/OcmHelper.php @@ -58,7 +58,7 @@ class OcmHelper { ?string $email = null, ?string $description = null ): ResponseInterface { - $body['params'] = [ + $body = [ "description" => $description, "recipient" => $email ]; diff --git a/tests/acceptance/bootstrap/FeatureContext.php b/tests/acceptance/bootstrap/FeatureContext.php index f7a16ef3c9..92dc208b46 100644 --- a/tests/acceptance/bootstrap/FeatureContext.php +++ b/tests/acceptance/bootstrap/FeatureContext.php @@ -162,6 +162,7 @@ class FeatureContext extends BehatVariablesContext { public TUSContext $tusContext; public GraphContext $graphContext; public SpacesContext $spacesContext; + public OcmContext $ocmContext; /** * The codes are stored as strings, even though they are numbers @@ -2318,10 +2319,10 @@ class FeatureContext extends BehatVariablesContext { "parameter" => [] ], [ - "code" => "%fed_invitation_token_pattern%", + "code" => "%fed_invitation_token%", "function" => [ - __NAMESPACE__ . '\TestHelpers\GraphHelper', - "getUUIDv4Regex" + $this->ocmContext, + "getLastFederatedInvitationToken" ], "parameter" => [] ], @@ -2530,12 +2531,14 @@ class FeatureContext extends BehatVariablesContext { $this->ocsContext = new OCSContext(); $this->authContext = new AuthContext(); $this->tusContext = new TUSContext(); + $this->ocmContext = new OcmContext(); $this->ocsContext->before($scope); $this->authContext->setUpScenario($scope); $this->tusContext->setUpScenario($scope); $environment->registerContext($this->ocsContext); $environment->registerContext($this->authContext); $environment->registerContext($this->tusContext); + $environment->registerContext($this->ocmContext); $scenarioLine = $scope->getScenario()->getLine(); $featureFile = $scope->getFeature()->getFile(); $suiteName = $scope->getSuite()->getName(); diff --git a/tests/acceptance/bootstrap/OcmContext.php b/tests/acceptance/bootstrap/OcmContext.php index 7447d7ab24..4105b0ae68 100644 --- a/tests/acceptance/bootstrap/OcmContext.php +++ b/tests/acceptance/bootstrap/OcmContext.php @@ -68,6 +68,13 @@ class OcmContext implements Context { return $this->extractDomain(\getenv('TEST_SERVER_FED_URL')); } + /** + * @return string + */ + public function getLastFederatedInvitationToken():string { + return $this->invitationToken; + } + /** * @param string $url * @@ -151,7 +158,7 @@ class OcmContext implements Context { $this->featureContext->getStepLineRef(), $user, $this->featureContext->getPasswordForUser($user), - $token ? $token : $this->invitationToken, + $token ? $token : $this->getLastFederatedInvitationToken(), $providerDomain ); } diff --git a/tests/acceptance/features/apiOcm/createInvitation.feature b/tests/acceptance/features/apiOcm/createInvitation.feature index 14ffb01816..ed62a3fd0c 100755 --- a/tests/acceptance/features/apiOcm/createInvitation.feature +++ b/tests/acceptance/features/apiOcm/createInvitation.feature @@ -26,7 +26,7 @@ Feature: create invitation }, "token": { "type": "string", - "pattern": "^%fed_invitation_token_pattern%$" + "pattern": "%fed_invitation_token%" } } } @@ -52,7 +52,7 @@ Feature: create invitation }, "token": { "type": "string", - "pattern": "^%fed_invitation_token_pattern%$" + "pattern": "%fed_invitation_token%" } } } @@ -81,17 +81,18 @@ Feature: create invitation }, "token": { "type": "string", - "pattern": "^%fed_invitation_token_pattern%$" + "pattern": "%fed_invitation_token%" }, "description": { "const": "a share invitation from Alice" }, - "recipient": { + "description": { "const": "brian@example.com" } } } """ + When "Alice" lists the created invitations And the HTTP status code should be "200" And the JSON data of the response should match """ @@ -103,7 +104,8 @@ Feature: create invitation "type": "object", "required": [ "expiration", - "token" + "token", + "description" ], "properties": { "expiration": { @@ -112,19 +114,31 @@ Feature: create invitation }, "token": { "type": "string", - "pattern": "^%fed_invitation_token_pattern%$" + "pattern": "%fed_invitation_token%" }, "description": { "const": "a share invitation from Alice" - }, - "recipient": { - "const": "brian@example.com" } } } } """ + @email + 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" + """ + Hi, + + Alice Hansen (alice@example.org) wants to start sharing collaboration resources with you. + + Please visit your federation provider and use the following details: + Token: %fed_invitation_token% + ProviderDomain: https://ocis-server:9200 + """ + @env-config Scenario: user cannot see expired invitation tokens Given using server "LOCAL" @@ -146,7 +160,7 @@ Feature: create invitation }, "token": { "type": "string", - "pattern": "^%fed_invitation_token_pattern%$" + "pattern": "%fed_invitation_token%" } } } From 16f3535d460f3abc4a6e78815cd8d6f70a628af2 Mon Sep 17 00:00:00 2001 From: Viktor Scharf Date: Fri, 13 Sep 2024 09:11:53 +0200 Subject: [PATCH 2/3] added missed config --- tests/acceptance/config/behat.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/acceptance/config/behat.yml b/tests/acceptance/config/behat.yml index aed0c8034f..d80a794465 100644 --- a/tests/acceptance/config/behat.yml +++ b/tests/acceptance/config/behat.yml @@ -391,6 +391,8 @@ default: - SharingNgContext: - SpacesContext: - OcisConfigContext: + - NotificationContext: + - SettingsContext: apiActivities: paths: From 03763331e56ffeae1be33decf746eaec9fc40936 Mon Sep 17 00:00:00 2001 From: Viktor Scharf Date: Fri, 13 Sep 2024 11:22:43 +0200 Subject: [PATCH 3/3] fix --- tests/acceptance/features/apiOcm/createInvitation.feature | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/acceptance/features/apiOcm/createInvitation.feature b/tests/acceptance/features/apiOcm/createInvitation.feature index ed62a3fd0c..7c35d7f206 100755 --- a/tests/acceptance/features/apiOcm/createInvitation.feature +++ b/tests/acceptance/features/apiOcm/createInvitation.feature @@ -133,7 +133,6 @@ Feature: create invitation Hi, Alice Hansen (alice@example.org) wants to start sharing collaboration resources with you. - Please visit your federation provider and use the following details: Token: %fed_invitation_token% ProviderDomain: https://ocis-server:9200