refactor code to handle single notification event
This commit is contained in:
5 files changed
+64
-49
No files matched your search
@@ -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
|
||||
```
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -13,8 +13,9 @@ Feature: enable/disable malware related notification
|
||||
|
||||
Scenario Outline: disable in-app notification for "File rejected" event
|
||||
Given using <dav-path-version> 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
|
||||
"""
|
||||
|
||||
@@ -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
|
||||
"""
|
||||
|
||||
@@ -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
|
||||
"""
|
||||
|
||||
Reference in new issue
Block a user