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

[test-only][full-ci] Api tests. get notification on different languages #6254

Merged
merged 6 commits into from
May 17, 2023
Merged
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
14 changes: 7 additions & 7 deletions tests/acceptance/config/behat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ default:
ldapGroupsOU: TestGroups
ldapInitialUserFilePath: /../../config/ldap-users.ldif
contexts:
- RoleAssignmentContext:
- SettingsContext:
- GraphContext:
- SpacesContext:
- FeatureContext: &common_feature_context_params
Expand All @@ -37,7 +37,7 @@ default:
- '%paths.base%/../features/apiSpaces'
context: *common_ldap_suite_context
contexts:
- RoleAssignmentContext:
- SettingsContext:
- SpacesContext:
- FeatureContext: *common_feature_context_params
- CapabilitiesContext:
Expand All @@ -60,7 +60,7 @@ default:
- '%paths.base%/../features/apiSpacesShares'
context: *common_ldap_suite_context
contexts:
- RoleAssignmentContext:
- SettingsContext:
- SpacesContext:
- FeatureContext: *common_feature_context_params
- CapabilitiesContext:
Expand All @@ -82,7 +82,7 @@ default:
- '%paths.base%/../features/apiContract'
context: *common_ldap_suite_context
contexts:
- RoleAssignmentContext:
- SettingsContext:
- SpacesContext:
- FeatureContext: *common_feature_context_params
- CapabilitiesContext:
Expand All @@ -103,7 +103,7 @@ default:
- '%paths.base%/../features/apiArchiver'
context: *common_ldap_suite_context
contexts:
- RoleAssignmentContext:
- SettingsContext:
- ArchiverContext:
- SpacesContext:
- FeatureContext: *common_feature_context_params
Expand All @@ -122,7 +122,7 @@ default:
- '%paths.base%/../features/apiGraph'
context: *common_ldap_suite_context
contexts:
- RoleAssignmentContext:
- SettingsContext:
ScharfViktor marked this conversation as resolved.
Show resolved Hide resolved
- GraphContext:
- SpacesContext:
- FeatureContext: *common_feature_context_params
Expand Down Expand Up @@ -185,7 +185,7 @@ default:
- FavoritesContext:
- ChecksumContext:
- FilesVersionsContext:
- RoleAssignmentContext:
- SettingsContext:

