def test_publickey(self):
        """
        Test that the client can authenticate with a public key.
        """
        self.authClient.ssh_USERAUTH_FAILURE(NS(b'publickey') + b'\x00')
        self.assertEqual(self.authClient.transport.packets[-1],
                (userauth.MSG_USERAUTH_REQUEST, NS(b'foo') + NS(b'nancy')
                    + NS(b'publickey') + b'\x00' + NS(b'ssh-dss')
                    + NS(keys.Key.fromString(
                        keydata.publicDSA_openssh).blob())))
       # that key isn't good
        self.authClient.ssh_USERAUTH_FAILURE(NS(b'publickey') + b'\x00')
        blob = NS(keys.Key.fromString(keydata.publicRSA_openssh).blob())
        self.assertEqual(self.authClient.transport.packets[-1],
                (userauth.MSG_USERAUTH_REQUEST, (NS(b'foo') + NS(b'nancy')
                    + NS(b'publickey') + b'\x00' + NS(b'ssh-rsa') + blob)))
        self.authClient.ssh_USERAUTH_PK_OK(NS(b'ssh-rsa')
            + NS(keys.Key.fromString(keydata.publicRSA_openssh).blob()))
        sigData = (NS(self.authClient.transport.sessionID)
                + chr(userauth.MSG_USERAUTH_REQUEST) + NS(b'foo')
                + NS(b'nancy') + NS(b'publickey') + b'\x01' + NS(b'ssh-rsa')
                + blob)
        obj = keys.Key.fromString(keydata.privateRSA_openssh)
        self.assertEqual(self.authClient.transport.packets[-1],
                (userauth.MSG_USERAUTH_REQUEST, NS(b'foo') + NS(b'nancy')
                    + NS(b'publickey') + b'\x01' + NS(b'ssh-rsa') + blob
                    + NS(obj.sign(sigData))))

        Test that the client can authenticate with a public key.
        
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_userauth.py