diff --git a/python/samba/tests/credentials.py b/python/samba/tests/credentials.py index 1cbd540eac9..8bfab7ad823 100644 --- a/python/samba/tests/credentials.py +++ b/python/samba/tests/credentials.py @@ -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()