Ticket #5776: randomhash_userauth.patch

File randomhash_userauth.patch, 1.3 KB (added by antoine, 22 months ago)
  • twisted/conch/ssh/userauth.py

    diff --git a/twisted/conch/ssh/userauth.py b/twisted/conch/ssh/userauth.py
    a b  
    836836MSG_USERAUTH_PK_OK            = 60 
    837837 
    838838messages = {} 
    839 for k, v in locals().items(): 
     839# Sorting ensures MSG_USERAUTH_PK_OK comes last. 
     840for k, v in sorted(globals().items()): 
    840841    if k[:4]=='MSG_': 
    841842        messages[v] = k # doesn't handle doubles 
    842843 
  • twisted/conch/test/test_userauth.py

    diff --git a/twisted/conch/test/test_userauth.py b/twisted/conch/test/test_userauth.py
    a b  
    10601060        def check(ignored): 
    10611061            self.assertEqual(server.transport.service.name, 'TestService') 
    10621062        return d.addCallback(check) 
     1063 
     1064 
     1065 
     1066class ModuleInitializationTestCase(unittest.TestCase): 
     1067 
     1068 
     1069    def test_messages(self): 
     1070        # Several message types have value 60, check that MSG_USERAUTH_PK_OK 
     1071        # is always the one which is mapped. 
     1072        self.assertEqual(userauth.SSHUserAuthServer.protocolMessages[60], 
     1073                         'MSG_USERAUTH_PK_OK') 
     1074        self.assertEqual(userauth.SSHUserAuthClient.protocolMessages[60], 
     1075                         'MSG_USERAUTH_PK_OK')