summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2018-07-11 16:48:07 +1200
committerAndrew Bartlett <abartlet@samba.org>2018-07-12 04:32:05 +0200
commit77ffadd3a04d442c19549611dc8cdf253db3863b (patch)
treec65c01ceb40ae1e7c4af4224bcb407988ff5426f
parentc02023fbbc320e1c25803da94e7dcc9c9376c36d (diff)
downloadsamba-77ffadd3a04d442c19549611dc8cdf253db3863b.tar.gz
selftest: Add tests for samba.auth.admin_session()
Signed-off-by: Andrew Bartlett <abartlet@samba.org> Signed-off-by: Joe Guo <joeg@catalyst.net.nz> Pair-programmed-with: Joe Guo <joeg@catalyst.net.nz> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
-rw-r--r--python/samba/tests/auth.py41
-rw-r--r--selftest/tests.py2
2 files changed, 38 insertions, 5 deletions
diff --git a/python/samba/tests/auth.py b/python/samba/tests/auth.py
index a1b8115dba1..6318bec40a0 100644
--- a/python/samba/tests/auth.py
+++ b/python/samba/tests/auth.py
@@ -24,11 +24,12 @@ the functionality, that's already done in other tests.
from samba import auth
import samba.tests
-class AuthTests(samba.tests.TestCase):
+class AuthSystemSessionTests(samba.tests.TestCase):
def setUp(self):
- super(AuthTests, self).setUp()
+ super(AuthSystemSessionTests, self).setUp()
self.system_session = auth.system_session()
+ self.lp = samba.tests.env_loadparm()
def test_system_session_attrs(self):
self.assertTrue(hasattr(self.system_session, 'credentials'))
@@ -39,8 +40,9 @@ class AuthTests(samba.tests.TestCase):
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(), '')
+ self.assertIsNotNone(self.system_session.credentials.get_password())
+ self.assertEqual(self.system_session.credentials.get_username(),
+ self.lp.get('netbios name').upper() + "$")
def test_system_session_info(self):
self.assertEqual(self.system_session.info.full_name, 'System')
@@ -54,3 +56,34 @@ class AuthTests(samba.tests.TestCase):
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())
+
+class AuthAdminSessionTests(samba.tests.TestCase):
+
+ def setUp(self):
+ super(AuthAdminSessionTests, self).setUp()
+ self.lp = samba.tests.env_loadparm()
+ self.admin_session = auth.admin_session(self.lp,
+ "S-1-5-21-2212615479-2695158682-2101375467")
+
+ def test_admin_session_attrs(self):
+ self.assertTrue(hasattr(self.admin_session, 'credentials'))
+ self.assertTrue(hasattr(self.admin_session, 'info'))
+ self.assertTrue(hasattr(self.admin_session, 'security_token'))
+ self.assertTrue(hasattr(self.admin_session, 'session_key'))
+ self.assertTrue(hasattr(self.admin_session, 'torture'))
+
+ def test_admin_session_credentials(self):
+ self.assertIsNone(self.admin_session.credentials)
+
+ def test_session_info_details(self):
+ self.assertEqual(self.admin_session.info.full_name,
+ 'Administrator')
+ self.assertEqual(self.admin_session.info.domain_name,
+ self.lp.get('workgroup'))
+ self.assertEqual(self.admin_session.info.account_name,
+ 'Administrator')
+
+ def test_security_token(self):
+ self.assertFalse(self.admin_session.security_token.is_system())
+ self.assertFalse(self.admin_session.security_token.is_anonymous())
+ self.assertTrue(self.admin_session.security_token.has_builtin_administrators())
diff --git a/selftest/tests.py b/selftest/tests.py
index f354bb57ef5..6808925ffde 100644
--- a/selftest/tests.py
+++ b/selftest/tests.py
@@ -56,7 +56,7 @@ planpythontestsuite("none", "samba.tests.blackbox.check_output", py3_compatible=
planpythontestsuite("none", "api", name="ldb.python", extra_path=['lib/ldb/tests/python'])
planpythontestsuite("none", "samba.tests.credentials", py3_compatible=True)
planpythontestsuite("none", "samba.tests.registry", py3_compatible=True)
-planpythontestsuite("none", "samba.tests.auth", py3_compatible=True)
+planpythontestsuite("ad_dc_ntvfs:local", "samba.tests.auth", py3_compatible=True)
planpythontestsuite("none", "samba.tests.get_opt", py3_compatible=True)
planpythontestsuite("none", "samba.tests.security", py3_compatible=True)
planpythontestsuite("none", "samba.tests.dcerpc.misc", py3_compatible=True)