forked from twilio/twilio-python
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest_validation.py
More file actions
49 lines (41 loc) · 1.54 KB
/
test_validation.py
File metadata and controls
49 lines (41 loc) · 1.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# -*- coding: utf-8 -*-
import unittest
from nose.tools import assert_equal, assert_true
from six import b
from twilio.util import RequestValidator
class ValidationTest(unittest.TestCase):
def test_validation(self):
token = "1c892n40nd03kdnc0112slzkl3091j20"
validator = RequestValidator(token)
uri = "http://www.postbin.org/1ed898x"
params = {
"AccountSid": "AC9a9f9392lad99kla0sklakjs90j092j3",
"ApiVersion": "2010-04-01",
"CallSid": "CAd800bb12c0426a7ea4230e492fef2a4f",
"CallStatus": "ringing",
"Called": "+15306384866",
"CalledCity": "OAKLAND",
"CalledCountry": "US",
"CalledState": "CA",
"CalledZip": "94612",
"Caller": "+15306666666",
"CallerCity": "SOUTH LAKE TAHOE",
"CallerCountry": "US",
"CallerName": "CA Wireless Call",
"CallerState": "CA",
"CallerZip": "89449",
"Direction": "inbound",
"From": "+15306666666",
"FromCity": "SOUTH LAKE TAHOE",
"FromCountry": "US",
"FromState": "CA",
"FromZip": "89449",
"To": "+15306384866",
"ToCity": "OAKLAND",
"ToCountry": "US",
"ToState": "CA",
"ToZip": "94612",
}
expected = b("fF+xx6dTinOaCdZ0aIeNkHr/ZAA=")
assert_equal(validator.compute_signature(uri, params), expected)
assert_true(validator.validate(uri, params, expected))