Merge lp:~james-w/canonical-identity-provider/doubled-email-acceptance into lp:canonical-identity-provider/release

Proposed by James Westby
Status: Merged
Approved by: Natalia Bidart
Approved revision: no longer in the source branch.
Merged at revision: 1034
Proposed branch: lp:~james-w/canonical-identity-provider/doubled-email-acceptance
Merge into: lp:canonical-identity-provider/release
Diff against target: 73 lines (+16/-30)
2 files modified
acceptance/pages.py (+8/-0)
acceptance/tests/emails/doubled_email.py (+8/-30)
To merge this branch: bzr merge lp:~james-w/canonical-identity-provider/doubled-email-acceptance
Reviewer Review Type Date Requested Status
Natalia Bidart (community) Approve
Review via email: mp+182508@code.launchpad.net

Commit message

When a second user tries to add an email that is already in use they get an error.

The behaviour changed in r1031 such that you can't claim an email that has been
added by someone else, even if they haven't yet verified it. This updates
the acceptance test to check this, rather than checking the rules around token
invalidation with duplicated emails.

Description of the change

Hi,

This updates the failing acceptence test to match the new behaviour
of duplicated emails.

Thanks,

James

To post a comment you must log in.
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 'acceptance/pages.py'
2--- acceptance/pages.py 2013-07-12 15:57:28 +0000
3+++ acceptance/pages.py 2013-08-27 21:48:48 +0000
4@@ -203,6 +203,14 @@
5 sst.actions.click_link(remove_link)
6 return DeleteEmail()
7
8+ def get_form_errors(self):
9+ try:
10+ email_error = sst.actions.get_element(
11+ css_class='error').text
12+ except AssertionError:
13+ email_error = None
14+ return email_error
15+
16
17 class EnterConfirmationCode(LoggedUserPage):
18
19
20=== modified file 'acceptance/tests/emails/doubled_email.py'
21--- acceptance/tests/emails/doubled_email.py 2013-05-02 17:20:14 +0000
22+++ acceptance/tests/emails/doubled_email.py 2013-08-27 21:48:48 +0000
23@@ -1,12 +1,10 @@
24 from sst.actions import (
25- assert_title,
26- fails,
27- wait_for,
28+ assert_equal,
29 )
30 from u1testutils import mail
31 from u1testutils.sst import config
32
33-from acceptance import helpers
34+from acceptance import helpers, pages
35
36 config.set_base_url_from_env()
37 PASSWORD = 'Admin007'
38@@ -23,29 +21,9 @@
39 helpers.logout()
40
41 helpers.register_account(email_b_id, password=PASSWORD)
42-vcode_y = helpers.add_email(email_c_id)
43-
44-
45-# try x from a, should fail
46-helpers.logout()
47-helpers.login(email_a_id, PASSWORD)
48-# Trying and failing to use token X completely invalidates token X, even for
49-# account B (which now owns the token) later in this test.
50-# helpers.try_to_validate_email(email_c_id, vcode_x)
51-# fails(assert_title, 'Complete email address validation')
52-
53-# try y from a, should fail
54-helpers.try_to_validate_email(email_c_id, vcode_y, finish_validation=False)
55-fails(assert_title, 'Complete email address validation')
56-
57-# both x & y should work for b, but using one should kill the other.
58-# try x from b, should work
59-helpers.logout()
60-helpers.login(email_b_id, PASSWORD)
61-helpers.try_to_validate_email(email_c_id, vcode_x, finish_validation=False)
62-wait_for(assert_title, 'Complete email address validation')
63-
64-# now, y from b should fail, because address C was already verified (but would
65-# normally work)
66-helpers.try_to_validate_email(email_c_id, vcode_y, finish_validation=False)
67-fails(assert_title, 'Complete email address validation')
68+# Once one account adds an email, no-one else can add it, even if
69+# it is not yet verified.
70+your_email_addresses = pages.YourEmailAddresses(open_page=True)
71+your_email_addresses.add_email(email_c_id)
72+assert_equal('Email already registered.',
73+ your_email_addresses.get_form_errors())