示例#1
0
 def test_if_encoding_does_not_vary_in_time(self, time):
     data = {'a': 3}
     time.return_value = 16
     old = urls.Next().encode(data)
     time.return_value = 42
     new = urls.Next().encode(data)
     self.assertEqual(old, new)
示例#2
0
 def test_valid_next(self, authenticate):
     authenticate.return_value = None
     encoded_next = urls.Next().encode({
         'next': 'http://next.example.com',
         'close': 'http://close.example.com'})
     next_value = parse.parse_qs(encoded_next)['next'][0]
     request = mock.Mock(GET={'next': next_value, 'code': 'code'},
                         method='GET')
     with self.settings(FACEBOOK_CANVAS_URL='http://example.com'):
         response = views.handler(request)
     self.assertEqual(302, response.status_code)
     self.assertEqual('http://next.example.com', response['Location'])
示例#3
0
def handler(request):
    next_url = urls.Next().decode(request.GET['next'])
    if 'code' not in request.GET:
        return http.HttpResponseRedirect(next_url['close'])
    user = authenticate(
        code=request.GET['code'],
        redirect_uri=urls.redirect_uri(next_url['next'], next_url['close']))
    if user:
        login(request, user)
    response = http.HttpResponseRedirect(next_url['next'])
    response["P3P"] = ('CP="IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi'
                       ' CONi HIS OUR IND CNT"')
    return response
示例#4
0
 def test_if_encoding_is_dictionary_order_independent(self):
     ordered = collections.OrderedDict([('A', 'a'), ('B', 'b')])
     reverse_ordered = collections.OrderedDict([('B', 'b'), ('A', 'a')])
     self.assertEqual(urls.Next().encode(ordered),
                      urls.Next().encode(reverse_ordered))
示例#5
0
 def test_empty_next(self):
     with self.assertRaises(urls.InvalidNextUrl):
         urls.Next().decode('')
示例#6
0
 def test_invalid_next_format(self):
     with self.assertRaises(urls.InvalidNextUrl):
         urls.Next().decode('this is not valid signature')
示例#7
0
 def test_invalid_next(self):
     with self.assertRaises(urls.InvalidNextUrl):
         urls.Next().decode('1:2:3')