python: samba.tests.auth: Add tests for samba.auth module
authorLumir Balhar <lbalhar@redhat.com>
Mon, 2 Jan 2017 13:39:17 +0000 (14:39 +0100)
committerAndrew Bartlett <abartlet@samba.org>
Fri, 10 Mar 2017 06:31:11 +0000 (07:31 +0100)
Add some tests which test that `system_session` object has
correct attributes and methods.

Signed-off-by: Lumir Balhar <lbalhar@redhat.com>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
python/samba/tests/auth.py

index f71e1a784d2b6bd92da4b28d2d1773a3db8e5216..a1b8115dba1a9fae46ed2c187d09ff1a4f884316 100644 (file)
@@ -26,6 +26,31 @@ import samba.tests
 
 class AuthTests(samba.tests.TestCase):
 
-    def test_system_session(self):
-        auth.system_session()
+    def setUp(self):
+        super(AuthTests, self).setUp()
+        self.system_session = auth.system_session()
 
+    def test_system_session_attrs(self):
+        self.assertTrue(hasattr(self.system_session, 'credentials'))
+        self.assertTrue(hasattr(self.system_session, 'info'))
+        self.assertTrue(hasattr(self.system_session, 'security_token'))
+        self.assertTrue(hasattr(self.system_session, 'session_key'))
+        self.assertTrue(hasattr(self.system_session, 'torture'))
+
+    def test_system_session_credentials(self):
+        self.assertIsNone(self.system_session.credentials.get_bind_dn())
+        self.assertIsNone(self.system_session.credentials.get_password())
+        self.assertEqual(self.system_session.credentials.get_username(), '')
+
+    def test_system_session_info(self):
+        self.assertEqual(self.system_session.info.full_name, 'System')
+        self.assertEqual(self.system_session.info.domain_name, 'NT AUTHORITY')
+        self.assertEqual(self.system_session.info.account_name, 'SYSTEM')
+
+    def test_system_session_session_key(self):
+        expected = b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
+        self.assertEqual(self.system_session.session_key, expected)
+
+    def test_system_session_security_token(self):
+        self.assertTrue(self.system_session.security_token.is_system())
+        self.assertFalse(self.system_session.security_token.is_anonymous())