-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added tests for the notifications plugin.
Signed-off-by: dblock <[email protected]>
- Loading branch information
Showing
13 changed files
with
241 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
https://localhost:* | ||
http://webhook:8080 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
$schema: ../../../json_schemas/test_story.schema.yaml | ||
|
||
description: Test listing channels. | ||
version: '>= 2.0' | ||
chapters: | ||
- synopsis: Retrieve a list of all notification channels. | ||
path: /_plugins/_notifications/channels | ||
method: GET | ||
response: | ||
status: 200 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
$schema: ../../../json_schemas/test_story.schema.yaml | ||
|
||
description: Test listing notification configs. | ||
version: '>= 2.0' | ||
chapters: | ||
- synopsis: Create a channel configuration. | ||
path: /_plugins/_notifications/configs | ||
method: POST | ||
request: | ||
payload: | ||
config_id: webhook-configuration | ||
config: | ||
name: Notifications Channel | ||
description: Default notifications channel. | ||
config_type: webhook | ||
is_enabled: true | ||
webhook: | ||
url: http://webhook:8080/ | ||
response: | ||
status: 200 | ||
- synopsis: Update a channel configuration. | ||
path: /_plugins/_notifications/configs/{config_id} | ||
method: PUT | ||
parameters: | ||
config_id: webhook-configuration | ||
request: | ||
payload: | ||
config: | ||
name: Notifications Channel | ||
config_type: webhook | ||
is_enabled: true | ||
webhook: | ||
url: http://webhook:8080/ | ||
response: | ||
status: 200 | ||
- synopsis: Retrieve a list of all notification configurations. | ||
path: /_plugins/_notifications/configs | ||
method: GET | ||
retry: | ||
count: 2 | ||
response: | ||
status: 200 | ||
payload: | ||
config_list: | ||
- config_id: webhook-configuration | ||
- synopsis: Retrieve a list of all notification configurations filtered by config ID. | ||
path: /_plugins/_notifications/configs | ||
method: GET | ||
parameters: | ||
config_type: webhook | ||
response: | ||
status: 200 | ||
payload: | ||
config_list: | ||
- config_id: webhook-configuration | ||
- synopsis: Retrieve a notification configuration by config ID (path). | ||
path: /_plugins/_notifications/configs/{config_id} | ||
method: GET | ||
parameters: | ||
config_id: webhook-configuration | ||
response: | ||
status: 200 | ||
payload: | ||
config_list: | ||
- config_id: webhook-configuration | ||
- synopsis: Retrieve a notification configuration by config ID (query). | ||
path: /_plugins/_notifications/configs | ||
method: GET | ||
parameters: | ||
config_id: webhook-configuration | ||
response: | ||
status: 200 | ||
payload: | ||
config_list: | ||
- config_id: webhook-configuration | ||
- synopsis: Retrieve a notification configuration by config ID list (query). | ||
path: /_plugins/_notifications/configs | ||
method: GET | ||
parameters: | ||
config_id_list: | ||
- webhook-configuration | ||
response: | ||
status: 200 | ||
payload: | ||
config_list: | ||
- config_id: webhook-configuration | ||
- synopsis: Delete a channel configuration. | ||
path: /_plugins/_notifications/configs/{config_id} | ||
method: DELETE | ||
parameters: | ||
config_id: webhook-configuration | ||
response: | ||
status: 200 | ||
epilogues: | ||
- path: /_plugins/_notifications/configs/webhook-configuration | ||
method: DELETE | ||
status: [200,404] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
$schema: ../../../json_schemas/test_story.schema.yaml | ||
|
||
description: Test listing supported channel configurations. | ||
version: '>= 2.0' | ||
chapters: | ||
- synopsis: Retrieve a list of all supported notification configuration types. | ||
path: /_plugins/_notifications/features | ||
method: GET | ||
response: | ||
status: 200 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
version: '3' | ||
|
||
services: | ||
opensearch-cluster: | ||
image: ${OPENSEARCH_DOCKER_HUB_PROJECT:-opensearchproject}/opensearch:${OPENSEARCH_VERSION:-latest}${OPENSEARCH_DOCKER_REF} | ||
ports: | ||
- 9200:9200 | ||
- 9600:9600 | ||
environment: | ||
- OPENSEARCH_INITIAL_ADMIN_PASSWORD=${OPENSEARCH_PASSWORD:-myStrongPassword123!} | ||
- OPENSEARCH_JAVA_OPTS=${OPENSEARCH_JAVA_OPTS} | ||
- discovery.type=single-node | ||
webhook: | ||
image: python:latest | ||
volumes: | ||
- ./server.py:/server.py | ||
ports: | ||
- '8080:8080' | ||
entrypoint: python server.py |
37 changes: 37 additions & 0 deletions
37
tests/plugins/notifications/notifications/feature/test.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
$schema: ../../../../../json_schemas/test_story.schema.yaml | ||
|
||
description: Test sending a notification. | ||
version: '>= 2.0' | ||
prologues: | ||
- path: /_plugins/_notifications/configs | ||
method: POST | ||
request: | ||
payload: | ||
config_id: custom-webhook-configuration | ||
config: | ||
name: Notifications Channel | ||
description: Default notifications channel. | ||
config_type: webhook | ||
is_enabled: true | ||
webhook: | ||
url: http://webhook:8080/ | ||
status: [200] | ||
chapters: | ||
- synopsis: Test sending a notification. | ||
path: /_plugins/_notifications/feature/test/{config_id} | ||
method: GET | ||
parameters: | ||
config_id: custom-webhook-configuration | ||
response: | ||
status: 200 | ||
payload: | ||
status_list: | ||
- config_id: custom-webhook-configuration | ||
config_type: webhook | ||
delivery_status: | ||
status_code: '200' | ||
status_text: '{"ok":"true"}' | ||
epilogues: | ||
- path: /_plugins/_notifications/configs/custom-webhook-configuration | ||
method: DELETE | ||
status: [200,404] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# | ||
# Copyright OpenSearch Contributors | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
# The OpenSearch Contributors require contributions made to | ||
# this file be licensed under the Apache-2.0 license or a | ||
# compatible open source license. | ||
# | ||
|
||
from http.server import BaseHTTPRequestHandler, HTTPServer | ||
|
||
|
||
class SimpleHTTPRequestHandler(BaseHTTPRequestHandler): | ||
def do_GET(self): | ||
self.send_response(200) | ||
self.send_header("Content-type", "application_json") | ||
self.end_headers() | ||
self.wfile.write(b'{"ok":"true"}') | ||
|
||
def do_POST(self): | ||
self.send_response(200) | ||
self.send_header("Content-type", "application_json") | ||
self.end_headers() | ||
self.wfile.write(b'{"ok":"true"}') | ||
|
||
|
||
if __name__ == "__main__": | ||
server_address = ("", 8080) | ||
httpd = HTTPServer(server_address, SimpleHTTPRequestHandler) | ||
print("Server started on http://localhost:8080") | ||
httpd.serve_forever() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters