Skip to content

Commit

Permalink
fix(Singature): verification timestamp added to the constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
650elx committed Jan 18, 2024
1 parent 3317bf0 commit d52e838
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
11 changes: 9 additions & 2 deletions sinch/core/signature.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,19 @@


class Signature:
def __init__(self, sinch, http_method, request_data, request_uri):
def __init__(
self,
sinch,
http_method,
request_data,
request_uri,
signature_timestamp=None
):
self.sinch = sinch
self.http_method = http_method
self.content_type = 'application/json; charset=UTF-8'
self.request_data = request_data
self.signature_timestamp = datetime.now(timezone.utc).isoformat()
self.signature_timestamp = signature_timestamp or datetime.now(timezone.utc).isoformat()
self.request_uri = request_uri
self.authorization_signature = None

Expand Down
9 changes: 6 additions & 3 deletions tests/integration/test_request_signing.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ def test_request_signature(
sinch_client_sync,
http_method="GET",
request_data=json.dumps({"test": "test"}),
request_uri="/verification/v1/verifications"
request_uri="/verification/v1/verifications",
signature_timestamp=verification_request_signature_timestamp
)
signature.signature_timestamp = verification_request_signature_timestamp
signature.calculate()
Expand All @@ -30,7 +31,8 @@ def test_request_signature_using_empty_body(
sinch_client_sync,
http_method="POST",
request_data=None,
request_uri="/verification/v1/verifications"
request_uri="/verification/v1/verifications",
signature_timestamp=verification_request_signature_timestamp
)
signature.signature_timestamp = verification_request_signature_timestamp
signature.calculate()
Expand All @@ -49,7 +51,8 @@ def test_get_headers_with_signature_and_async_client(
sinch_client_async,
http_method="POST",
request_data=None,
request_uri="/verification/v1/verifications"
request_uri="/verification/v1/verifications",
signature_timestamp=verification_request_signature_timestamp
)
signature.signature_timestamp = verification_request_signature_timestamp
headers = signature.get_http_headers_with_signature()
Expand Down

0 comments on commit d52e838

Please sign in to comment.