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
26 # FIXME: Pidl should be doing this for us
27 def toArray(handle, array, num_entries):
28 return [(entry.idx, entry.name) for entry in array.entries[:num_entries]]
31 class SamrTests(RpcInterfaceTestCase):
34 super(SamrTests, self).setUp()
35 self.conn = samr.samr("ncalrpc:", self.get_loadparm())
37 def test_connect5(self):
38 (level, info, handle) = self.conn.Connect5(None, 0, 1, samr.ConnectInfo1())
40 def test_connect2(self):
41 handle = self.conn.Connect2(None, security.SEC_FLAG_MAXIMUM_ALLOWED)
42 self.assertTrue(handle is not None)
44 def test_EnumDomains(self):
45 handle = self.conn.Connect2(None, security.SEC_FLAG_MAXIMUM_ALLOWED)
46 domains = toArray(*self.conn.EnumDomains(handle, 0, 4294967295))
47 self.conn.Close(handle)