build: Change bin/default/python -> bin/python symlink to bin/default/python_modules
[Samba.git] / source4 / scripting / python / samba / tests / dcerpc / sam.py
blob0e09323adbe453833cab865b8fbb65e83fc2c37d
1 # -*- coding: utf-8 -*-
3 # Unix SMB/CIFS implementation.
4 # Copyright © Jelmer Vernooij <jelmer@samba.org> 2008
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.
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.
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/>.
20 """Tests for samba.dcerpc.sam."""
22 from samba.dcerpc import samr, security
23 from samba.tests import RpcInterfaceTestCase
25 # FIXME: Pidl should be doing this for us
26 def toArray((handle, array, num_entries)):
27 ret = []
28 for x in range(num_entries):
29 ret.append((array.entries[x].idx, array.entries[x].name))
30 return ret
33 class SamrTests(RpcInterfaceTestCase):
35 def setUp(self):
36 super(SamrTests, self).setUp()
37 self.conn = samr.samr("ncalrpc:", self.get_loadparm())
39 def test_connect5(self):
40 (level, info, handle) = self.conn.Connect5(None, 0, 1, samr.ConnectInfo1())
42 def test_connect2(self):
43 handle = self.conn.Connect2(None, security.SEC_FLAG_MAXIMUM_ALLOWED)
44 self.assertTrue(handle is not None)
46 def test_EnumDomains(self):
47 handle = self.conn.Connect2(None, security.SEC_FLAG_MAXIMUM_ALLOWED)
48 domains = toArray(self.conn.EnumDomains(handle, 0, -1))
49 self.conn.Close(handle)