From 1b4c5f9d1ec60e6a413e847884edd4b7434e8f36 Mon Sep 17 00:00:00 2001 From: vdutta Date: Thu, 11 Nov 2021 17:16:45 +0530 Subject: [PATCH] test: json plugin with index --- test/files/etc/bbfdm/json/index.json | 69 ++++++++++++++++++++++++++++ test/files/tmp/proxd.data | 6 +++ test/files/tmp/proxd.get.data | 3 ++ test/files/usr/libexec/rpcd/proxd | 25 ++++++++++ 4 files changed, 103 insertions(+) create mode 100644 test/files/etc/bbfdm/json/index.json create mode 100644 test/files/tmp/proxd.data create mode 100644 test/files/tmp/proxd.get.data create mode 100755 test/files/usr/libexec/rpcd/proxd diff --git a/test/files/etc/bbfdm/json/index.json b/test/files/etc/bbfdm/json/index.json new file mode 100644 index 00000000..67610901 --- /dev/null +++ b/test/files/etc/bbfdm/json/index.json @@ -0,0 +1,69 @@ +{ + "Device.PD2.{i}.": { + "type": "object", + "protocols": [ + "cwmp", + "usp" + ], + "access": false, + "array": true, + "mapping": { + "type": "ubus", + "ubus": { + "object": "proxd", + "method": "list", + "args": {}, + "key": "devices" + } + }, + "Device.PD2.{i}.MiniHub.{i}.": { + "type": "object", + "protocols": [ + "cwmp", + "usp" + ], + "access": false, + "array": true, + "mapping": { + "type": "ubus", + "ubus": { + "object": "proxd", + "method": "list", + "args": {}, + "key": "devices" + } + }, + "Device.PD2.{i}.MiniHub.{i}.DeviceInfo.": { + "type": "object", + "protocols": [ + "cwmp", + "usp" + ], + "access": false, + "array": false, + "Description": { + "type": "string", + "read": true, + "write": false, + "protocols": [ + "cwmp", + "usp" + ], + "mapping": [ + { + "type": "ubus", + "ubus": { + "object": "proxd", + "method": "get", + "args": { + "path": "Device.ProxiedDevice.{i}.MiniHub.{i}.DeviceInfo.Description" + }, + "key": "Description" + } + } + ] + } + } + } + } +} diff --git a/test/files/tmp/proxd.data b/test/files/tmp/proxd.data new file mode 100644 index 00000000..ab830282 --- /dev/null +++ b/test/files/tmp/proxd.data @@ -0,0 +1,6 @@ +{ + "devices": [ + { "name": "one"}, + {"name": "two"} + ] +} diff --git a/test/files/tmp/proxd.get.data b/test/files/tmp/proxd.get.data new file mode 100644 index 00000000..dfa5a778 --- /dev/null +++ b/test/files/tmp/proxd.get.data @@ -0,0 +1,3 @@ +{ + "Description": "Test Description" +} diff --git a/test/files/usr/libexec/rpcd/proxd b/test/files/usr/libexec/rpcd/proxd new file mode 100755 index 00000000..c0aa8aa2 --- /dev/null +++ b/test/files/usr/libexec/rpcd/proxd @@ -0,0 +1,25 @@ +#!/bin/sh + +. /usr/share/libubox/jshn.sh + +case "$1" in + list) + echo '{ "list" : {}, "get": {"path":"str"}}' + ;; + call) + case "$2" in + list) + cat /tmp/proxd.data 2>/dev/null + ;; + get) + read input; + json_load "$input" + json_get_var path path + json_init + json_add_string "Description" "$path" + json_dump >/dev/console + json_dump + ;; + esac + ;; +esac