vfs_ceph_new: common prefix to debug-log messages
[Samba.git] / python / samba / tests / libsmb.py
blobcb632d0e3a71a36cc9abdad98301599b1cc68516
1 # Unix SMB/CIFS implementation.
2 # Copyright Volker Lendecke <vl@samba.org> 2012
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.samba3.libsmb."""
20 from samba.samba3 import libsmb_samba_internal as libsmb
21 from samba.dcerpc import security
22 from samba.samba3 import param as s3param
23 from samba import credentials
24 from samba import (ntstatus,NTSTATUSError)
25 import samba.tests
26 import os
28 class LibsmbTests(samba.tests.TestCase):
30 def setUp(self):
31 self.lp = s3param.get_context()
32 self.lp.load(samba.tests.env_get_var_value("SMB_CONF_PATH"))
34 self.creds = credentials.Credentials()
35 self.creds.guess(self.lp)
36 self.creds.set_domain(samba.tests.env_get_var_value("DOMAIN"))
37 self.creds.set_username(samba.tests.env_get_var_value("USERNAME"))
38 self.creds.set_password(samba.tests.env_get_var_value("PASSWORD"))
40 # Build the global inject file path
41 server_conf = samba.tests.env_get_var_value("SERVERCONFFILE")
42 server_conf_dir = os.path.dirname(server_conf)
43 self.global_inject = os.path.join(server_conf_dir, "global_inject.conf")
45 self.server_ip = samba.tests.env_get_var_value("SERVER_IP")
47 def clean_file(self, conn, filename):
48 try:
49 conn.unlink(filename)
50 except NTSTATUSError as e:
51 if e.args[0] == ntstatus.NT_STATUS_FILE_IS_A_DIRECTORY:
52 conn.rmdir(filename)
53 elif not (e.args[0] == ntstatus.NT_STATUS_OBJECT_NAME_NOT_FOUND or
54 e.args[0] == ntstatus.NT_STATUS_OBJECT_PATH_NOT_FOUND):
55 raise