95de0d0703f7a65e8397b0b02aaff35339598258
[amitay/samba.git] / python / samba / tests / dcerpc / registry.py
1 # Unix SMB/CIFS implementation.
2 # Copyright (C) Jelmer Vernooij <jelmer@samba.org> 2008
3 #
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 3 of the License, or
7 # (at your option) any later version.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 # GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 #
17
18 """Tests for samba.dcerpc.registry."""
19
20 from samba.dcerpc import winreg
21 from samba.tests import RpcInterfaceTestCase
22
23
24 class WinregTests(RpcInterfaceTestCase):
25
26     def setUp(self):
27         super(WinregTests, self).setUp()
28         self.conn = winreg.winreg("ncalrpc:", self.get_loadparm(),
29                                   self.get_credentials())
30
31     def get_hklm(self):
32         return self.conn.OpenHKLM(None,
33                                   winreg.KEY_QUERY_VALUE | winreg.KEY_ENUMERATE_SUB_KEYS)
34
35     def test_hklm(self):
36         handle = self.conn.OpenHKLM(None,
37                                     winreg.KEY_QUERY_VALUE | winreg.KEY_ENUMERATE_SUB_KEYS)
38         self.conn.CloseKey(handle)
39
40     def test_getversion(self):
41         handle = self.get_hklm()
42         version = self.conn.GetVersion(handle)
43         self.assertEquals(int, version.__class__)
44         self.conn.CloseKey(handle)
45
46     def test_getkeyinfo(self):
47         handle = self.conn.OpenHKLM(None,
48                                     winreg.KEY_QUERY_VALUE | winreg.KEY_ENUMERATE_SUB_KEYS)
49         x = self.conn.QueryInfoKey(handle, winreg.String())
50         self.assertEquals(9, len(x)) # should return a 9-tuple
51         self.conn.CloseKey(handle)