Ejemplo n.º 1
0
 def test_initiate_success(self):
     state, payload = self._run_test(self.sm.initiate("foo", b"bar"), [
         XMLStreamMock.Send(nonza.SASLAuth(mechanism="foo", payload=b"bar"),
                            response=XMLStreamMock.Receive(
                                nonza.SASLSuccess()))
     ])
     self.assertEqual(state, "success")
     self.assertIsNone(payload)
Ejemplo n.º 2
0
    def test_response_success(self):
        self.sm._state = "challenge"

        state, payload = self._run_test(self.sm.respond(b"bar"), [
            XMLStreamMock.Send(nonza.SASLResponse(payload=b"bar"),
                               response=XMLStreamMock.Receive(
                                   nonza.SASLSuccess()))
        ])
        self.assertEqual(state, "success")
        self.assertIsNone(payload)
Ejemplo n.º 3
0
    def test_abort_reject_non_failure(self):
        self.sm._state = "challenge"

        with self.assertRaisesRegex(aiosasl.SASLFailure,
                                    "unexpected non-failure") as ctx:
            self._run_test(self.sm.abort(), [
                XMLStreamMock.Send(nonza.SASLAbort(),
                                   response=XMLStreamMock.Receive(
                                       nonza.SASLSuccess()))
            ])

        self.assertEqual("aborted", ctx.exception.opaque_error)