libsmb: Use clistr_smb2_extract_snapshot_token() in cli_smb2_create_fnum_send()
[Samba.git] / python / samba / tests / dsdb_api.py
blob997407917af413ef98136d51645752f5cb2e5793
1 # Unix SMB/CIFS implementation. Tests for dsdb
2 # Copyright (C) Andrew Bartlett <abartlet@samba.org> 2021
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.dsdb."""
20 from samba.tests import TestCase, DynamicTestCase
21 from samba.dsdb import user_account_control_flag_bit_to_string
22 import samba
25 @DynamicTestCase
26 class DsdbFlagTests(TestCase):
28 @classmethod
29 def setUpDynamicTestCases(cls):
31 for x in dir(samba.dsdb):
32 if x.startswith("UF_"):
33 cls.generate_dynamic_test("test",
36 getattr(samba.dsdb, x))
39 def _test_with_args(self, uf_string, uf_bit):
40 self.assertEqual(user_account_control_flag_bit_to_string(uf_bit),
41 uf_string)
44 def test_not_a_flag(self):
45 self.assertRaises(KeyError,
46 user_account_control_flag_bit_to_string,
47 0xabcdef)
49 def test_too_long(self):
50 self.assertRaises(OverflowError,
51 user_account_control_flag_bit_to_string,
52 0xabcdefffff)
54 def test_way_too_long(self):
55 self.assertRaises(OverflowError,
56 user_account_control_flag_bit_to_string,
57 0xabcdeffffffffffff)