~nataliabidart/ubuntuone-control-panel/fix-setup-for-qt

« back to all changes in this revision

Viewing changes to ubuntuone/controlpanel/gui/tests/test_url_sign.py

  • Committer: Tarmac
  • Author(s): Alejandro J. Cura
  • Date: 2011-10-07 20:41:13 UTC
  • mfrom: (230.2.10 timestamp-autofix)
  • Revision ID: tarmac-20111007204113-1j9n36yyjwvyout7
Do a HEAD request on the server to get accurate timestamp (LP: #692597)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
# -*- coding: utf-8 -*-
2
2
 
3
3
# Authors: Roberto Alsina <roberto.alsina@canonical.com>
 
4
# Authors: Alejandro J. Cura <alecu@canonical.com>
4
5
#
5
6
# Copyright 2011 Canonical Ltd.
6
7
#
21
22
from urlparse import urlparse, parse_qs
22
23
 
23
24
from ubuntuone.controlpanel.tests import TestCase
24
 
from ubuntuone.controlpanel.gui import sign_url, UBUNTUONE_FROM_OAUTH
 
25
from ubuntuone.controlpanel.gui import (
 
26
    sign_url,
 
27
    UBUNTUONE_FROM_OAUTH,
 
28
)
25
29
 
26
30
TOKEN = {u'consumer_key': u'consumer_key',
27
31
         u'consumer_secret': u'consumer_secret',
87
91
        signed_query = parse_qs(parsed_signed.query)
88
92
 
89
93
        self.assertEqual(signed_query['next'], ['/blah?foo=bar'])
 
94
 
 
95
    def test_uses_timestamper(self):
 
96
        """Test that the signed url is using the server-relative timestamp."""
 
97
        timestamp = 999
 
98
        signed = sign_url("/blah?foo=bar", TOKEN, timestamp)
 
99
        parsed_signed = urlparse(signed)
 
100
        signed_query = parse_qs(parsed_signed.query)
 
101
 
 
102
        self.assertEqual(signed_query['oauth_timestamp'], [str(timestamp)])