python:samba/tests: don't use the x.alter_context() method in dcerpc/bare.py
[obnox/samba/samba-obnox.git] / python / samba / tests / dcerpc / bare.py
1 # -*- coding: utf-8 -*-
2 #
3 # Unix SMB/CIFS implementation.
4 # Copyright © Jelmer Vernooij <jelmer@samba.org> 2008
5 #
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 3 of the License, or
9 # (at your option) any later version.
10 #
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 # GNU General Public License for more details.
15 #
16 # You should have received a copy of the GNU General Public License
17 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
18 #
19
20 """Tests for samba.tests.dcerpc.bare."""
21
22 from samba.dcerpc import ClientConnection
23 import samba.tests
24
25 class BareTestCase(samba.tests.TestCase):
26
27     def test_bare(self):
28         # Connect to the echo pipe
29         x = ClientConnection("ncalrpc:localhost[DEFAULT]",
30                 ("60a15ec5-4de8-11d7-a637-005056a20182", 1),
31                 lp_ctx=samba.tests.env_loadparm())
32         self.assertEquals("\x01\x00\x00\x00", x.request(0, chr(0) * 4))
33
34     def test_two_contexts(self):
35         x = ClientConnection("ncalrpc:localhost[DEFAULT]",
36                 ("12345778-1234-abcd-ef00-0123456789ac", 1),
37                 lp_ctx=samba.tests.env_loadparm())
38         y = ClientConnection("ncalrpc:localhost",
39                 ("60a15ec5-4de8-11d7-a637-005056a20182", 1),
40                 basis_connection=x, lp_ctx=samba.tests.env_loadparm())
41         self.assertEquals(24, len(x.request(0, chr(0) * 8)))
42         self.assertEquals("\x01\x00\x00\x00", y.request(0, chr(0) * 4))