python: samba.tests.credentials: Add tests
authorLumir Balhar <lbalhar@redhat.com>
Wed, 19 Oct 2016 10:11:31 +0000 (12:11 +0200)
committerGarming Sam <garming@samba.org>
Sun, 6 Nov 2016 22:53:10 +0000 (23:53 +0100)
Newly tested functions:
- set_utf16_password
- set_old_password
- get_old_password
- set_old_utf16_password

Signed-off-by: Lumir Balhar <lbalhar@redhat.com>
Reviewed-by: Garming Sam <garming@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
python/samba/tests/credentials.py

index 2afc2307da1e1aad4f687a5f6b8441b24d7a8493..a08ef3e5dc5dd424e89d20cf77ee1088495e2f14 100644 (file)
@@ -38,6 +38,23 @@ class CredentialsTests(samba.tests.TestCase):
         self.creds.set_password("S3CreT")
         self.assertEqual("S3CreT", self.creds.get_password())
 
+    def test_set_utf16_password(self):
+        password = 'S3cRet'
+        passbytes = password.encode('utf-16-le')
+        self.assertTrue(self.creds.set_utf16_password(passbytes))
+        self.assertEqual(password, self.creds.get_password())
+
+    def test_set_old_password(self):
+        self.assertEqual(None, self.creds.get_old_password())
+        self.assertTrue(self.creds.set_old_password("S3c0ndS3CreT"))
+        self.assertEqual("S3c0ndS3CreT", self.creds.get_old_password())
+
+    def test_set_old_utf16_password(self):
+        password = '0ldS3cRet'
+        passbytes = password.encode('utf-16-le')
+        self.assertTrue(self.creds.set_old_utf16_password(passbytes))
+        self.assertEqual(password, self.creds.get_old_password())
+
     def test_set_domain(self):
         self.creds.set_domain("ABMAS")
         self.assertEqual("ABMAS", self.creds.get_domain())