~ubuntu-branches/ubuntu/vivid/samba/vivid

« back to all changes in this revision

Viewing changes to source4/scripting/python/samba/tests/samba3.py

  • Committer: Package Import Robot
  • Author(s): Chuck Short
  • Date: 2011-12-21 13:18:04 UTC
  • mfrom: (0.39.21 sid)
  • Revision ID: package-import@ubuntu.com-20111221131804-xtlr39wx6njehxxr
Tags: 2:3.6.1-3ubuntu1
* Merge from Debian testing.  Remaining changes:
  + debian/patches/VERSION.patch:
    - set SAMBA_VERSION_SUFFIX to Ubuntu.
  + debian/patches/error-trans.fix-276472:
    - Add the translation of Unix Error code -ENOTSUP to NT Error Code
    - NT_STATUS_NOT_SUPPORTED to prevent the Permission denied error.
  + debian/smb.conf:
    - add "(Samba, Ubuntu)" to server string.
    - comment out the default [homes] share, and add a comment about
      "valid users = %S" to show users how to restrict access to
      \\server\username to only username.
    - Set 'usershare allow guests', so that usershare admins are 
      allowed to create public shares in addition to authenticated
      ones.
    - add map to guest = Bad user, maps bad username to guest access.
  + debian/samba-common.config:
    - Do not change priority to high if dhclient3 is installed.
    - Use priority medium instead of high for the workgroup question.
  + debian/control:
    - Don't build against or suggest ctdb.
    - Add dependency on samba-common-bin to samba.
  + Add ufw integration:
    - Created debian/samba.ufw.profile
    - debian/rules, debian/samba.dirs, debian/samba.files: install
      profile
    - debian/control: have samba suggest ufw
  + Add apport hook:
    - Created debian/source_samba.py.
    - debian/rules, debian/samba.dirs, debian/samba-common-bin.files: install
  + Switch to upstart:
    - Add debian/samba.{nmbd,smbd}.upstart.
  + debian/samba.logrotate, debian/samba-common.dhcp, debian/samba.if-up:
    - Make them upstart compatible
  + debian/samba.postinst: 
    - Avoid scary pdbedit warnings on first import.
  + debian/samba-common.postinst: Add more informative error message for
    the case where smb.conf was manually deleted
  + debian/patches/fix-debuglevel-name-conflict.patch: don't use 'debug_level'
    as a global variable name in an NSS module 
  + Dropped:
    - debian/patches/error-trans.fix-276472
    - debian/patches/fix-debuglevel-name-conflict.patch

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/usr/bin/python
 
1
#!/usr/bin/env python
2
2
 
3
3
# Unix SMB/CIFS implementation.
4
4
# Copyright (C) Jelmer Vernooij <jelmer@samba.org> 2007
17
17
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
18
18
#
19
19
 
20
 
import unittest
21
 
from samba.samba3 import GroupMappingDatabase, Registry, PolicyDatabase, SecretsDatabase, TdbSam
22
 
from samba.samba3 import WinsDatabase, SmbpasswdFile, ACB_NORMAL, IdmapDatabase, SAMUser, ParamFile
 
20
"""Tests for samba.samba3."""
 
21
 
 
22
from samba.samba3 import (GroupMappingDatabase, Registry, PolicyDatabase,
 
23
        SecretsDatabase, TdbSam)
 
24
from samba.samba3 import (WinsDatabase, SmbpasswdFile, ACB_NORMAL,
 
25
        IdmapDatabase, SAMUser, ParamFile)
 
26
from samba.tests import TestCase
23
27
import os
24
28
 
25
 
DATADIR=os.path.join(os.path.dirname(__file__), "../../../../../testdata/samba3")
26
 
print "Samba 3 data dir: %s" % DATADIR
27
 
 
28
 
class RegistryTestCase(unittest.TestCase):
 
29
for p in [ "../../../../../testdata/samba3", "../../../../testdata/samba3" ]:
 
30
    DATADIR = os.path.join(os.path.dirname(__file__), p)
 
31
    if os.path.exists(DATADIR):
 
32
        break
 
33
 
 
34
 
 
35
class RegistryTestCase(TestCase):
 
36
 
29
37
    def setUp(self):
 
38
        super(RegistryTestCase, self).setUp()
30
39
        self.registry = Registry(os.path.join(DATADIR, "registry.tdb"))
31
40
 
32
41
    def tearDown(self):
33
42
        self.registry.close()
 
43
        super(RegistryTestCase, self).tearDown()
34
44
 
35
45
    def test_length(self):
36
46
        self.assertEquals(28, len(self.registry))
47
57
                           self.registry.values("HKLM/SYSTEM/CURRENTCONTROLSET/SERVICES/EVENTLOG"))
48
58
 
49
59
 
50
 
class PolicyTestCase(unittest.TestCase):
 
60
class PolicyTestCase(TestCase):
 
61
 
51
62
    def setUp(self):
 
63
        super(PolicyTestCase, self).setUp()
52
64
        self.policy = PolicyDatabase(os.path.join(DATADIR, "account_policy.tdb"))
