def test_auth_resp_invalid(self): con = self._with_pck((MSG_AUTH_RESP, dict(status=False))) p = Protocol(con, "foo") p._loop() ok_(not p.authenticated)
def test_accept_auth_resp(self): con = self._with_pck((MSG_AUTH_RESP, dict(status=True))) p = Protocol(con, "foo") p._loop() ok_(p.authenticated)
def test_responds_to_challenge(self, p): con = self._with_pck((MSG_CHALLENGE, dict(challenge="0" * 64))) p = Protocol(con, "foo") p._loop() con.send_packet.assert_called_once_with( MSG_AUTH, dict(signature=sentinel.signed))
def test_responds_to_challenge(self, p): con = self._with_pck((MSG_CHALLENGE, dict(challenge="0" * 64))) p = Protocol(con, "foo") p._loop() con.send_packet.assert_called_once_with( MSG_AUTH, dict(signature=sentinel.signed) )
def test_request_async(self): con = self._with_pck((MSG_RESPONSE, self._response_data)) p = Protocol(con, "foo") p._authed = True args = dict(somearg=sentinel.somearg) handle = p.request(sentinel.mtd, **args) p._loop() # calling handle should wait the response ret = handle() eq_(ret, "foo") con.send_packet.assert_called_once_with(MSG_REQUEST, { "reqid": 1, "action": sentinel.mtd, "args": args })