252789812dd827734e71a283ba7ce56d6b89d8e5
[sim/a1-interface.git] / near-rt-ric-simulator / test / 1.1.x-alpha.2 / commands.sh
1 #!/bin/bash
2 #  ============LICENSE_START===============================================
3 #  Copyright (C) 2020 Nordix Foundation. All rights reserved.
4 #  ========================================================================
5 #  Licensed under the Apache License, Version 2.0 (the "License");
6 #  you may not use this file except in compliance with the License.
7 #  You may obtain a copy of the License at
8 #
9 #       http://www.apache.org/licenses/LICENSE-2.0
10 #
11 #  Unless required by applicable law or agreed to in writing, software
12 #  distributed under the License is distributed on an "AS IS" BASIS,
13 #  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 #  See the License for the specific language governing permissions and
15 #  limitations under the License.
16 #  ============LICENSE_END=================================================
17 #
18
19 # Different commands for the simulator.
20 # By running this, nothing should return an error.
21
22 # Run the build_and_start with the same arg as this script
23 if [ $# -ne 1 ]; then
24     echo "Usage: ./commands.sh nonsecure|secure"
25     exit 1
26 fi
27 if [ "$1" != "nonsecure" ] && [ "$1" != "secure" ]; then
28     echo "Usage: ./commands.sh nonsecure|secure"
29     exit 1
30 fi
31
32 if [ $1 == "nonsecure" ]; then
33     #Default http port for the simulator
34     PORT=8085
35     # Set http protocol
36     HTTPX="http"
37 else
38     #Default https port for the simulator
39     PORT=8185
40     # Set https protocol
41     HTTPX="https"
42 fi
43
44 # Make a test
45 curl -vk "$HTTPX://localhost:$PORT/"
46
47 # PUT a policy type STD_QoSNudging_0.2.0
48 curl -X PUT -vk "$HTTPX://localhost:$PORT/policytypes/STD_QoSNudging_0.2.0" -H "accept: application/json" -H "Content-Type: application/json" --data-binary @example_files/policy_type_STD_QoSNudging_0.2.0.json
49
50 # GET policy types
51 curl -vk "$HTTPX://localhost:$PORT/A1-P/v1/policytypes"
52
53 # GET policy type STD_QoSNudging_0.2.0
54 curl -vk "$HTTPX://localhost:$PORT/A1-P/v1/policytypes/STD_QoSNudging_0.2.0"
55
56 # PUT a policy instance pi1
57 curl -X PUT -vk "$HTTPX://localhost:$PORT/A1-P/v1/policies/pi1?policyTypeId=STD_QoSNudging_0.2.0" -H "accept: application/json" -H "Content-Type: application/json" --data-binary @example_files/policy_instance_1_STD_QoSNudging_0.2.0.json
58
59 # PUT a policy instance pi2
60 curl -X PUT -vk "$HTTPX://localhost:$PORT/A1-P/v1/policies/pi2?policyTypeId=STD_QoSNudging_0.2.0" -H "accept: application/json" -H "Content-Type: application/json" --data-binary @example_files/policy_instance_2_STD_QoSNudging_0.2.0.json
61
62 # SET status for pi1 and pi2
63 curl -X PUT -vk "$HTTPX://localhost:$PORT/pi1/NOT_ENFORCED/300"
64 curl -X PUT -vk "$HTTPX://localhost:$PORT/pi2/ENFORCED"
65
66 # GET policies
67 curl -vk "$HTTPX://localhost:$PORT/A1-P/v1/policies"
68
69 # DELETE policy instance pi2
70 curl -X DELETE -vk "$HTTPX://localhost:$PORT/A1-P/v1/policies/pi2"
71
72 # PUT a different policy instance pi1 (i.e. update it)
73 curl -X PUT -vk "$HTTPX://localhost:$PORT/A1-P/v1/policies/pi1?policyTypeId=STD_QoSNudging_0.2.0" -H "accept: application/json" -H "Content-Type: application/json" --data-binary @example_files/policy_instance_1_bis_STD_QoSNudging_0.2.0.json
74
75 # GET policy instance pi1
76 curl -vk "$HTTPX://localhost:$PORT/A1-P/v1/policies/pi1"
77
78 # GET policy status for pi1
79 curl -vk "$HTTPX://localhost:$PORT/A1-P/v1/policystatus/pi1"