python:tests/core: add tests for arcfour_encrypt() and string_to_byte_array()
authorStefan Metzmacher <metze@samba.org>
Thu, 28 Jan 2016 14:10:00 +0000 (15:10 +0100)
committerStefan Metzmacher <metze@samba.org>
Wed, 3 Feb 2016 10:42:29 +0000 (11:42 +0100)
BUG: https://bugzilla.samba.org/show_bug.cgi?id=11699

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Alexander Bokovoy <ab@samba.org>
Autobuild-User(master): Stefan Metzmacher <metze@samba.org>
Autobuild-Date(master): Wed Feb  3 11:42:29 CET 2016 on sn-devel-144

python/samba/tests/core.py

index 8206e68d4fb8b3a8e51362090dc5c839c0fa1436..9dbaff11e6634f4ca25c2f5ea723242982f7be89 100644 (file)
@@ -20,6 +20,7 @@
 import ldb
 import os
 import samba
+from samba import arcfour_encrypt, string_to_byte_array
 from samba.tests import TestCase, TestCaseInTempDir
 
 class SubstituteVarTestCase(TestCase):
@@ -48,6 +49,21 @@ class SubstituteVarTestCase(TestCase):
         self.assertRaises(Exception, samba.check_all_substituted,
                 "Not subsituted: ${FOOBAR}")
 
+class ArcfourTestCase(TestCase):
+
+    def test_arcfour_direct(self):
+        key = '12345678'
+        plain = 'abcdefghi'
+        crypt_expected = '\xda\x91Z\xb0l\xd7\xb9\xcf\x99'
+        crypt_calculated = arcfour_encrypt(key, plain)
+        self.assertEquals(crypt_expected, crypt_calculated)
+
+class StringToByteArrayTestCase(TestCase):
+
+    def test_byte_array(self):
+        expected = [218, 145, 90, 176, 108, 215, 185, 207, 153]
+        calculated = string_to_byte_array('\xda\x91Z\xb0l\xd7\xb9\xcf\x99')
+        self.assertEquals(expected, calculated)
 
 class LdbExtensionTests(TestCaseInTempDir):