[pywin32-checkins] pywin32/win32/test test_sspi.py,1.3,1.3.4.1
OLD project page for the Python extensions for Windows
Brought to you by:
mhammond
From: Roger U. <ru...@us...> - 2008-10-03 22:41:27
|
Update of /cvsroot/pywin32/pywin32/win32/test In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv30291 Modified Files: Tag: py3k test_sspi.py Log Message: Pass test data as bytes, use winerror exception attribute Index: test_sspi.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/test/test_sspi.py,v retrieving revision 1.3 retrieving revision 1.3.4.1 diff -C2 -d -r1.3 -r1.3.4.1 *** test_sspi.py 13 Feb 2006 14:49:31 -0000 1.3 --- test_sspi.py 3 Oct 2008 22:41:20 -0000 1.3.4.1 *************** *** 10,16 **** try: return func(*args) ! raise RuntimeError, "expecting %s failure" % (hr,) ! except win32security.error, (hr_got, func, msg): ! self.failUnlessEqual(hr_got, hr) def _doAuth(self, pkg_name): --- 10,16 ---- try: return func(*args) ! raise RuntimeError("expecting %s failure" % (hr,)) ! except win32security.error as exc: ! self.failUnlessEqual(exc.winerror, hr) def _doAuth(self, pkg_name): *************** *** 42,46 **** pkg_size_info=sspiclient.ctxt.QueryContextAttributes(sspicon.SECPKG_ATTR_SIZES) ! msg='some data to be encrypted ......' trailersize=pkg_size_info['SecurityTrailer'] --- 42,46 ---- pkg_size_info=sspiclient.ctxt.QueryContextAttributes(sspicon.SECPKG_ATTR_SIZES) ! msg=b'some data to be encrypted ......' trailersize=pkg_size_info['SecurityTrailer'] *************** *** 53,61 **** self.failUnlessEqual(msg, encbuf[0].Buffer) # and test the higher-level functions ! data, sig = sspiclient.encrypt("hello") ! self.assertEqual(sspiserver.decrypt(data, sig), "hello") ! data, sig = sspiserver.encrypt("hello") ! self.assertEqual(sspiclient.decrypt(data, sig), "hello") def testEncryptNTLM(self): --- 53,61 ---- self.failUnlessEqual(msg, encbuf[0].Buffer) # and test the higher-level functions ! data, sig = sspiclient.encrypt(b"hello") ! self.assertEqual(sspiserver.decrypt(data, sig), b"hello") ! data, sig = sspiserver.encrypt(b"hello") ! self.assertEqual(sspiclient.decrypt(data, sig), b"hello") def testEncryptNTLM(self): *************** *** 70,74 **** pkg_size_info=sspiclient.ctxt.QueryContextAttributes(sspicon.SECPKG_ATTR_SIZES) ! msg='some data to be encrypted ......' sigsize=pkg_size_info['MaxSignature'] --- 70,74 ---- pkg_size_info=sspiclient.ctxt.QueryContextAttributes(sspicon.SECPKG_ATTR_SIZES) ! msg=b'some data to be encrypted ......' sigsize=pkg_size_info['MaxSignature'] *************** *** 82,97 **** sspiclient.next_seq_num = 1 sspiserver.next_seq_num = 1 ! key = sspiclient.sign("hello") ! sspiserver.verify("hello", key) ! key = sspiclient.sign("hello") self.assertRaisesHRESULT(sspicon.SEC_E_MESSAGE_ALTERED, ! sspiserver.verify, "hellox", key) # and the other way ! key = sspiserver.sign("hello") ! sspiclient.verify("hello", key) ! key = sspiserver.sign("hello") self.assertRaisesHRESULT(sspicon.SEC_E_MESSAGE_ALTERED, ! sspiclient.verify, "hellox", key) def testSignNTLM(self): --- 82,97 ---- sspiclient.next_seq_num = 1 sspiserver.next_seq_num = 1 ! key = sspiclient.sign(b"hello") ! sspiserver.verify(b"hello", key) ! key = sspiclient.sign(b"hello") self.assertRaisesHRESULT(sspicon.SEC_E_MESSAGE_ALTERED, ! sspiserver.verify, b"hellox", key) # and the other way ! key = sspiserver.sign(b"hello") ! sspiclient.verify(b"hello", key) ! key = sspiserver.sign(b"hello") self.assertRaisesHRESULT(sspicon.SEC_E_MESSAGE_ALTERED, ! sspiclient.verify, b"hellox", key) def testSignNTLM(self): *************** *** 103,117 **** def testSequenceSign(self): # Only Kerberos supports sequence detection. ! sspiclient, sspiserver = self._doAuth("Kerberos") ! key = sspiclient.sign("hello") ! sspiclient.sign("hello") self.assertRaisesHRESULT(sspicon.SEC_E_OUT_OF_SEQUENCE, ! sspiserver.verify, 'hello', key) def testSequenceEncrypt(self): # Only Kerberos supports sequence detection. sspiclient, sspiserver = self._doAuth("Kerberos") ! blob, key = sspiclient.encrypt("hello",) ! blob, key = sspiclient.encrypt("hello") self.assertRaisesHRESULT(sspicon.SEC_E_OUT_OF_SEQUENCE, sspiserver.decrypt, blob, key) --- 103,117 ---- def testSequenceSign(self): # Only Kerberos supports sequence detection. ! sspiclient, sspiserver = self._doAuth(b"Kerberos") ! key = sspiclient.sign(b"hello") ! sspiclient.sign(b"hello") self.assertRaisesHRESULT(sspicon.SEC_E_OUT_OF_SEQUENCE, ! sspiserver.verify, b'hello', key) def testSequenceEncrypt(self): # Only Kerberos supports sequence detection. sspiclient, sspiserver = self._doAuth("Kerberos") ! blob, key = sspiclient.encrypt(b"hello",) ! blob, key = sspiclient.encrypt(b"hello") self.assertRaisesHRESULT(sspicon.SEC_E_OUT_OF_SEQUENCE, sspiserver.decrypt, blob, key) |