Opened 2 years ago

Closed 2 years ago

Last modified 2 years ago

#5700 defect closed fixed (fixed)

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 (1)

twisted-conch-test-getCipher.patch (914 bytes) - added by marienz 2 years ago.
make test_getCiphers work with pycrypto 2.5 and 2.6

Download all attachments as: .zip

Change History (10)

comment:1 Changed 2 years ago by DefaultCC Plugin

  • Cc z3p added

comment:2 Changed 2 years 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.

comment:3 Changed 2 years ago by Arfrever

  • Cc Arfrever.FTA@… added

Changed 2 years ago by marienz

make test_getCiphers work with pycrypto 2.5 and 2.6

comment:4 Changed 2 years 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).

comment:5 Changed 2 years ago by z3p

  • Author set to z3p
  • Branch set to branches/getCipher-pycrypto26-5700

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

comment:6 Changed 2 years 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.

comment:7 Changed 2 years ago by therve

  • Keywords review removed
  • Owner set to z3p

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.

comment:8 Changed 2 years ago by z3p

  • Resolution set to fixed
  • Status changed from new to closed

(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.

comment:9 Changed 2 years 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.