-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(SMS): test credentials formatting for different APIs
- Loading branch information
Showing
3 changed files
with
73 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
from sinch.core.adapters.requests_http_transport import HTTPTransportRequests | ||
from sinch.domains.sms.endpoints.sms_endpoint import SMSEndpoint | ||
from sinch.core.enums import HTTPAuthentication | ||
|
||
|
||
def test_authenticate_method_with_service_plan_id_version_of_sms_api( | ||
sinch_client_sync_with_service_plan_id, | ||
empty_http_request | ||
): | ||
sms_endpoint = SMSEndpoint( | ||
sinch=sinch_client_sync_with_service_plan_id, | ||
request_data=empty_http_request | ||
) | ||
http_transport = HTTPTransportRequests(sinch=sinch_client_sync_with_service_plan_id) | ||
http_transport.authenticate(endpoint=sms_endpoint, request_data=empty_http_request) | ||
|
||
assert empty_http_request.headers | ||
assert "Bearer" in empty_http_request.headers["Authorization"] | ||
assert empty_http_request.headers["Content-Type"] == "application/json" | ||
|
||
|
||
def test_authenticate_method_with_project_id_version_of_sms_api( | ||
sinch_client_sync, | ||
empty_http_request | ||
): | ||
sms_endpoint = SMSEndpoint( | ||
sinch=sinch_client_sync, | ||
request_data=empty_http_request, | ||
) | ||
sms_endpoint.HTTP_AUTHENTICATION = HTTPAuthentication.OAUTH.value | ||
http_transport = HTTPTransportRequests(sinch=sinch_client_sync) | ||
http_transport.authenticate(endpoint=sms_endpoint, request_data=empty_http_request) | ||
|
||
assert empty_http_request.headers | ||
assert "Bearer" in empty_http_request.headers["Authorization"] | ||
assert empty_http_request.headers["Content-Type"] == "application/json" |
23 changes: 23 additions & 0 deletions
23
tests/integration/test_sms_endpoint_credendials_formatting.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
from sinch.domains.sms.endpoints.sms_endpoint import SMSEndpoint | ||
from sinch.core.enums import HTTPAuthentication | ||
|
||
|
||
def test_sms_endpoint_service_plan_id_credentials_processing(sinch_client_sync_with_service_plan_id, service_plan_id): | ||
sms_endpoint = SMSEndpoint( | ||
sinch=sinch_client_sync_with_service_plan_id, | ||
request_data={} | ||
) | ||
assert sms_endpoint.project_or_service_id == service_plan_id | ||
assert sms_endpoint.HTTP_AUTHENTICATION == HTTPAuthentication.SMS_TOKEN.value | ||
assert ( | ||
sms_endpoint.sms_origin == sinch_client_sync_with_service_plan_id.configuration._sms_origin_with_service_plan_id | ||
) | ||
|
||
|
||
def test_sms_endpoint_with_project_id_credentials_processing(sinch_client_sync, project_id): | ||
sms_endpoint = SMSEndpoint( | ||
sinch=sinch_client_sync, | ||
request_data={} | ||
) | ||
assert sms_endpoint.project_or_service_id == project_id | ||
assert sms_endpoint.sms_origin == sinch_client_sync.configuration.sms_origin |