mirror of
https://github.com/samba-team/samba.git
synced 2025-01-11 05:18:09 +03:00
tests/credentials.py: add tests with a realm from smb.conf
As we don't want to create a new smb.conf file we just simulate it with "creds.set_realm(realm, credentials.UNINITIALISED)". That's basically the same as the cli_credentials_set_conf() behaviour if a realm is specified in the configuration. Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
This commit is contained in:
parent
dab9456cfc
commit
86558b5ce8
@ -182,7 +182,7 @@ class CredentialsTests(samba.tests.TestCaseInTempDir):
|
||||
self.assertEqual(self.creds.authentication_requested(), True)
|
||||
os.unlink(passwd_file_name)
|
||||
|
||||
def test_parse_username(self):
|
||||
def test_parse_username_0(self):
|
||||
creds = credentials.Credentials()
|
||||
lp = samba.tests.env_loadparm()
|
||||
os.environ["USER"] = "env_user"
|
||||
@ -195,6 +195,21 @@ class CredentialsTests(samba.tests.TestCaseInTempDir):
|
||||
self.assertEqual(creds.is_anonymous(), False)
|
||||
self.assertEqual(creds.authentication_requested(), True)
|
||||
|
||||
def test_parse_username_1(self):
|
||||
creds = credentials.Credentials()
|
||||
lp = samba.tests.env_loadparm()
|
||||
os.environ["USER"] = "env_user"
|
||||
creds.guess(lp)
|
||||
realm = "realm.example.com"
|
||||
creds.set_realm(realm, credentials.UNINITIALISED)
|
||||
creds.parse_string("user")
|
||||
self.assertEqual(creds.get_username(), "user")
|
||||
self.assertEqual(creds.get_domain(), lp.get("workgroup").upper())
|
||||
self.assertEqual(creds.get_realm(), realm.upper())
|
||||
self.assertEqual(creds.get_principal(), "user@%s" % realm.upper())
|
||||
self.assertEqual(creds.is_anonymous(), False)
|
||||
self.assertEqual(creds.authentication_requested(), True)
|
||||
|
||||
def test_parse_username_with_domain(self):
|
||||
creds = credentials.Credentials()
|
||||
lp = samba.tests.env_loadparm()
|
||||
|
Loading…
Reference in New Issue
Block a user