]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
tests: Validate that JSON deflattening fixed nested json pseudo-protocol strings
authorPeter Krempa <pkrempa@redhat.com>
Mon, 26 Jun 2017 17:42:06 +0000 (19:42 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Tue, 11 Jul 2017 12:24:17 +0000 (14:24 +0200)
Sheepdog and possibly others use nested objects for network server and
thus could be specified in a way that libvirt would not parse.

Validates that https://bugzilla.redhat.com/show_bug.cgi?id=1464821
is fixed properly.

tests/virjsondata/deflatten-qemu-sheepdog-in.json [new file with mode: 0644]
tests/virjsondata/deflatten-qemu-sheepdog-out.json [new file with mode: 0644]
tests/virjsontest.c
tests/virstoragetest.c

diff --git a/tests/virjsondata/deflatten-qemu-sheepdog-in.json b/tests/virjsondata/deflatten-qemu-sheepdog-in.json
new file mode 100644 (file)
index 0000000..7c02863
--- /dev/null
@@ -0,0 +1,11 @@
+{
+    "driver": "raw",
+    "file": {
+        "server.host": "10.10.10.10",
+        "server.port": "7000",
+        "tag": "",
+        "driver": "sheepdog",
+        "server.type": "inet",
+        "vdi": "Alice"
+    }
+}
diff --git a/tests/virjsondata/deflatten-qemu-sheepdog-out.json b/tests/virjsondata/deflatten-qemu-sheepdog-out.json
new file mode 100644 (file)
index 0000000..258b44a
--- /dev/null
@@ -0,0 +1,13 @@
+{
+  "driver": "raw",
+  "file": {
+    "server": {
+      "host": "10.10.10.10",
+      "port": "7000",
+      "type": "inet"
+    },
+    "tag": "",
+    "driver": "sheepdog",
+    "vdi": "Alice"
+  }
+}
index 2771cb5cd8beeb163aa63b2369cccdc4c0e8430f..b3a230a02da69d6f7e65a5733bc41dcd00433a68 100644 (file)
@@ -519,6 +519,7 @@ mymain(void)
     DO_TEST_DEFLATTEN("double-key", false);
     DO_TEST_DEFLATTEN("concat", true);
     DO_TEST_DEFLATTEN("concat-double-key", false);
+    DO_TEST_DEFLATTEN("qemu-sheepdog", true);
 
     return (ret == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
 }
index f34408395b4a0f3f4f15276ef2c6fd2f0c337b10..90fcf36ca1f3e7f437478995231ba9b7e2475d2a 100644 (file)
@@ -1575,6 +1575,16 @@ mymain(void)
                        "<source protocol='sheepdog' name='test'>\n"
                        "  <host name='example.com' port='321'/>\n"
                        "</source>\n");
+    TEST_BACKING_PARSE("json:{\"driver\": \"raw\","
+                             "\"file\": {\"server.host\": \"10.10.10.10\","
+                                        "\"server.port\": \"7000\","
+                                        "\"tag\": \"\","
+                                        "\"driver\": \"sheepdog\","
+                                        "\"server.type\": \"inet\","
+                                        "\"vdi\": \"Alice\"}}",
+                       "<source protocol='sheepdog' name='Alice'>\n"
+                       "  <host name='10.10.10.10' port='7000'/>\n"
+                       "</source>\n");
 #endif /* WITH_YAJL */
 
  cleanup: