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
10 # http://www.apache.org/licenses/LICENSE-2.0
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=================================================
20 # Automated test script for mrstub container
25 # source function to do curl and check result
26 . ../common/do_curl_function.sh
28 echo "=== Stub hello world ==="
32 echo "=== Stub reset ==="
34 do_curl GET /reset 200
36 ## Test with json response
38 echo "=== Send a request ==="
41 echo "{\"data\": \"data-value\"}" > .tmp.json
43 do_curl POST '/send-request?operation=PUT&url=/test' 200 .tmp.json
47 echo "=== Fetch a response, shall be empty ==="
49 do_curl GET '/receive-response?correlationid='$CORRID 204
51 echo "=== Fetch a request ==="
52 RESULT="json:[{\"apiVersion\":\"1.0\",\"operation\":\"PUT\",\"correlationId\":\""$CORRID"\",\"originatorId\": \"849e6c6b420\",\"payload\":{\"data\": \"data-value\"},\"requestId\":\"23343221\", \"target\":\"policy-agent\", \"timestamp\":\"????\", \"type\":\"request\",\"url\":\"/test\"}]"
53 do_curl GET '/events/A1-POLICY-AGENT-READ/users/policy-agent' 200
55 echo "=== Send a json response ==="
56 # Create minimal accepted response message
57 echo "[{\"correlationId\": \""$CORRID"\", \"message\": {\"test\":\"testresponse\"}, \"status\": \"200\"}]" > .tmp.json
59 do_curl POST /events/A1-POLICY-AGENT-WRITE 200 .tmp.json
61 echo "=== Fetch a response ==="
62 RESULT="{\"test\": \"testresponse\"}200"
63 do_curl GET '/receive-response?correlationid='$CORRID 200
65 ### Test with plain text response
67 echo "=== Send a request ==="
69 do_curl POST '/send-request?operation=GET&url=/test2' 200
73 echo "=== Fetch a response, shall be empty ==="
75 do_curl GET '/receive-response?correlationid='$CORRID 204
77 echo "=== Fetch a request ==="
78 RESULT="json:[{\"apiVersion\":\"1.0\",\"operation\":\"GET\",\"correlationId\":\""$CORRID"\",\"originatorId\": \"849e6c6b420\",\"payload\":{},\"requestId\":\"23343221\", \"target\":\"policy-agent\", \"timestamp\":\"????\", \"type\":\"request\",\"url\":\"/test2\"}]"
79 do_curl GET '/events/A1-POLICY-AGENT-READ/users/policy-agent' 200
81 echo "=== Send a json response ==="
82 # Create minimal accepted response message
83 echo "[{\"correlationId\": \""$CORRID"\", \"message\": \"test2-response\", \"status\": \"200\"}]" > .tmp.json
85 do_curl POST /events/A1-POLICY-AGENT-WRITE 200 .tmp.json
87 echo "=== Fetch a response ==="
88 RESULT="test2-response200"
89 do_curl GET '/receive-response?correlationid='$CORRID 200
91 echo "********************"
92 echo "*** All tests ok ***"
93 echo "********************"