From: Stefan Metzmacher Date: Tue, 20 Nov 2018 14:48:08 +0000 (+0100) Subject: py:dcerpc/raw_testcase: pass auth_context and stub_len to parse_auth() in order to... X-Git-Tag: tdb-1.3.17~125 X-Git-Url: http://git.samba.org/?p=samba.git;a=commitdiff_plain;h=20ed4bd920095ddb9b89a3c04d27c6fba2990cf7 py:dcerpc/raw_testcase: pass auth_context and stub_len to parse_auth() in order to assert BUG: https://bugzilla.samba.org/show_bug.cgi?id=7113 BUG: https://bugzilla.samba.org/show_bug.cgi?id=11892 Signed-off-by: Stefan Metzmacher Reviewed-by: Jeremy Allison --- diff --git a/python/samba/tests/dcerpc/raw_testcase.py b/python/samba/tests/dcerpc/raw_testcase.py index 61538cea248..035d3ac0c6a 100644 --- a/python/samba/tests/dcerpc/raw_testcase.py +++ b/python/samba/tests/dcerpc/raw_testcase.py @@ -18,7 +18,7 @@ import sys import socket -import samba.dcerpc.dcerpc +import samba.dcerpc.dcerpc as dcerpc import samba.dcerpc.base import samba.dcerpc.epmapper import samba.tests @@ -207,7 +207,7 @@ class RawDCERPCTest(TestCase): self.assertGreater(len(rep.u.auth_info), samba.dcerpc.dcerpc.DCERPC_AUTH_TRAILER_LENGTH) self.assertEquals(rep.auth_length, len(rep.u.auth_info) - samba.dcerpc.dcerpc.DCERPC_AUTH_TRAILER_LENGTH) - a = self.parse_auth(rep.u.auth_info) + a = self.parse_auth(rep.u.auth_info, auth_context=auth_context) from_server = a.credentials (finished, to_server) = auth_context["gensec"].update(from_server) @@ -253,7 +253,7 @@ class RawDCERPCTest(TestCase): self.assertGreater(len(rep.u.auth_info), samba.dcerpc.dcerpc.DCERPC_AUTH_TRAILER_LENGTH) self.assertEquals(rep.auth_length, len(rep.u.auth_info) - samba.dcerpc.dcerpc.DCERPC_AUTH_TRAILER_LENGTH) - a = self.parse_auth(rep.u.auth_info) + a = self.parse_auth(rep.u.auth_info, auth_context=auth_context) from_server = a.credentials (finished, to_server) = auth_context["gensec"].update(from_server) @@ -411,12 +411,9 @@ class RawDCERPCTest(TestCase): rep_sig = rep_blob[ofs_sig:] rep_auth_info_blob = rep_blob[ofs_trailer:] - rep_auth_info = self.parse_auth(rep_auth_info_blob) - self.assertEquals(rep_auth_info.auth_type, auth_context["auth_type"]) - self.assertEquals(rep_auth_info.auth_level, auth_context["auth_level"]) - self.assertLessEqual(rep_auth_info.auth_pad_length, len(rep_data)) - self.assertEquals(rep_auth_info.auth_reserved, 0) - self.assertEquals(rep_auth_info.auth_context_id, auth_context["auth_context_id"]) + rep_auth_info = self.parse_auth(rep_auth_info_blob, + auth_context=auth_context, + stub_len=len(rep_data)) self.assertEquals(rep_auth_info.credentials, rep_sig) if auth_context["auth_level"] >= samba.dcerpc.dcerpc.DCERPC_AUTH_LEVEL_PACKET: @@ -622,7 +619,8 @@ class RawDCERPCTest(TestCase): return ai - def parse_auth(self, auth_info, ndr_print=None, hexdump=None): + def parse_auth(self, auth_info, ndr_print=None, hexdump=None, + auth_context=None, stub_len=0): if ndr_print is None: ndr_print = self.do_ndr_print if hexdump is None: @@ -637,6 +635,15 @@ class RawDCERPCTest(TestCase): if ndr_print: sys.stderr.write("parse_auth: %s" % samba.ndr.ndr_print(a)) + if auth_context is not None: + self.assertEquals(a.auth_type, auth_context["auth_type"]) + self.assertEquals(a.auth_level, auth_context["auth_level"]) + self.assertEquals(a.auth_reserved, 0) + self.assertEquals(a.auth_context_id, auth_context["auth_context_id"]) + + self.assertLessEqual(a.auth_pad_length, dcerpc.DCERPC_AUTH_PAD_ALIGNMENT) + self.assertLessEqual(a.auth_pad_length, stub_len) + return a def generate_pdu(self, ptype, call_id, payload,