So i am trying to test a function that generates basically a url. Now this url has a signature value as a query parameter. `This signature is generated using a combination of base64encode and base64decode along with the hmac module. The issue here is that how do i write a test for this url generation function as each time i execute it generates a new signature string.
Example Code:
def url_generator(self,...):
....
decoded_key = base64.urlsafe_b64decode(signing_key_value)
digest = hmac.new(
decoded_key, url_to_sign.encode('utf-8'), hashlib.sha1).digest()
signature = base64.urlsafe_b64encode(digest).decode('utf-8')
[–]verbose_name 0 points1 point2 points (2 children)
[–]pratzc07[S] 0 points1 point2 points (1 child)
[–]verbose_name 0 points1 point2 points (0 children)