blob: 8be110af6653f021aab8444cdcc0526e78e506ca [file] [log] [blame]
BjornMagnussonXA80a92002020-03-19 14:31:06 +01001#!/bin/bash
2
3# ============LICENSE_START===============================================
4# Copyright (C) 2020 Nordix Foundation. All rights reserved.
5# ========================================================================
6# Licensed under the Apache License, Version 2.0 (the "License");
7# you may not use this file except in compliance with the License.
8# You may obtain a copy of the License at
9#
10# http://www.apache.org/licenses/LICENSE-2.0
11#
12# Unless required by applicable law or agreed to in writing, software
13# distributed under the License is distributed on an "AS IS" BASIS,
14# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15# See the License for the specific language governing permissions and
16# limitations under the License.
17# ============LICENSE_END=================================================
18#
19
20# Automated test script for callback receiver container
21
22# callbackreciver port
23export PORT=8090
24
25# source function to do curl and check result
26. ../common/do_curl_function.sh
27
28echo "=== CR hello world ==="
29RESULT="OK"
30do_curl GET / 200
31
32
33echo "=== Get counter - callbacks ==="
34RESULT="0"
35do_curl GET /counter/received_callbacks 200
36
37echo "=== Get counter - fetched events ==="
38RESULT="0"
39do_curl GET /counter/fetched_callbacks 200
40
41echo "=== Get counter - current events ==="
42RESULT="0"
43do_curl GET /counter/current_messages 200
44
45
46echo "=== Send a request ==="
47RESULT="*"
48#create payload
49echo "\"DATA-MSG\"" > .tmp.json
50do_curl POST '/callbacks/test' 200 .tmp.json
51
52
53echo "=== Fetch an event, wrong id==="
54RESULT="*"
55do_curl GET '/get-event/wrongid' 204
56
57
58echo "=== Get counter - callbacks ==="
59RESULT="1"
60do_curl GET /counter/received_callbacks 200
61
62echo "=== Get counter - fetched events ==="
63RESULT="0"
64do_curl GET /counter/fetched_callbacks 200
65
66echo "=== Get counter - current events ==="
67RESULT="1"
68do_curl GET /counter/current_messages 200
69
70
71echo "=== Fetch an event ==="
72RESULT="DATA-MSG"
73do_curl GET '/get-event/test' 200
74
75echo "=== Fetch an event again ==="
76RESULT="*"
77do_curl GET '/get-event/test' 204
78
79echo "=== Get counter - callbacks ==="
80RESULT="1"
81do_curl GET /counter/received_callbacks 200
82
83echo "=== Get counter - fetched events ==="
84RESULT="1"
85do_curl GET /counter/fetched_callbacks 200
86
87echo "=== Get counter - current events ==="
88RESULT="0"
89do_curl GET /counter/current_messages 200
90
91echo "=== CR reset ==="
92RESULT="OK"
93do_curl GET /reset 200
94
95echo "=== Get counter - callbacks ==="
96RESULT="0"
97do_curl GET /counter/received_callbacks 200
98
99echo "=== Get counter - fetched events ==="
100RESULT="0"
101do_curl GET /counter/fetched_callbacks 200
102
103echo "=== Get counter - current events ==="
104RESULT="0"
105do_curl GET /counter/current_messages 200
106
107
108echo "********************"
109echo "*** All tests ok ***"
110echo "********************"