build: Change bin/default/python -> bin/python symlink to bin/default/python_modules
[samba.git] / source4 / scripting / python / samba / tests / dcerpc / sam.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.dcerpc.sam."""
21
22 from samba.dcerpc import samr, security
23 from samba.tests import RpcInterfaceTestCase
24
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
31
32
33 class SamrTests(RpcInterfaceTestCase):
34
35     def setUp(self):
36         super(SamrTests, self).setUp()
37         self.conn = samr.samr("ncalrpc:", self.get_loadparm())
38
39     def test_connect5(self):
40         (level, info, handle) = self.conn.Connect5(None, 0, 1, samr.ConnectInfo1())
41
42     def test_connect2(self):
43         handle = self.conn.Connect2(None, security.SEC_FLAG_MAXIMUM_ALLOWED)
44         self.assertTrue(handle is not None)
45
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)
50