libsmb: Use clistr_smb2_extract_snapshot_token() in cli_smb2_create_fnum_send()
[Samba.git] / python / samba / tests / samdb.py
blobf7697f83fdc75eec7bbd495fa0d55591fc1926e0
1 # Unix SMB/CIFS implementation. Tests for SamDB
2 # Copyright (C) Jelmer Vernooij <jelmer@samba.org> 2008
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.
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.
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/>.
18 """Tests for samba.samdb."""
20 import logging
21 import os
23 from samba.auth import system_session
24 from samba.provision import provision
25 from samba.tests import TestCaseInTempDir
26 from samba.dsdb import DS_DOMAIN_FUNCTION_2008_R2
29 class SamDBTestCase(TestCaseInTempDir):
30 """Base-class for tests with a Sam Database.
32 This is used by the Samba SamDB-tests, but e.g. also by the OpenChange
33 provisioning tests (which need a Sam).
34 """
36 def setUp(self):
37 super(SamDBTestCase, self).setUp()
38 self.session = system_session()
39 logger = logging.getLogger("selftest")
40 self.domain = "dsdb"
41 self.realm = "dsdb.samba.example.com"
42 host_name = "test"
43 server_role = "active directory domain controller"
44 self.result = provision(logger,
45 self.session, targetdir=self.tempdir,
46 realm=self.realm, domain=self.domain,
47 hostname=host_name,
48 use_ntvfs=True,
49 serverrole=server_role,
50 dns_backend="SAMBA_INTERNAL",
51 dom_for_fun_level=DS_DOMAIN_FUNCTION_2008_R2)
52 self.samdb = self.result.samdb
53 self.lp = self.result.lp
55 def tearDown(self):
56 self.rm_files('names.tdb')
57 self.rm_dirs('etc', 'msg.lock', 'private', 'state', 'bind-dns')
59 super(SamDBTestCase, self).tearDown()
62 class SamDBTests(SamDBTestCase):
64 def test_get_domain(self):
65 self.assertEqual(self.samdb.domain_dns_name(), self.realm.lower())
66 self.assertEqual(self.samdb.domain_netbios_name(), self.domain.upper())