]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
selftest: Test fix for ndrdump of structures by number
authorAndrew Bartlett <abartlet@samba.org>
Thu, 14 Nov 2019 00:49:48 +0000 (13:49 +1300)
committerDouglas Bagnall <dbagnall@samba.org>
Sun, 17 Nov 2019 22:28:41 +0000 (22:28 +0000)
This requires that misc.GUID not move in the IDL, so a comment is added.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14191

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
librpc/idl/misc.idl
python/samba/tests/blackbox/ndrdump.py
source4/librpc/tests/misc-GUID.dat [new file with mode: 0644]

index 0b59ce5c96cc4f69ab39a77479e0e87aadca5698..a705b53b5f31a0bfd45b281ed4d1b35620601a4e 100644 (file)
 ]
 interface misc
 {
+       /*
+        * While structures are not normally known by their order,
+        * please keep this as the first struct, we use this for a
+        * test of 'ndrdump misc 0 struct' (this helps debug failures
+        * from our NDR fuzzing tool, which doesn't use string names)
+        */
        typedef [public,noprint,gensize] struct {
                uint32 time_low;
                uint16 time_mid;
index b8f467f8e82b77cb7c0b31d5650ca37c86bfc3c7..8ec138bacb379d4c25289d125862c3ade567ec8f 100644 (file)
@@ -94,3 +94,19 @@ class NdrDumpTests(BlackboxTestCase):
         self.assertEqual(actual[:len(expected)],
                          expected.encode('utf-8'))
         self.assertTrue(actual.endswith(b"dump OK\n"))
+
+    def test_ndrdump_with_binary_struct_number(self):
+        expected = '''pull returned NT_STATUS_OK
+    0                        : 33323130-3534-3736-3839-616263646566
+dump OK
+'''
+        try:
+            actual = self.check_output(
+                "ndrdump misc 0 struct %s" %
+                self.data_path("misc-GUID.dat"))
+        except BlackboxProcessError as e:
+            self.fail(e)
+
+        # check_output will return bytes
+        # convert expected to bytes for python 3
+        self.assertEqual(actual, expected.encode('utf-8'))
diff --git a/source4/librpc/tests/misc-GUID.dat b/source4/librpc/tests/misc-GUID.dat
new file mode 100644 (file)
index 0000000..454f6b3
--- /dev/null
@@ -0,0 +1 @@
+0123456789abcdef
\ No newline at end of file