proc: do not declare empty process variables
[project/uhttpd.git] / session-test.sh
1 #!/usr/bin/env bash
2 . /usr/share/libubox/jshn.sh
3
4 json_load "$(ubus call session create)"
5 json_get_var sid ubus_rpc_session
6
7
8 json_init
9 json_add_string ubus_rpc_session "$sid"
10 json_add_array "objects"
11 json_add_array ""
12 json_add_string "" "session"
13 json_add_string "" "list"
14 json_close_array
15 json_close_array
16
17 ubus call session grant "$(json_dump)"
18
19 echo "Session: $sid"
20 echo "Request 1"
21 wget -q -O- \
22 --post-data='{
23 "jsonrpc": "2.0",
24 "method" : "call",
25 "params" : [
26 "'$sid'",
27 "session",
28 "test",
29 {},
30 ]
31 }' "http://localhost:8080/ubus"
32 echo "Request 2"
33 wget -q -O- \
34 --post-data='[
35 {
36 "jsonrpc": "2.0",
37 "method" : "call",
38 "params" : [
39 "'$sid'",
40 "session",
41 "list",
42 {},
43 ]
44 },
45 {
46 "jsonrpc": "2.0",
47 "method" : "call",
48 "params" : [
49 "'$sid'",
50 "session",
51 "test",
52 {},
53 ]
54 },
55 ]' "http://localhost:8080/ubus"