-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
handles a JSON body that isn't a SWML callback
- Loading branch information
1 parent
1a0883c
commit ca6fd45
Showing
2 changed files
with
35 additions
and
1 deletion.
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 |
---|---|---|
|
@@ -106,6 +106,32 @@ def test_should_validate_from_signalwire_https_request(self): | |
valid = validator.validate(url, body, signature) | ||
self.assertTrue(valid) | ||
|
||
def test_should_validate_from_raw_json(self): | ||
from signalwire.request_validator import RequestValidator | ||
|
||
url = 'https://675d-189-71-169-171.ngrok-free.app/voice' | ||
token = 'PSK_V3bF8oyeRNpJWGoRWHNYQMUU' | ||
signature = 'muUMpldcBHlzuXGZ5gbw1ETZCYA=' | ||
body = '''{ | ||
"CallSid": "a97d4e8a-6047-4e2b-be48-fb96b33b5642", | ||
"AccountSid": "6bfbbe86-a901-4197-8759-2a0de1fa319d", | ||
"ApiVersion": "2010-04-01", | ||
"Direction": "outbound-api", | ||
"From": "sip:[email protected]", | ||
"To": "sip:[email protected]", | ||
"Timestamp": "Thu, 09 Nov 2023 14:40:55 +0000", | ||
"CallStatus": "no-answer", | ||
"CallbackSource": "call-progress-events", | ||
"HangupDirection": "outbound", | ||
"HangupBy": "sip:[email protected]", | ||
"SipResultCode": "487" | ||
}''' | ||
|
||
|
||
validator = RequestValidator(token) | ||
valid = validator.validate(url, body, signature) | ||
self.assertTrue(valid) | ||
|
||
|
||
|
||
|