def test_validate_signature(self): params = {"key1": "val1", "key2": "val2"} sig = utils.generate_signature(params, self.secret) params["signature"] = sig self.assertTrue(utils.signature_valid(params, self.secret)) params["signature"] = "123482494523435" self.assertFalse(utils.signature_valid(params, self.secret))
def validate_webhook(self, params): """Check whether a webhook signature is valid Takes a dictionary of parameters, including the signature and returns a boolean indicating whether the signature is valid. :param params: A dictionary of data to validate, must include the key "signature" """ return signature_valid(params, self._app_secret)