3 # Unix SMB/CIFS implementation.
4 # Copyright (C) Jelmer Vernooij <jelmer@samba.org> 2007
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 3 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program. If not, see <http://www.gnu.org/licenses/>.
21 from samba import security
23 class SecurityTokenTests(unittest.TestCase):
25 self.token = security.SecurityToken()
27 def test_is_system(self):
28 self.assertFalse(self.token.is_system())
30 def test_is_anonymous(self):
31 self.assertFalse(self.token.is_anonymous())
33 def test_has_builtin_administrators(self):
34 self.assertFalse(self.token.has_builtin_administrators())
36 def test_has_nt_authenticated_users(self):
37 self.assertFalse(self.token.has_nt_authenticated_users())
39 def test_has_priv(self):
40 self.assertFalse(self.token.has_privilege(security.SEC_PRIV_SHUTDOWN))
42 def test_set_priv(self):
43 self.assertFalse(self.token.has_privilege(security.SEC_PRIV_SHUTDOWN))
44 self.assertFalse(self.token.set_privilege(security.SEC_PRIV_SHUTDOWN))
45 self.assertTrue(self.token.has_privilege(security.SEC_PRIV_SHUTDOWN))
48 class SecurityDescriptorTests(unittest.TestCase):
50 self.descriptor = security.SecurityDescriptor()
53 class DomSidTests(unittest.TestCase):
54 def test_parse_sid(self):
55 sid = security.Sid("S-1-5-21")
56 self.assertEquals("S-1-5-21", str(sid))
58 def test_sid_equal(self):
59 sid1 = security.Sid("S-1-5-21")
60 sid2 = security.Sid("S-1-5-21")
61 self.assertTrue(sid1.__eq__(sid1))
62 self.assertTrue(sid1.__eq__(sid2))
64 def test_random(self):
65 sid = security.random_sid()
66 self.assertTrue(str(sid).startswith("S-1-5-21-"))
69 class PrivilegeTests(unittest.TestCase):
70 def test_privilege_name(self):
71 self.assertEquals("SeShutdownPrivilege", security.privilege_name(security.SEC_PRIV_SHUTDOWN))
73 def test_privilege_id(self):
74 self.assertEquals(security.SEC_PRIV_SHUTDOWN, security.privilege_id("SeShutdownPrivilege"))