5ce8c0ff74c5555ff3577669361f32636954a68b
[nivanova/samba-autobuild/.git] / python / samba / tests / s3registry.py
1 # Unix SMB/CIFS implementation.
2 # Copyright (C) Jelmer Vernooij <jelmer@samba.org> 2007
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.samba3."""
19
20 from samba.samba3 import Registry
21 from samba.tests import TestCase, TestCaseInTempDir
22 from samba.dcerpc.security import dom_sid
23 import os
24
25
26 for p in [ "../../../../../testdata/samba3", "../../../../testdata/samba3" ]:
27     DATADIR = os.path.join(os.path.dirname(__file__), p)
28     if os.path.exists(DATADIR):
29         break
30
31
32 class RegistryTestCase(TestCase):
33
34     def setUp(self):
35         super(RegistryTestCase, self).setUp()
36         self.registry = Registry(os.path.join(DATADIR, "registry"))
37
38     def tearDown(self):
39         self.registry.close()
40         super(RegistryTestCase, self).tearDown()
41
42     def test_length(self):
43         self.assertEquals(28, len(self.registry))
44
45     def test_keys(self):
46         self.assertTrue(b"HKLM" in self.registry.keys())
47
48     def test_subkeys(self):
49         self.assertEquals([b"SOFTWARE", b"SYSTEM"], self.registry.subkeys(b"HKLM"))
50
51     def test_values(self):
52         self.assertEquals({b'DisplayName': (1, b'E\x00v\x00e\x00n\x00t\x00 \x00L\x00o\x00g\x00\x00\x00'),
53                            b'ErrorControl': (4, b'\x01\x00\x00\x00')},
54                            self.registry.values(b"HKLM/SYSTEM/CURRENTCONTROLSET/SERVICES/EVENTLOG"))