blob: dbaca4f05cb29e79bfb9cf80e58b1708260ef737 [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
ecaiyanlinux113bf092020-08-01 14:05:17 +000023# export PORT=8090
24if [ $# -ne 1 ]; then
25 echo "Usage: ./basic_test.sh nonsecure|secure"
26 exit 1
27fi
28if [ "$1" != "nonsecure" ] && [ "$1" != "secure" ]; then
29 echo "Usage: ./basic_test.sh nonsecure|secure"
30 exit 1
31fi
32
33if [ $1 == "nonsecure" ]; then
34 #Default http port for the simulator
35 PORT=8090
36 # Set http protocol
37 HTTPX="http"
38else
39 #Default https port for the simulator
40 PORT=8091
41 # Set https protocol
42 HTTPX="https"
43fi
BjornMagnussonXA80a92002020-03-19 14:31:06 +010044
45# source function to do curl and check result
46. ../common/do_curl_function.sh
47
48echo "=== CR hello world ==="
49RESULT="OK"
50do_curl GET / 200
51
52
53echo "=== Get counter - callbacks ==="
54RESULT="0"
55do_curl GET /counter/received_callbacks 200
56
57echo "=== Get counter - fetched events ==="
58RESULT="0"
59do_curl GET /counter/fetched_callbacks 200
60
61echo "=== Get counter - current events ==="
62RESULT="0"
63do_curl GET /counter/current_messages 200
64
65
66echo "=== Send a request ==="
67RESULT="*"
68#create payload
69echo "\"DATA-MSG\"" > .tmp.json
70do_curl POST '/callbacks/test' 200 .tmp.json
71
72
73echo "=== Fetch an event, wrong id==="
74RESULT="*"
75do_curl GET '/get-event/wrongid' 204
76
77
78echo "=== Get counter - callbacks ==="
79RESULT="1"
80do_curl GET /counter/received_callbacks 200
81
82echo "=== Get counter - fetched events ==="
83RESULT="0"
84do_curl GET /counter/fetched_callbacks 200
85
86echo "=== Get counter - current events ==="
87RESULT="1"
88do_curl GET /counter/current_messages 200
89
90
91echo "=== Fetch an event ==="
92RESULT="DATA-MSG"
93do_curl GET '/get-event/test' 200
94
95echo "=== Fetch an event again ==="
96RESULT="*"
97do_curl GET '/get-event/test' 204
98
99echo "=== Get counter - callbacks ==="
100RESULT="1"
101do_curl GET /counter/received_callbacks 200
102
103echo "=== Get counter - fetched events ==="
104RESULT="1"
105do_curl GET /counter/fetched_callbacks 200
106
107echo "=== Get counter - current events ==="
108RESULT="0"
109do_curl GET /counter/current_messages 200
110
111echo "=== CR reset ==="
112RESULT="OK"
113do_curl GET /reset 200
114
115echo "=== Get counter - callbacks ==="
116RESULT="0"
117do_curl GET /counter/received_callbacks 200
118
119echo "=== Get counter - fetched events ==="
120RESULT="0"
121do_curl GET /counter/fetched_callbacks 200
122
123echo "=== Get counter - current events ==="
124RESULT="0"
125do_curl GET /counter/current_messages 200
126
127
128echo "********************"
129echo "*** All tests ok ***"
130echo "********************"