diff --git a/docs/ocis/development/testing.md b/docs/ocis/development/testing.md index c4c37faca0a..367f608f04d 100644 --- a/docs/ocis/development/testing.md +++ b/docs/ocis/development/testing.md @@ -483,7 +483,7 @@ ANTIVIRUS_SCANNER_TYPE="clamav" \ ANTIVIRUS_CLAMAV_SOCKET="tcp://host.docker.internal:3310" \ POSTPROCESSING_STEPS="virusscan" \ OCIS_ASYNC_UPLOADS=true \ -OCIS_ADD_RUN_SERVICES="antivirus" +OCIS_ADD_RUN_SERVICES="antivirus" \ ocis/bin/ocis server ``` diff --git a/tests/acceptance/bootstrap/SettingsContext.php b/tests/acceptance/bootstrap/SettingsContext.php index 22c2c0eb841..5341832ce98 100644 --- a/tests/acceptance/bootstrap/SettingsContext.php +++ b/tests/acceptance/bootstrap/SettingsContext.php @@ -584,7 +584,7 @@ class SettingsContext implements Context { } /** - * @When /^user "([^"]*)" (disables|enables) notification for the following events using the settings API:$/ + * @When /^user "([^"]*)" (disables|enables) notification for the following event using the settings API:$/ * * @param string $user * @param string $enableOrDisable @@ -592,41 +592,46 @@ class SettingsContext implements Context { * * @return void */ - public function userDisablesNotificationForFollowingEventUsingSettingsApi( + public function userDisablesNotificationForTheFollowingEventUsingSettingsApi( string $user, string $enableOrDisable, TableNode $table ): void { $settings = $table->getRowsHash(); - Assert::assertCount(1, $settings, "only 1 event should be provided"); - foreach ($settings as $event => $value) { - $body = [ - "value" => [ - "account_uuid" => "me", - "bundleId" => SettingsHelper::getBundleId(), - "settingId" => SettingsHelper::getSettingIdUsingEventName($event), - "resource" => [ - "type" => "TYPE_USER" - ] + $body = [ + "value" => [ + "account_uuid" => "me", + "bundleId" => SettingsHelper::getBundleId(), + "settingId" => SettingsHelper::getSettingIdUsingEventName($settings['event']), + "resource" => [ + "type" => "TYPE_USER" ] - ]; - if (str_contains($value, "mail")) { - $body["value"]["collectionValue"]["values"][] - = ["key" => "mail","boolValue" => $enableOrDisable === "enables"]; + ] + ]; + $notificationTypes = explode(',', $settings['notificationTypes']); + + foreach ($notificationTypes as $type) { + if ($type === "mail") { + $body["value"]["collectionValue"]["values"][] = [ + "key" => "mail", + "boolValue" => $enableOrDisable === "enables" + ]; + } elseif ($type === "in-app") { + $body["value"]["collectionValue"]["values"][] = [ + "key" => "in-app", + "boolValue" => $enableOrDisable === "enables" + ]; } - if (str_contains($value, "in-app")) { - $body["value"]["collectionValue"]["values"][] - = ["key" => "in-app","boolValue" => $enableOrDisable === "enables"]; - } - $response = SettingsHelper::updateSettings( - $this->featureContext->getBaseUrl(), - $this->featureContext->getActualUsername($user), - $this->featureContext->getPasswordForUser($user), - json_encode($body), - $this->featureContext->getStepLineRef(), - ); - $this->featureContext->setResponse($response); } + + $response = SettingsHelper::updateSettings( + $this->featureContext->getBaseUrl(), + $this->featureContext->getActualUsername($user), + $this->featureContext->getPasswordForUser($user), + json_encode($body), + $this->featureContext->getStepLineRef(), + ); + $this->featureContext->setResponse($response); } /** diff --git a/tests/acceptance/features/apiAntivirus/enableDisableNotification.feature b/tests/acceptance/features/apiAntivirus/enableDisableNotification.feature index b03151ce76c..56063a122d4 100644 --- a/tests/acceptance/features/apiAntivirus/enableDisableNotification.feature +++ b/tests/acceptance/features/apiAntivirus/enableDisableNotification.feature @@ -13,8 +13,9 @@ Feature: enable/disable malware related notification Scenario Outline: disable in-app notification for "File rejected" event Given using DAV path - When user "Brian" disables notification for the following events using the settings API: - | File Rejected | in-app | + When user "Brian" disables notification for the following event using the settings API: + | event | File Rejected | + | notificationTypes | in-app | Then the HTTP status code should be "201" And the JSON data of the response should match """ @@ -99,8 +100,9 @@ Feature: enable/disable malware related notification | sharee | Brian | | shareType | user | | permissionsRole | Space Editor | - When user "Brian" disables notification for the following events using the settings API: - | File Rejected | in-app | + When user "Brian" disables notification for the following event using the settings API: + | event | File Rejected | + | notificationTypes | in-app | Then the HTTP status code should be "201" And the JSON data of the response should match """ diff --git a/tests/acceptance/features/apiOcm/ocmNotifications.feature b/tests/acceptance/features/apiOcm/ocmNotifications.feature index b6c67d3dd7d..a8dfbcb6f68 100644 --- a/tests/acceptance/features/apiOcm/ocmNotifications.feature +++ b/tests/acceptance/features/apiOcm/ocmNotifications.feature @@ -14,8 +14,9 @@ Feature: ocm notifications And using server "REMOTE" And user "Brian" has been created with default attributes And "Brian" has accepted invitation - When user "Brian" disables notification for the following events using the settings API: - | Share Received | mail,in-app | + When user "Brian" disables notification for the following event using the settings API: + | event | Share Received | + | notificationTypes | mail,in-app | Then the HTTP status code should be "201" And the JSON data of the response should match """ diff --git a/tests/acceptance/features/apiSettings/notificationSetting.feature b/tests/acceptance/features/apiSettings/notificationSetting.feature index c495469e5ba..290f7587adc 100644 --- a/tests/acceptance/features/apiSettings/notificationSetting.feature +++ b/tests/acceptance/features/apiSettings/notificationSetting.feature @@ -66,8 +66,9 @@ Feature: Notification Settings @email Scenario: disable mail and in-app notification for "Share Received" event - When user "Brian" disables notification for the following events using the settings API: - | Share Received | mail,in-app | + When user "Brian" disables notification for the following event using the settings API: + | event | Share Received | + | notificationTypes | mail,in-app | Then the HTTP status code should be "201" And the JSON data of the response should match """ @@ -161,8 +162,9 @@ Feature: Notification Settings | sharee | Brian | | shareType | user | | permissionsRole | Viewer | - When user "Brian" disables notification for the following events using the settings API: - | Share Removed | mail, in-app | + When user "Brian" disables notification for the following event using the settings API: + | event | Share Removed | + | notificationTypes | mail,in-app | Then the HTTP status code should be "201" And the JSON data of the response should match """ @@ -256,8 +258,9 @@ Feature: Notification Settings | sharee | Brian | | shareType | user | | permissionsRole | Viewer | - When user "Brian" disables notification for the following events using the settings API: - | Share Removed | mail, in-app | + When user "Brian" disables notification for the following event using the settings API: + | event | Share Removed | + | notificationTypes | mail,in-app | Then the HTTP status code should be "201" And the JSON data of the response should match """ @@ -348,8 +351,9 @@ Feature: Notification Settings | sharee | Brian | | shareType | user | | permissionsRole | Space Viewer | - When user "Brian" disables notification for the following events using the settings API: - | Space Disabled | in-app | + When user "Brian" disables notification for the following event using the settings API: + | event | Space Disabled | + | notificationTypes | in-app | Then the HTTP status code should be "201" And the JSON data of the response should match """ @@ -496,8 +500,9 @@ Feature: Notification Settings Given using spaces DAV path And the administrator has assigned the role "Space Admin" to user "Alice" using the Graph API And user "Alice" has created a space "newSpace" with the default quota using the Graph API - When user "Brian" disables notification for the following events using the settings API: - | Added As Space Member | mail,in-app | + When user "Brian" disables notification for the following event using the settings API: + | event | Added As Space Member | + | notificationTypes | mail,in-app | Then the HTTP status code should be "201" And the JSON data of the response should match """ @@ -649,8 +654,9 @@ Feature: Notification Settings | sharee | Brian | | shareType | user | | permissionsRole | Space Viewer | - When user "Brian" disables notification for the following events using the settings API: - | Removed As Space Member | mail,in-app | + When user "Brian" disables notification for the following event using the settings API: + | event | Removed As Space Member | + | notificationTypes | mail,in-app | Then the HTTP status code should be "201" And the JSON data of the response should match """ @@ -750,8 +756,9 @@ Feature: Notification Settings | sharee | Brian | | shareType | user | | permissionsRole | Space Viewer | - When user "Brian" disables notification for the following events using the settings API: - | Space Membership Expired | mail,in-app | + When user "Brian" disables notification for the following event using the settings API: + | event | Space Membership Expired | + | notificationTypes | mail,in-app | Then the HTTP status code should be "201" And the JSON data of the response should match """