Ticket #5700 defect closed fixed

Opened 23 months ago

Last modified 22 months ago

twisted.conch.test.test_transport.SSHCiphersTestCase.test_getCipher() fails with pycrypto 2.6

Reported by: Arfrever Owned by: z3p
Priority: normal Milestone:
Component: conch Keywords:
Cc: z3p, Arfrever.FTA@…, marien.zwart@… Branch: branches/getCipher-pycrypto26-5700
(diff, github, buildbot, log)
Author: z3p Launchpad Bug:

Description

twisted.conch.test.test_transport.SSHCiphersTestCase.test_getCipher() fails with pycrypto 2.6 and passes with pycrypto 2.5. I use Twisted 12.1.0.

===============================================================================
[FAIL]
Traceback (most recent call last):
  File "/var/tmp/portage/dev-python/twisted-conch-12.1.0-r1000/temp/usr/lib64/python2.7/site-packages/twisted/conch/test/test_transport.py", line 1832, in test_getCipher
    self.assertTrue(str(cip).startswith('<' + modName))
twisted.trial.unittest.FailTest: None

twisted.conch.test.test_transport.SSHCiphersTestCase.test_getCipher
-------------------------------------------------------------------------------

If I add print((cipName, cip, modName)) in the loop in this test, then I see:

('cast128-ctr', <Crypto.Cipher.CAST.CAST128Cipher instance at 0x2f50680>, 'CAST')

Attachments

twisted-conch-test-getCipher.patch Download (0.9 KB) - added by marienz 23 months ago.
make test_getCiphers work with pycrypto 2.5 and 2.6

Change History

1

Changed 23 months ago by DefaultCC Plugin

  • cc z3p added

2

Changed 23 months ago by therve

The test is rather dump, but the error comes from a name change in pycrypto classes, from "<CAST object at xxx>" to "<Crypto.Cipher.CAST.CAST128Cipher instance at xxx>". It should be easy to fix, if we can a buildslave with the updated pycrypto version.

3

Changed 23 months ago by Arfrever

  • cc Arfrever.FTA@… added

Changed 23 months ago by marienz

make test_getCiphers work with pycrypto 2.5 and 2.6

4

Changed 23 months ago by marienz

  • cc marien.zwart@… added

The attached patch works for me against both pycrypto 2.5 and pycrypto 2.6. Alternatively the test could just check if modName is in repr(cip), but the attached change seems as safe and makes the test a little more precise.

The actual change to pycrypto is that 2.5 gave you an instance of an extension type while 2.6 gives you an instance of an old-style class. So if you want to work with both and don't want to do a fairly fuzzy match against repr(cip) you really need getClass here (it's type(cip) on one and cip.class on the other).

5

Changed 22 months ago by z3p

  • branch set to branches/getCipher-pycrypto26-5700
  • branch_author set to z3p

(In [34677]) Branching to 'getCipher-pycrypto26-5700'

6

Changed 22 months ago by z3p

  • keywords review added

Applied the patch, and forced a build:  http://buildbot.twistedmatrix.com/boxes-supported?branch=/branches/getCipher-pycrypto26-5700

Normally I'd review it here, but I have a headache and don't trust myself. If no one gets to it, I'll check it again later.

7

Changed 22 months ago by therve

  • owner set to z3p
  • keywords review removed

Looks good to me, please merge. We still need a build slave with the new version of the library, though. Can you send an email to the list or ping the buildbot maintainer to make sure it happens? Thanks.

8

Changed 22 months ago by z3p

  • status changed from new to closed
  • resolution set to fixed

(In [34697]) Merge getCipher-pycrypto26-5700: fix test failure with PyCrypto 2.6

Author: marienz Reviewer: therve Fixes: #5700

PyCrypto 2.6 changed the str() of some of its classes. This caused a failure in a test which was checking the str() to verify that we received the correct encryption class. This branch changes the test to check the name of the received class.

9

Changed 22 months ago by z3p

I've also sent an e-mail to the Twisted list to inquire about a new buildbox.

Note: See TracTickets for help on using tickets.