summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2016-12-15 10:30:29 +0100
committerAndrew Bartlett <abartlet@samba.org>2016-12-20 01:11:24 +0100
commit9fa7f59f88cb0350c0616d6f0a6a06b4e7a52228 (patch)
tree493f784477fea0e8f4a6d824cb95a1548d9bc31b /python
parentdf652c3ede181576f63ae20ccd993203b744952d (diff)
downloadsamba-9fa7f59f88cb0350c0616d6f0a6a06b4e7a52228.tar.gz
tests/credentials.py: add very simple test for py_creds_parse_file
Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Diffstat (limited to 'python')
-rw-r--r--python/samba/tests/credentials.py24
1 files changed, 23 insertions, 1 deletions
diff --git a/python/samba/tests/credentials.py b/python/samba/tests/credentials.py
index ad3f663e14d..0a64179d102 100644
--- a/python/samba/tests/credentials.py
+++ b/python/samba/tests/credentials.py
@@ -26,7 +26,7 @@ import samba.tests
import os
import binascii
-class CredentialsTests(samba.tests.TestCase):
+class CredentialsTests(samba.tests.TestCaseInTempDir):
def setUp(self):
super(CredentialsTests, self).setUp()
@@ -156,6 +156,28 @@ class CredentialsTests(samba.tests.TestCase):
self.assertEqual(creds.is_anonymous(), True)
self.assertEqual(creds.authentication_requested(), False)
+ def test_parse_file_1(self):
+ realm="realm.example.com"
+ domain="dom"
+ password="pass"
+ username="user"
+
+ passwd_file_name = os.path.join(self.tempdir, "parse_file")
+ passwd_file_fd = open(passwd_file_name, 'wx')
+ passwd_file_fd.write("realm=%s\n" % realm)
+ passwd_file_fd.write("domain=%s\n" % domain)
+ passwd_file_fd.write("username=%s\n" % username)
+ passwd_file_fd.write("password=%s\n" % password)
+ 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(), domain.upper())
+ self.assertEqual(self.creds.get_realm(), realm.upper())
+ self.assertEqual(self.creds.is_anonymous(), False)
+ self.assertEqual(self.creds.authentication_requested(), True)
+ os.unlink(passwd_file_name)
+
def test_parse_username(self):
creds = credentials.Credentials()
lp = samba.tests.env_loadparm()