libsmb: Use clistr_smb2_extract_snapshot_token() in cli_smb2_create_fnum_send()
[Samba.git] / python / samba / tests / smbd_base.py
blobb49bcc0828f8094dc2fff733fc693e21b9a1a274
1 # Unix SMB/CIFS implementation. Common code for smbd python bindings tests
2 # Copyright (C) Catalyst.Net Ltd 2019
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/>.
17 from samba.tests import TestCaseInTempDir
18 import os
20 TEST_UMASK = 0o042
22 class SmbdBaseTests(TestCaseInTempDir):
24 def get_umask(self):
25 # we can only get the umask by setting it to something
26 curr_umask = os.umask(0)
27 # restore the old setting
28 os.umask(curr_umask)
29 return curr_umask
31 def setUp(self):
32 super(SmbdBaseTests, self).setUp()
33 self.orig_umask = self.get_umask()
35 # set an arbitrary umask - the underlying smbd code should override
36 # this, but it allows us to check if umask is left unset
37 os.umask(TEST_UMASK)
39 def tearDown(self):
40 # the current umask should be what we set it to earlier - if it's not,
41 # it indicates the code has changed it and not restored it
42 self.assertEqual(self.get_umask(), TEST_UMASK,
43 "umask unexpectedly overridden by test")
45 # restore the original umask value (before we interferred with it)
46 os.umask(self.orig_umask)
48 super(SmbdBaseTests, self).tearDown()