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