Beispiel #1
0
    def test_abort_return_on_aborted_error(self):
        self.sm._state = "challenge"

        state, payload = self._run_test(self.sm.abort(), [
            XMLStreamMock.Send(
                nonza.SASLAbort(),
                response=XMLStreamMock.Receive(
                    nonza.SASLFailure(condition=(namespaces.sasl, "aborted"))))
        ])

        self.assertEqual(state, "failure")
        self.assertIsNone(payload)
Beispiel #2
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)
Beispiel #3
0
    def test_abort_re_raise_other_errors(self):
        self.sm._state = "challenge"

        with self.assertRaises(aiosasl.SASLFailure) as ctx:
            self._run_test(self.sm.abort(), [
                XMLStreamMock.Send(
                    nonza.SASLAbort(),
                    response=XMLStreamMock.Receive(
                        nonza.SASLFailure(condition=(namespaces.sasl,
                                                     "mechanism-too-weak"))))
            ])

        self.assertEqual("mechanism-too-weak", ctx.exception.opaque_error)