mirror of
https://github.com/samba-team/samba.git
synced 2024-12-22 13:34:15 +03:00
tests/credentials.py: demonstrate the last 'username' line of creds.parse_file() beats other lines
Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
This commit is contained in:
parent
05e8bfdc95
commit
d7fb3bb572
@ -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()
|
||||
|
Loading…
Reference in New Issue
Block a user