1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-24 21:34:56 +03:00

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
This commit is contained in:
Stefan Metzmacher 2016-01-28 15:10:00 +01:00
parent 8841b1e641
commit 915185aa58

View 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):