Esempio n. 1
0
    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)
Esempio n. 2
0
    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)
Esempio n. 3
0
    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)
Esempio n. 4
0
    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))
Esempio n. 5
0
    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)
Esempio n. 6
0
    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)
        )
Esempio n. 7
0
    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
        })
Esempio n. 8
0
    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
            })