3 #Script for basic testing of the A1 simulator API
4 #Note: policy is reset before test
6 HOST_PORT="localhost:8080"
8 echo "Usage: populate.sh [<host:port>]"
10 HOST_PORT="localhost:8080"
13 echo "Setting host and port from cmd line: "$1
17 echo "======================================="
18 echo "Using host and port:" $HOST_PORT
19 echo "======================================="
21 echo "======================================="
23 curl 'http://'$HOST_PORT'/reset'
24 echo "======================================="
28 PATTERN="s/XXXX/${1}/g"
29 sed $PATTERN pt-template.json > .tmp.json
30 res=$(curl -sw "%{http_code}" -X PUT --header 'Content-Type: application/json' --header 'Accept: */*' -d @.tmp.json 'http://'${HOST_PORT}'/a1-p/policytypes/'$1)
31 http_code="${res:${#res}-3}"
32 echo "Response code: " $http_code
36 res=$(curl -sw "%{http_code}" --header 'Accept: application/json' 'http://'${HOST_PORT}'/a1-p/policytypes/'$1)
37 http_code="${res:${#res}-3}"
38 echo "Response code: " $http_code
39 echo "Response: " ${res:0:${#res}-3}
43 res=$(curl -sw "%{http_code}" --header 'Accept: application/json' 'http://'${HOST_PORT}'/a1-p/policytypes/')
44 http_code="${res:${#res}-3}"
45 echo "Response code: " $http_code
46 echo "Response: " ${res:0:${#res}-3}
50 res=$(curl -sw "%{http_code}" -X DELETE --header 'Accept: */*' 'http://'${HOST_PORT}'/a1-p/policytypes/'$1)
51 http_code="${res:${#res}-3}"
52 echo "Response code: " $http_code
56 res=$(curl -sw "%{http_code}" --header 'Accept: application/json' 'http://'${HOST_PORT}'/a1-p/policytypes/'${1}'/policies')
57 http_code="${res:${#res}-3}"
58 echo "Response code: " $http_code
59 echo "Response: " ${res:0:${#res}-3}
63 PATTERN="s/XXXX/${2}/g"
64 sed $PATTERN pi-template.json > .tmp.json
65 res=$(curl -sw "%{http_code}" -X PUT --header 'Content-Type: application/json' --header 'Accept: */*' -d @.tmp.json 'http://'${HOST_PORT}'/a1-p/policytypes/'$1'/policies/'$2)
66 http_code="${res:${#res}-3}"
67 echo "Response code: " $http_code
71 res=$(curl -sw "%{http_code}" --header 'Accept: application/json' 'http://'${HOST_PORT}'/a1-p/policytypes/'${1}'/policies/'$2)
72 http_code="${res:${#res}-3}"
73 echo "Response code: " $http_code
74 echo "Response: " ${res:0:${#res}-3}
78 res=$(curl -sw "%{http_code}" -X DELETE --header 'Accept: application/json' 'http://'${HOST_PORT}'/a1-p/policytypes/'${1}'/policies/'$2)
79 http_code="${res:${#res}-3}"
80 echo "Response code: " $http_code
84 res=$(curl -sw "%{http_code}" --header 'Accept: application/json' 'http://'${HOST_PORT}'/a1-p/policytypes/'${1}'/policies/'$2'/status')
85 http_code="${res:${#res}-3}"
86 echo "Response code: " $http_code
87 echo "Response: " ${res:0:${#res}-3}
91 echo "== Create policy type 23"
93 echo "== Get policy type 23"
95 echo "== Create policy type 23 again"
97 echo "== Create policy type 24"
99 echo "== Get all policy types"
101 echo "== Delete policy type 24"
103 echo "== Delete policy type 24 again"
105 echo "== Get all policy types"
107 echo "== Get all policy instancess for type 23"
109 echo "== Create policy instance 16 for type 23"
111 echo "== Create policy instance 16 for type 23 again"
113 echo "== Get policy instance 16 for type 23"
115 echo "== Get missing policy instance 17 for type 23"
117 echo "== Create policy instance 18 for type 23"
119 echo "== Get all policy instances for type 23"
121 echo "== Delete policy instance 18 for type 23"
123 echo "== Get all policy instances for type 23"
125 echo "== Get status for policy instance 16 for type 23"