'Receiving a bad handshake should yield a stream error.'

def test_onHandshakeWrongHash(self):

    streamErrors = []
    authd = []
    def authenticated(xs):
        authd.append(xs)
    xs = self.xmlstream
    xs.addOnetimeObserver(xmlstream.STREAM_AUTHD_EVENT, authenticated)
    xs.sendStreamError = streamErrors.append
    xs.sid = u'1234'
    theHash = '1234'
    xs.authenticator.onHandshake(theHash)
    self.assertEqual('not-authorized', streamErrors[(-1)].condition)
    self.assertEqual(0, len(authd))