extensions:
rdx\behatvars\BehatVariablesExtension: ~
Expand Down
246 changes: 149 additions & 97 deletions tests/acceptance/features/apiSpaces/notification.feature
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@api
@api
Feature: Notification
As a user
I want to be notified of actions related to me
Expand All @@ -21,108 +21,160 @@ Feature: Notification
When user "Brian" lists all notifications
Then the HTTP status code should be "200"
And the JSON response should contain a notification message with the subject "Space shared" and the message-details should match
"""
{
"type": "object",
"required": [
"app",
"datetime",
"message",
"messageRich",
"messageRichParameters",
"notification_id",
"object_id",
"object_type",
"subject",
"subjectRich",
"user"
],
"properties": {
"app": {
"type": "string",
"enum": ["userlog"]
},
"message": {
"type": "string",
"enum": ["Alice Hansen added you to Space notification checking"]
},
"messageRich": {
"type": "string",
"enum": ["{user} added you to Space {space}"]
},
"messageRichParameters": {
"type": "object",
"required": [
"space",
"user"
],
"properties": {
"space": {
"type": "object",
"required": [
"id",
"name"
],
"properties": {
"id": {
"type": "string",
"pattern": "^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}\\$[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}![a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$"
},
"name": {
"type": "string",
"enum": ["notification checking"]
"""
{
"type": "object",
"required": [
"app",
"datetime",
"message",
"messageRich",
"messageRichParameters",
"notification_id",
"object_id",
"object_type",
"subject",
"subjectRich",
"user"
],
"properties": {
"app": {
"type": "string",
"enum": [
"userlog"
]
},
"message": {
"type": "string",
"enum": [
"Alice Hansen added you to Space notification checking"
]
},
"messageRich": {
"type": "string",
"enum": [
"{user} added you to Space {space}"
]
},
"messageRichParameters": {
"type": "object",
"required": [
"space",
"user"
],
"properties": {
"space": {
"type": "object",
"required": [
"id",
"name"
],
"properties": {
"id": {
"type": "string",
"pattern": "^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}\\$[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}![a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$"
Copy link
Member

Choose a reason for hiding this comment

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

may be we can make a function and name what type of regex pattern is ths and substitute. may be we can use such pattern in other place as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's space id like 3db75261-afa8-4224-9c10-f8459fd047d7$1eb6a3e9-5dba-4887-b1b2-0c26d73d4e83!1eb6a3e9-5dba-4887-b1b2-0c26d73d4e83

We have pattern for checking spaceID but my spaceUUID contains ! . self::getUUIDv4Regex() -> maybe it is bug(because objectId is normal spaceId).

Screenshot 2023-05-16 at 21 57 37
public static function getSpaceIdRegex(): string {
		return self::getUUIDv4Regex() . '\\\$' . self::getUUIDv4Regex();

Otherwise I have to add something like:

public static function getFullSpaceIdRegex(): string {
		return self::getUUIDv4Regex() . '\\\$' . self::getUUIDv4Regex(). '\\\!' . self::getUUIDv4Regex();

},
"name": {
"type": "string",
"enum": [
"notification checking"
]
}
}
}
},
"user": {
"type": "object",
"required": [
"displayname",
"id",
"name"
],
"properties": {
"displayname": {
"type": "string",
"enum": ["Alice Hansen"]
},
"id": {
"type": "string",
"enim": ["%user_id%"]
},
"name": {
"type": "string",
"enum": ["Alice"]
},
"user": {
"type": "object",
"required": [
"displayname",
"id",
"name"
],
"properties": {
"displayname": {
"type": "string",
"enum": [
"Alice Hansen"
]
},
"id": {
"type": "string",
"enim": [
"%user_id%"
]
},
"name": {
"type": "string",
"enum": [
"Alice"
]
}
}
}
}
},
"notification_id": {
"type": "string"
},
"object_id": {
"type": "string",
"pattern": "^%space_id_pattern%$"
},
"object_type": {
"type": "string",
"enum": [
"storagespace"
]
},
"subject": {
"type": "string",
"enum": [
"Space shared"
]
},
"subjectRich": {
"type": "string",
"enum": [
"Space shared"
]
},
"user": {
"type": "string",
"enum": [
"Alice"
]
}
},
"notification_id": {
"type": "string"
}
}
"""

},
"object_id": {
"type": "string"

},
"object_type": {
"type": "string",
"enum": ["storagespace"]
},
"subject": {
"type": "string",
"enum": ["Space shared"]
},
"subjectRich": {
"type": "string",
"enum": ["Space shared"]
},
"user": {
"type": "string",
"enum": ["Alice"]
Scenario Outline: user gets a notification of space sharing in different languages
Given user "Alice" has created a space "notification checking" with the default quota using the GraphApi
And user "Brian" has switched the system language to "<language>"
And user "Alice" has shared a space "notification checking" with settings:
| shareWith | Brian |
| role | editor |
When user "Brian" lists all notifications
Then the HTTP status code should be "200"
And the JSON response should contain a notification message with the subject "<subject>" and the message-details should match
"""
{
"type": "object",
"required": [
"message"
],
"properties": {
"message": {
"type": "string",
"enum": [
"<message>"
]
}
}
}
}
"""

"""
Examples:
| language | subject | message |
| de | Space freigegeben | Alice Hansen hat Sie zu Space notification checking hinzugefügt |
| en | Space shared | Alice Hansen added you to Space notification checking |
| es | Space compartido | Alice Hansen te añadió al Space notification checking |
10 changes: 7 additions & 3 deletions tests/acceptance/features/bootstrap/NotificationContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,8 @@
*/
class NotificationContext implements Context {
private FeatureContext $featureContext;

private SpacesContext $spacesContext;

private SettingsContext $settingsContext;
private string $notificationEndpointPath = '/apps/notifications/api/v1/notifications?format=json';

private array $notificationIds;
Expand Down Expand Up @@ -78,6 +77,7 @@ public function setUpScenario(BeforeScenarioScope $scope):void {
// Get all the contexts you need in this context
$this->featureContext = $environment->getContext('FeatureContext');
$this->spacesContext = $environment->getContext('SpacesContext');
$this->settingsContext = $environment->getContext('SettingsContext');
}

/**
Expand All @@ -89,13 +89,17 @@ public function setUpScenario(BeforeScenarioScope $scope):void {
*/
public function userListAllNotifications(string $user):void {
$this->setUserRecipient($user);
$headers = ["accept-language" => $this->settingsContext->getSettingLanguageValue($user)];
$response = OcsApiHelper::sendRequest(
$this->featureContext->getBaseUrl(),
$this->featureContext->getActualUsername($user),
$this->featureContext->getPasswordForUser($user),
'GET',
$this->notificationEndpointPath,
$this->featureContext->getStepLineRef()
$this->featureContext->getStepLineRef(),
[],
2,
$headers
);
$this->featureContext->setResponse($response);
}
Expand Down
Loading