selftest: Test partial parse behaviour in ndrdump
authorAndrew Bartlett <abartlet@samba.org>
Wed, 20 Nov 2019 05:55:47 +0000 (18:55 +1300)
committerAndrew Bartlett <abartlet@samba.org>
Fri, 29 Nov 2019 02:09:11 +0000 (02:09 +0000)
Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Autobuild-User(master): Andrew Bartlett <abartlet@samba.org>
Autobuild-Date(master): Fri Nov 29 02:09:11 UTC 2019 on sn-devel-184

python/samba/tests/blackbox/ndrdump.py

index dcc82e4dba7c96a014f1c45138b08fbe09c26158..92a6c090c48ecae4d267171d1bfe43cabdee5d6b 100644 (file)
@@ -111,6 +111,57 @@ dump OK
         # convert expected to bytes for python 3
         self.assertEqual(actual, expected.encode('utf-8'))
 
+    def test_ndrdump_input_cmdline_short_struct_name(self):
+        expected = '''pull returned Buffer Size Error
+'''
+        try:
+            actual = self.check_exit_code(
+                "ndrdump -d0 misc GUID struct --input=abcdefg", 2)
+        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'))
+
+    def test_ndrdump_input_cmdline_short_struct_name_dump(self):
+        expected = '''pull returned Buffer Size Error
+6 bytes consumed
+[0000] 61 62 63 64 65 66 67                               abcdefg ''' \
+        '''
+'''
+        try:
+            actual = self.check_exit_code(
+                "ndrdump -d0 misc GUID struct --input=abcdefg --dump-data", 2)
+        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'))
+
+    def test_ndrdump_input_cmdline_short_struct_name_print_fail(self):
+        expected = '''pull returned Buffer Size Error
+6 bytes consumed
+[0000] 61 62 63 64 65 66 67                               abcdefg ''' \
+        '''
+WARNING! 1 unread bytes
+[0000] 67                                                 g ''' \
+    '''
+WARNING: pull of GUID was incomplete, therefore the parse below may SEGFAULT
+    GUID                     : 64636261-6665-0000-0000-000000000000
+dump of failed-to-parse GUID complete
+'''
+        try:
+            actual = self.check_exit_code(
+                "ndrdump -d0 misc GUID struct --input=abcdefg --dump-data --print-after-parse-failure", 2)
+        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'))
+
     def test_ndrdump_fuzzed_clusapi_QueryAllValues(self):
         expected = b'''pull returned Success
 WARNING! 53 unread bytes