Beispiel #1
0
def test_verify_requset():
    token = "weixin-token"
    weixinhandler = Weixin(token)
    timestamp = str(int(time.time()))
    nonce = "hello"
    echostr = "good"
    args = [token, timestamp, nonce]
    args.sort()
    signature = hashlib.sha1(''.join(args)).hexdigest()
    is_verify, new_echo = weixinhandler.verify_request(
        signature=signature, timestamp=timestamp, nonce=nonce, echostr=echostr)
    assert_equal(is_verify, True)
    assert_equal(new_echo, echostr)
    is_verify, new_echo = weixinhandler.verify_request(
        signature=signature, timestamp="1223434334", nonce=nonce, echostr=echostr)
    assert_equal(is_verify, False)
    assert_equal(new_echo, echostr)
Beispiel #2
0
def test_verify_requset():
    token = "weixin-token"
    weixinhandler = Weixin(token)
    timestamp = str(int(time.time()))
    nonce = "hello"
    echostr = "good"
    args = [token, timestamp, nonce]
    args.sort()
    signature = hashlib.sha1(''.join(args)).hexdigest()
    is_verify, new_echo = weixinhandler.verify_request(signature=signature,
                                                       timestamp=timestamp,
                                                       nonce=nonce,
                                                       echostr=echostr)
    assert_equal(is_verify, True)
    assert_equal(new_echo, echostr)
    is_verify, new_echo = weixinhandler.verify_request(signature=signature,
                                                       timestamp="1223434334",
                                                       nonce=nonce,
                                                       echostr=echostr)
    assert_equal(is_verify, False)
    assert_equal(new_echo, echostr)