Beispiel #1
0
    def test_passes_token_through_trace(self):
        with unittest.mock.patch("aiosasl.trace") as trace:
            trace.return_value = "traced"

            anon = aiosasl.ANONYMOUS(unittest.mock.sentinel.token)

        trace.assert_called_with(unittest.mock.sentinel.token)

        smmock = aiosasl.SASLStateMachine(SASLInterfaceMock(
            self,
            [
                ("auth;ANONYMOUS",
                 b"traced",
                 "success",
                 None)
            ]))

        def run():
            result = yield from anon.authenticate(
                smmock,
                "ANONYMOUS")
            self.assertTrue(result)

        asyncio.get_event_loop().run_until_complete(run())

        smmock.interface.finalize()
Beispiel #2
0
    def execute(self, client_jid, features, xmlstream, tls_transport):
        mechanism_class, token = self._find_supported(features,
                                                      [aiosasl.ANONYMOUS])

        if mechanism_class is None:
            return False

        intf = sasl.SASLXMPPInterface(xmlstream)
        mechanism = aiosasl.ANONYMOUS(self._token)

        return (yield from self._execute(
            intf,
            mechanism,
            token,
        ))
Beispiel #3
0
 def run():
     anon = aiosasl.ANONYMOUS("sirhc")
     result = yield from anon.authenticate(
         smmock,
         "ANONYMOUS")
     self.assertTrue(result)