def test_equality(self): """ Two L{HashedEntry} instances compare equal if and only if they represent the same host and key in exactly the same way: the host salt, host hash, public key type, public key, and comment fields must all be equal. """ hostSalt = b"gJbSEPBG9ZSBoZpHNtZBD1bHKBA" hostHash = b"bQv+0Xa0dByrwkA1EB0E7Xop/Fo" publicKey = Key.fromString(sampleKey) keyType = networkString(publicKey.type()) comment = b"hello, world" entry = HashedEntry(hostSalt, hostHash, keyType, publicKey, comment) duplicate = HashedEntry(hostSalt, hostHash, keyType, publicKey, comment) # Vary the host salt self.assertNormalEqualityImplementation( entry, duplicate, HashedEntry(hostSalt[::-1], hostHash, keyType, publicKey, comment), ) # Vary the host hash self.assertNormalEqualityImplementation( entry, duplicate, HashedEntry(hostSalt, hostHash[::-1], keyType, publicKey, comment), ) # Vary the key type self.assertNormalEqualityImplementation( entry, duplicate, HashedEntry(hostSalt, hostHash, keyType[::-1], publicKey, comment), ) # Vary the key self.assertNormalEqualityImplementation( entry, duplicate, HashedEntry(hostSalt, hostHash, keyType, Key.fromString(otherSampleKey), comment), ) # Vary the comment self.assertNormalEqualityImplementation( entry, duplicate, HashedEntry(hostSalt, hostHash, keyType, publicKey, comment[::-1]), )
def setUp(self): """ Set 'entry' to a sample hashed entry for twistedmatrix.com with sampleKey as its key. """ self.entry = HashedEntry.fromString(self.hashedLine)