diff --git a/python/samba/tests/credentials.py b/python/samba/tests/credentials.py index 7aaa7118a26..4e5746e589a 100644 --- a/python/samba/tests/credentials.py +++ b/python/samba/tests/credentials.py @@ -231,6 +231,56 @@ class CredentialsTests(samba.tests.TestCaseInTempDir): self.assertEqual(self.creds.authentication_requested(), True) os.unlink(passwd_file_name) + def test_parse_file_4(self): + realm="realm.example.com" + domain="domain" + password="password" + username="username" + + userdom="userdom" + + passwd_file_name = os.path.join(self.tempdir, "parse_file") + passwd_file_fd = open(passwd_file_name, 'wx') + passwd_file_fd.write("username=%s\\%s%%%s\n" % (userdom, username, password)) + passwd_file_fd.write("realm=ignorerealm\n") + passwd_file_fd.write("domain=ignoredomain\n") + passwd_file_fd.write("password=ignorepassword\n") + passwd_file_fd.close() + self.creds.parse_file(passwd_file_name) + self.assertEqual(self.creds.get_username(), username) + self.assertEqual(self.creds.get_password(), password) + self.assertEqual(self.creds.get_domain(), userdom.upper()) + self.assertEqual(self.creds.get_realm(), userdom.upper()) + self.assertEqual(self.creds.get_principal(), "%s@%s" % (username, userdom.upper())) + self.assertEqual(self.creds.is_anonymous(), False) + self.assertEqual(self.creds.authentication_requested(), True) + os.unlink(passwd_file_name) + + def test_parse_file_5(self): + realm="realm.example.com" + domain="domain" + password="password" + username="username" + + userdom="userdom" + + passwd_file_name = os.path.join(self.tempdir, "parse_file") + passwd_file_fd = open(passwd_file_name, 'wx') + passwd_file_fd.write("realm=ignorerealm\n") + passwd_file_fd.write("username=%s\\%s%%%s\n" % (userdom, username, password)) + passwd_file_fd.write("domain=ignoredomain\n") + passwd_file_fd.write("password=ignorepassword\n") + passwd_file_fd.close() + self.creds.parse_file(passwd_file_name) + self.assertEqual(self.creds.get_username(), username) + self.assertEqual(self.creds.get_password(), password) + self.assertEqual(self.creds.get_domain(), userdom.upper()) + self.assertEqual(self.creds.get_realm(), userdom.upper()) + self.assertEqual(self.creds.get_principal(), "%s@%s" % (username, userdom.upper())) + self.assertEqual(self.creds.is_anonymous(), False) + self.assertEqual(self.creds.authentication_requested(), True) + os.unlink(passwd_file_name) + def test_parse_username_0(self): creds = credentials.Credentials() lp = samba.tests.env_loadparm()