def test_signature(self):
# Check signature of token by corrupting the signature
with self.assertRaises(Unauthorized) as context:
t = template.copy()
t['signature'] = t['signature'][:84] + '5' + t['signature'][85:] # Just modify one random letter.
validate_gamecenter_token(t)
self.assertIn("Can't verify signature:", context.exception.description)
self.assertIn("'padding check failed'", context.exception.description)
# Check signature of token by modifying the payload
with self.assertRaises(Unauthorized) as context:
t = template.copy()
t['player_id'] = 'G:5637867917'
validate_gamecenter_token(t)
self.assertIn("Can't verify signature:", context.exception.description)
self.assertIn("'bad signature'", context.exception.description)
# For requests library mock
评论列表
文章目录