diff options
author | Andrew Bartlett <abartlet@samba.org> | 2019-11-11 16:39:13 +1300 |
---|---|---|
committer | Douglas Bagnall <dbagnall@samba.org> | 2019-11-13 00:32:36 +0000 |
commit | 88373c472c52ddc1191c1c20e74bff7776d0e805 (patch) | |
tree | 97717e7b35ad191f70515ef919f54596f99e62a3 /python/samba | |
parent | dfbb3049585186230a0d28a581ad22de7276614c (diff) | |
download | samba-88373c472c52ddc1191c1c20e74bff7776d0e805.tar.gz |
selftest: Add expected-output tests for the ndrdump struct mode
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>
Diffstat (limited to 'python/samba')
-rw-r--r-- | python/samba/tests/blackbox/ndrdump.py | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/python/samba/tests/blackbox/ndrdump.py b/python/samba/tests/blackbox/ndrdump.py index fd1bc832d9b..b8f467f8e82 100644 --- a/python/samba/tests/blackbox/ndrdump.py +++ b/python/samba/tests/blackbox/ndrdump.py @@ -62,9 +62,35 @@ class NdrDumpTests(BlackboxTestCase): self.data_path("dns-decode_dns_name_packet-hex.dat"))) def test_ndrdump_with_hex_struct_name(self): + expected = open(self.data_path("dns-decode_dns_name_packet-hex.txt")).read() try: - self.check_run( + actual = self.check_output( "ndrdump dns dns_name_packet struct --hex-input %s" % self.data_path("dns-decode_dns_name_packet-hex.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')) + + def test_ndrdump_with_binary_struct_name(self): + # Prefix of the expected unparsed PAC data (without times, as + # these vary by host) + expected = '''pull returned NT_STATUS_OK + PAC_DATA: struct PAC_DATA + num_buffers : 0x00000005 (5) + version : 0x00000000 (0) + buffers: ARRAY(5)''' + try: + actual = self.check_output( + "ndrdump krb5pac PAC_DATA struct %s" % + self.data_path("krb5pac-PAC_DATA.dat")) + except BlackboxProcessError as e: + self.fail(e) + + # check_output will return bytes + # convert expected to bytes for python 3 + self.assertEqual(actual[:len(expected)], + expected.encode('utf-8')) + self.assertTrue(actual.endswith(b"dump OK\n")) |