Skip to content

Commit

Permalink
Add api tests for notification
Browse files Browse the repository at this point in the history
  • Loading branch information
amrita-shrestha committed May 18, 2023
1 parent 419c624 commit f003836
Show file tree
Hide file tree
Showing 7 changed files with 301 additions and 31 deletions.
4 changes: 2 additions & 2 deletions .drone.star
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,9 @@ config = {
"skip": False,
"earlyFail": True,
},
"apiEmailNotification": {
"apiNotification": {
"suites": [
"apiEmailNotification",
"apiNotification",
],
"skip": False,
"earlyFail": True,
Expand Down
2 changes: 1 addition & 1 deletion docs/ocis/development/testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -346,5 +346,5 @@ TEST_OCIS=true \
TEST_WITH_GRAPH_API=true \
EMAIL_HOST="localhost" \
EMAIL_PORT=9000 \
BEHAT_FEATURE="tests/acceptance/features/apiEmailNotification/emailNotification.feature"
BEHAT_FEATURE="tests/acceptance/features/apiNotification/emailNotification.feature"
```
4 changes: 2 additions & 2 deletions tests/acceptance/config/behat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -170,9 +170,9 @@ default:
- GraphContext:
- OcisConfigContext:

apiEmailNotification:
apiNotification:
paths:
- '%paths.base%/../features/apiEmailNotification'
- '%paths.base%/../features/apiNotification'
context: *common_ldap_suite_context
contexts:
- NotificationContext:
Expand Down
242 changes: 242 additions & 0 deletions tests/acceptance/features/apiNotification/notification.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,242 @@
@api
Feature: Notification
As a user
I want to be notified of actions
So that I can stay updated about the information

Background:
Given these users have been created with default attributes and without skeleton files:
| username |
| Alice |
| Brian |
| Carol |
And user "Alice" has uploaded file with content "other data" to "/textfile1.txt"
And user "Alice" has created folder "my_data"


Scenario Outline: user gets a notification of resource sharing
Given user "Alice" has shared entry "<resource>" with user "Brian"
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 "Resource 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 shared <resource> with you"]
},
"messageRich": {
"type": "string",
"enum": ["{user} shared {resource} with you"]
},
"messageRichParameters": {
"type": "object",
"required": [
"resource",
"user"
],
"properties": {
"resource": {
"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": ["<resource>"]
}
}
},
"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"
},
"object_type": {
"type": "string",
"enum": ["share"]
},
"subject": {
"type": "string",
"enum": ["Resource shared"]
},
"subjectRich": {
"type": "string",
"enum": ["Resource shared"]
},
"user": {
"type": "string",
"enum": ["Alice"]
}
}
}
"""
Examples:
| resource |
| textfile1.txt |
| my_data |


Scenario Outline: user gets a notification of unsharing resource
Given user "Alice" has shared entry "<resource>" with user "Brian"
And user "Brian" has accepted share "/<resource>" offered by user "Alice"
And user "Alice" has unshared folder "<resource>" for "Brian"
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 "Resource unshared" 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 unshared <resource> with you"]
},
"messageRich": {
"type": "string",
"enum": ["{user} unshared {resource} with you"]
},
"messageRichParameters": {
"type": "object",
"required": [
"resource",
"user"
],
"properties": {
"resource": {
"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": ["<resource>"]
}
}
},
"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"
},
"object_type": {
"type": "string",
"enum": ["share"]
},
"subject": {
"type": "string",
"enum": ["Resource unshared"]
},
"subjectRich": {
"type": "string",
"enum": ["Resource unshared"]
},
"user": {
"type": "string",
"enum": ["Alice"]
}
}
}
"""
Examples:
| resource |
| textfile1.txt |
| my_data |
Loading

0 comments on commit f003836

Please sign in to comment.