def test_init(self): challenge = nonza.SASLChallenge(b"foo") self.assertEqual(challenge.payload, b"foo") challenge = nonza.SASLChallenge(payload=b"foo") self.assertEqual(challenge.payload, b"foo") with self.assertRaisesRegex(TypeError, "positional argument"): nonza.SASLChallenge()
def test_initiate_challenge(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.SASLChallenge(payload=b"baz"))) ]) self.assertEqual(state, "challenge") self.assertEqual(payload, b"baz")
def test_response_challenge(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.SASLChallenge(payload=b"baz"))) ]) self.assertEqual(state, "challenge") self.assertEqual(payload, b"baz")