53
65
 
54
66
    def test_policy(self):
64
76
        self.assertEquals(self.policy.bad_lockout_minutes, None)
65
77
 
66
78
 
67
 
class GroupsTestCase(unittest.TestCase):
 
79
class GroupsTestCase(TestCase):
 
80
 
68
81
    def setUp(self):
 
82
        super(GroupsTestCase, self).setUp()
69
83
        self.groupdb = GroupMappingDatabase(os.path.join(DATADIR, "group_mapping.tdb"))
70
84
 
71
85
    def tearDown(self):
72
86
        self.groupdb.close()
 
87
        super(GroupsTestCase, self).tearDown()
73
88
 
74
89
    def test_group_length(self):
75
90
        self.assertEquals(13, len(list(self.groupdb.groupsids())))
85
100
        self.assertEquals(0, len(list(self.groupdb.aliases())))
86
101
 
87
102
 
88
 
class SecretsDbTestCase(unittest.TestCase):
 
103
class SecretsDbTestCase(TestCase):
 
104
 
89
105
    def setUp(self):
 
106
        super(SecretsDbTestCase, self).setUp()
90
107
        self.secretsdb = SecretsDatabase(os.path.join(DATADIR, "secrets.tdb"))
91
108
 
92
109
    def tearDown(self):
93
110
        self.secretsdb.close()
 
111
        super(SecretsDbTestCase, self).tearDown()
94
112
 
95
113
    def test_get_sid(self):
96
114
        self.assertTrue(self.secretsdb.get_sid("BEDWYR") is not None)
97
115
 
98
116
 
99
 
class TdbSamTestCase(unittest.TestCase):
 
117
class TdbSamTestCase(TestCase):
 
118
 
100
119
    def setUp(self):
 
120
        super(TdbSamTestCase, self).setUp()
101
121
        self.samdb = TdbSam(os.path.join(DATADIR, "passdb.tdb"))
102
122
 
103
123
    def tearDown(self):
104
124
        self.samdb.close()
 
125
        super(TdbSamTestCase, self).tearDown()
105
126
 
106
127
    def test_usernames(self):
107
128
        self.assertEquals(3, len(list(self.samdb.usernames())))
140
161
        self.assertEquals(user, other)
141
162
 
142
163
 
143
 
class WinsDatabaseTestCase(unittest.TestCase):
 
164
class WinsDatabaseTestCase(TestCase):
 
165
 
144
166
    def setUp(self):
 
167
        super(WinsDatabaseTestCase, self).setUp()
145
168
        self.winsdb = WinsDatabase(os.path.join(DATADIR, "wins.dat"))
146
169
 
147
170
    def test_length(self):
152
175
 
153
176
    def tearDown(self):
154
177
        self.winsdb.close()
155
 
 
156
 
 
157
 
class SmbpasswdTestCase(unittest.TestCase):
 
178
        super(WinsDatabaseTestCase, self).tearDown()
 
179
 
 
180
 
 
181
class SmbpasswdTestCase(TestCase):
 
182
 
158
183
    def setUp(self):
 
184
        super(SmbpasswdTestCase, self).setUp()
159
185
        self.samdb = SmbpasswdFile(os.path.join(DATADIR, "smbpasswd"))
160
186
 
161
187
    def test_length(self):
172
198
 
173
199
    def tearDown(self):
174
200
        self.samdb.close()
175
 
 
176
 
 
177
 
class IdmapDbTestCase(unittest.TestCase):
 
201
        super(SmbpasswdTestCase, self).tearDown()
 
202
 
 
203
 
 
204
class IdmapDbTestCase(TestCase):
 
205
 
178
206
    def setUp(self):
179
 
        self.idmapdb = IdmapDatabase(os.path.join(DATADIR, "winbindd_idmap.tdb"))
 
207
        super(IdmapDbTestCase, self).setUp()
 
208
        self.idmapdb = IdmapDatabase(os.path.join(DATADIR,
 
209
            "winbindd_idmap.tdb"))
180
210
 
181
211
    def test_user_hwm(self):
182
212
        self.assertEquals(10000, self.idmapdb.get_user_hwm())
198
228
 
199
229
    def tearDown(self):
200
230
        self.idmapdb.close()
201
 
 
202
 
 
203
 
class ShareInfoTestCase(unittest.TestCase):
204
 
    def setUp(self):
205
 
        self.shareinfodb = ShareInfoDatabase(os.path.join(DATADIR, "share_info.tdb"))
206
 
 
207
 
    # FIXME: needs proper data so it can be tested
208
 
 
209
 
    def tearDown(self):
210
 
        self.shareinfodb.close()
211
 
 
212
 
 
213
 
class ParamTestCase(unittest.TestCase):
 
231
        super(IdmapDbTestCase, self).tearDown()
 
232
 
 
233
 
 
234
class ParamTestCase(TestCase):
 
235
 
214
236
    def test_init(self):
215
237
        file = ParamFile()
216
238
        self.assertTrue(file is not None)