Add tests for new NDR pack/unpack functionality in Python DCE/RPC bindings.
authorJelmer Vernooij <jelmer@samba.org>
Sat, 24 May 2008 17:50:09 +0000 (19:50 +0200)
committerJelmer Vernooij <jelmer@samba.org>
Sat, 24 May 2008 17:50:09 +0000 (19:50 +0200)
(This used to be commit 468d35827fd055c82c6d43d6ce6d3d561abed54d)

source4/librpc/idl/echo.idl
source4/scripting/python/samba/ndr.py
source4/scripting/python/samba/tests/dcerpc/rpcecho.py

index 5ea37f1ac1940cc22d0801f87b8075f15154826e..bf1e318674988ec3a6260b7ab64b8169fe4ed98d 100644 (file)
@@ -38,7 +38,7 @@ interface rpcecho
 
 
        /* test some alignment issues */
-       typedef struct {
+       typedef [public] struct {
                uint8 v;
        } echo_info1;
 
index e93fbc3c2e7a7ac75185bb8b928e2b790ae782da..e718ff3422d69fd1655aec6fa1b4142b825b5e55 100644 (file)
@@ -1,4 +1,5 @@
 #!/usr/bin/python
+# -*- coding: utf-8 -*-
 
 # Unix SMB/CIFS implementation.
 # Copyright © Jelmer Vernooij <jelmer@samba.org> 2008
index 3b37f8a9bc19773dba535fd933f2e2f98c0e2c60..9157f83fc9476adfb1b2d631a0d7604508ad9a0f 100644 (file)
@@ -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)