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
)
29 class LibsmbTests(samba
.tests
.TestCase
):
32 self
.lp
= s3param
.get_context()
33 self
.lp
.load(samba
.tests
.env_get_var_value("SMB_CONF_PATH"))
35 self
.creds
= credentials
.Credentials()
36 self
.creds
.guess(self
.lp
)
37 self
.creds
.set_domain(samba
.tests
.env_get_var_value("DOMAIN"))
38 self
.creds
.set_username(samba
.tests
.env_get_var_value("USERNAME"))
39 self
.creds
.set_password(samba
.tests
.env_get_var_value("PASSWORD"))
41 # Build the global inject file path
42 server_conf
= samba
.tests
.env_get_var_value("SERVERCONFFILE")
43 server_conf_dir
= os
.path
.dirname(server_conf
)
44 self
.global_inject
= os
.path
.join(server_conf_dir
, "global_inject.conf")
46 self
.server_ip
= samba
.tests
.env_get_var_value("SERVER_IP")
48 def clean_file(self
, conn
, filename
):
51 except NTSTATUSError
as e
:
52 if e
.args
[0] == ntstatus
.NT_STATUS_FILE_IS_A_DIRECTORY
:
54 elif not (e
.args
[0] == ntstatus
.NT_STATUS_OBJECT_NAME_NOT_FOUND
or
55 e
.args
[0] == ntstatus
.NT_STATUS_OBJECT_PATH_NOT_FOUND
):
58 def wire_mode_to_unix(self
, wire
):
59 mode
= libsmb
.wire_mode_to_unix(wire
)
60 type = stat
.S_IFMT(mode
)
61 perms
= mode
& (stat
.S_IRWXU|stat
.S_IRWXG|stat
.S_IRWXO|
62 stat
.S_ISUID|stat
.S_ISGID|stat
.S_ISVTX
)