summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2016-01-28 15:10:00 +0100
committerKarolin Seeger <kseeger@samba.org>2016-02-05 13:10:00 +0100
commit9270b1d8bb77a891804008ac35edcf4b7569fd99 (patch)
treec3091c16ca5af4746a878a0d74a74dfa48cc816e
parent6c44fabcfd6fc4370a78854ab0ee9ac54f137a0e (diff)
downloadsamba-9270b1d8bb77a891804008ac35edcf4b7569fd99.tar.gz
python:tests/core: add tests for arcfour_encrypt() and string_to_byte_array()
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 (cherry picked from commit 915185aa585a622d338698f847171972d1a15a21) Autobuild-User(v4-3-test): Karolin Seeger <kseeger@samba.org> Autobuild-Date(v4-3-test): Fri Feb 5 13:10:00 CET 2016 on sn-devel-104
-rw-r--r--python/samba/tests/core.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/python/samba/tests/core.py b/python/samba/tests/core.py
index 8206e68d4fb..9dbaff11e66 100644
--- a/python/samba/tests/core.py
+++ b/python/samba/tests/core.py
@@ -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):