Merge lp:~canonical-isd-hackers/canonical-identity-provider/fix-tests into lp:canonical-identity-provider/release

Proposed by Simon Davy
Status: Merged
Approved by: Simon Davy
Approved revision: no longer in the source branch.
Merged at revision: 513
Proposed branch: lp:~canonical-isd-hackers/canonical-identity-provider/fix-tests
Merge into: lp:canonical-identity-provider/release
Prerequisite: lp:~canonical-isd-hackers/canonical-identity-provider/paper-button
Diff against target: 54 lines (+18/-8)
2 files modified
identityprovider/tests/acceptance/devices/add_device.py (+7/-2)
identityprovider/tests/acceptance/shared/devices.py (+11/-6)
To merge this branch: bzr merge lp:~canonical-isd-hackers/canonical-identity-provider/fix-tests
Reviewer Review Type Date Requested Status
Natalia Bidart (community) Approve
Review via email: mp+131027@code.launchpad.net

Commit message

Fix issues in acceptances for new PAPER_DEVICE flag and also quantal's urlparse backport

Description of the change

Fix two small issue's I encountered in the accetpance tests

To post a comment you must log in.
Revision history for this message
Natalia Bidart (nataliabidart) wrote :

The acceptance suite is failing with:

======================================================================
ERROR: test_add_device_google (sst.runtests.TestAdd_Device_Google)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/nessita/canonical/cip/reviews/.env/local/lib/python2.7/site-packages/sst/runtests.py", line 284, in test
    exec self.code in context
  File "/home/nessita/canonical/cip/reviews/identityprovider/tests/acceptance/devices/add_device_google.py", line 37, in <module>
    aes_key = get_key_from_qrcode(email)
  File "/home/nessita/canonical/cip/reviews/identityprovider/tests/acceptance/shared/devices.py", line 176, in get_key_from_qrcode
    b32_key = parse_qs(otpauth.query)['secret'][0]
KeyError: 'secret'

----------------------------------------------------------------------
Ran 1 test in 10.644s

FAILED (errors=1)
----------------------------------------------------------------------

I think that failure is related to the changes done in this branch, so I think it needs some fixing. Please let me know if I need to tweak something else in my env.

review: Needs Fixing
Revision history for this message
Natalia Bidart (nataliabidart) wrote :

Looks good!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'identityprovider/tests/acceptance/devices/add_device.py'
2--- identityprovider/tests/acceptance/devices/add_device.py 2012-10-12 18:00:59 +0000
3+++ identityprovider/tests/acceptance/devices/add_device.py 2012-10-24 14:35:33 +0000
4@@ -1,6 +1,9 @@
5 # Test basic device-list page
6+import sst
7+
8 from canonical.isd.tests.sst import config
9 from oath import hotp
10+
11 from sst.actions import (
12 assert_element,
13 assert_radio_value,
14@@ -55,8 +58,10 @@
15 assert_radio_value('type_yubi', False)
16 assert_radio_value('type_generic', False)
17
18-# TODO: change once the pad is added
19-fails(assert_radio_value, 'type_paper', False)
20+if 'paper_device' in sst.config.flags:
21+ assert_radio_value('type_paper', False)
22+else:
23+ fails(assert_radio_value, 'type_paper', False)
24
25 # Choose "Generic HOTP device" and click add device
26 set_radio_value('type_generic')
27
28=== modified file 'identityprovider/tests/acceptance/shared/devices.py'
29--- identityprovider/tests/acceptance/shared/devices.py 2012-10-12 18:00:59 +0000
30+++ identityprovider/tests/acceptance/shared/devices.py 2012-10-24 14:35:33 +0000
31@@ -167,12 +167,17 @@
32 url = urlparse(src)
33 assert url.scheme == 'https', "incorrect google charts protocol"
34 assert url.netloc == 'chart.googleapis.com', "incorrect google charts domain"
35- otpauth = urlparse(parse_qs(url.query)['chl'][0])
36+ qs = parse_qs(url.query)['chl'][0]
37+ otpauth = urlparse(qs)
38 assert email in otpauth.path
39-
40- # should have form otpauth://hotp/<email>?secrec=<key>&counter=0
41- # but urlparse doesn't correctly parse query strings on non-http schemes :(
42- # so we have to do it manually
43- b32_key = parse_qs(otpauth.path.split('?')[1])['secret'][0]
44+ # python2.7.3 on quantal has a backport from 2.7 trunk (presumably will be
45+ # 2.7.4) and now urlparse correctly handles query string on *all* url types
46+ if otpauth.query:
47+ # urlparse has handled query string
48+ query = otpauth.query
49+ else:
50+ # we need to handle query string parsing
51+ query = otpauth.path.split('?')[1]
52+ b32_key = parse_qs(query)['secret'][0]
53 aes_key = b32decode(b32_key).encode('hex')
54 return aes_key