test_pn_registration.py 文件源码

python
阅读 24 收藏 0 点赞 0 评论 0

项目:toshi-ethereum-service 作者: toshiapp 项目源码 文件源码
def test_invalid_signature_in_deregistration(self):

        async with self.pool.acquire() as con:

            await con.fetchrow("INSERT INTO notification_registrations VALUES ($2, 'apn', $1, $2)",
                               TEST_APN_ID, TEST_ADDRESS)

        body = {
            "registration_id": TEST_APN_ID
        }
        timestamp = int(time.time())
        signature = sign_request(FAUCET_PRIVATE_KEY, "POST", "/v1/apn/deregister", timestamp, json_encode(body).encode('utf-8'))

        resp = await self.fetch_signed("/apn/deregister", method="POST", body=body, timestamp=timestamp, signature=signature, address=TEST_ADDRESS)

        self.assertEqual(resp.code, 400, resp.body)

        async with self.pool.acquire() as con:

            rows = await con.fetch("SELECT * FROM notification_registrations WHERE toshi_id = $1", TEST_ADDRESS)

        self.assertEqual(len(rows), 1)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号