ubus: remove session api from plugin and check access via ubus call to let other...
[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 sid
6
7
8 json_init
9 json_add_string sid "$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                         "session",
27                         "test",
28                         {},
29                 ]
30         }' "http://localhost:8080/ubus/$sid"
31 echo "Request 2"
32 wget -q -O- \
33         --post-data='[
34         {
35                 "jsonrpc": "2.0",
36                 "method" : "call",
37                 "params" : [
38                         "session",
39                         "list",
40                         {},
41                 ]
42         },
43         {
44                 "jsonrpc": "2.0",
45                 "method" : "call",
46                 "params" : [
47                         "session",
48                         "test",
49                         {},
50                 ]
51         },
52         ]' "http://localhost:8080/ubus/$sid"