From 7d7a14f2d7cefcfe467baf13ea37f5027c5f49d8 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 28 Jan 2016 15:10:00 +0100 Subject: [PATCH] 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 Reviewed-by: Alexander Bokovoy Autobuild-User(master): Stefan Metzmacher Autobuild-Date(master): Wed Feb 3 11:42:29 CET 2016 on sn-devel-144 (cherry picked from commit 915185aa585a622d338698f847171972d1a15a21) Autobuild-User(v4-4-test): Karolin Seeger Autobuild-Date(v4-4-test): Fri Feb 5 13:15:48 CET 2016 on sn-devel-144 --- python/samba/tests/core.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) 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): -- 2.11.4.GIT