From 05194ccdf875ee70cb9ee3f7c27147503d585a6d Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sat, 24 May 2008 19:50:09 +0200 Subject: Add tests for new NDR pack/unpack functionality in Python DCE/RPC bindings. (This used to be commit 468d35827fd055c82c6d43d6ce6d3d561abed54d) --- source4/librpc/idl/echo.idl | 2 +- source4/scripting/python/samba/ndr.py | 1 + source4/scripting/python/samba/tests/dcerpc/rpcecho.py | 12 ++++++++++++ 3 files changed, 14 insertions(+), 1 deletion(-) (limited to 'source4') diff --git a/source4/librpc/idl/echo.idl b/source4/librpc/idl/echo.idl index 5ea37f1ac1..bf1e318674 100644 --- a/source4/librpc/idl/echo.idl +++ b/source4/librpc/idl/echo.idl @@ -38,7 +38,7 @@ interface rpcecho /* test some alignment issues */ - typedef struct { + typedef [public] struct { uint8 v; } echo_info1; diff --git a/source4/scripting/python/samba/ndr.py b/source4/scripting/python/samba/ndr.py index e93fbc3c2e..e718ff3422 100644 --- a/source4/scripting/python/samba/ndr.py +++ b/source4/scripting/python/samba/ndr.py @@ -1,4 +1,5 @@ #!/usr/bin/python +# -*- coding: utf-8 -*- # Unix SMB/CIFS implementation. # Copyright © Jelmer Vernooij 2008 diff --git a/source4/scripting/python/samba/tests/dcerpc/rpcecho.py b/source4/scripting/python/samba/tests/dcerpc/rpcecho.py index 3b37f8a9bc..9157f83fc9 100644 --- a/source4/scripting/python/samba/tests/dcerpc/rpcecho.py +++ b/source4/scripting/python/samba/tests/dcerpc/rpcecho.py @@ -18,6 +18,7 @@ # from samba.dcerpc import echo +from samba.ndr import ndr_pack, ndr_unpack import unittest from samba.tests import RpcInterfaceTestCase @@ -40,3 +41,14 @@ class RpcEchoTests(RpcInterfaceTestCase): surrounding_struct.surrounding = [1,2,3,4] y = self.conn.TestSurrounding(surrounding_struct) self.assertEquals(8 * [0], y.surrounding) + + +class NdrEchoTests(unittest.TestCase): + def test_info1_push(self): + x = echo.info1() + x.v = 42 + self.assertEquals("\x2a", ndr_pack(x)) + + def test_info1_pull(self): + x = ndr_unpack(echo.info1, "\x42") + self.assertEquals(x.v, 66) -- cgit