This repository has been archived by the owner on Feb 8, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 308
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update PayPal during finish_email_verification
- Loading branch information
1 parent
56c616c
commit 77d2aa2
Showing
3 changed files
with
38 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,7 +30,7 @@ def add(self, participant, address, _flush=False): | |
participant.start_email_verification(address) | ||
nonce = participant.get_email(address).nonce | ||
result = participant.finish_email_verification(address, nonce) | ||
assert result == (_email.VERIFICATION_SUCCEEDED, []) | ||
assert result == (_email.VERIFICATION_SUCCEEDED, [], False) | ||
if _flush: | ||
self.app.email_queue.flush() | ||
|
||
|
@@ -145,7 +145,7 @@ def test_verify_email_wrong_nonce(self): | |
self.hit_email_spt('add-email', '[email protected]') | ||
nonce = 'fake-nonce' | ||
result = self.alice.finish_email_verification('[email protected]', nonce) | ||
assert result == (_email.VERIFICATION_FAILED, None) | ||
assert result == (_email.VERIFICATION_FAILED, None, None) | ||
self.hit_verify_spt('[email protected]', nonce) | ||
expected = None | ||
actual = P('alice').email_address | ||
|
@@ -157,7 +157,7 @@ def test_verify_email_a_second_time_returns_redundant(self): | |
nonce = self.alice.get_email(address).nonce | ||
self.alice.finish_email_verification(address, nonce) | ||
result = self.alice.finish_email_verification(address, nonce) | ||
assert result == (_email.VERIFICATION_REDUNDANT, None) | ||
assert result == (_email.VERIFICATION_REDUNDANT, None, None) | ||
|
||
def test_verify_email_expired_nonce_fails(self): | ||
address = '[email protected]' | ||
|
@@ -169,7 +169,7 @@ def test_verify_email_expired_nonce_fails(self): | |
""", (self.alice.id,)) | ||
nonce = self.alice.get_email(address).nonce | ||
result = self.alice.finish_email_verification(address, nonce) | ||
assert result == (_email.VERIFICATION_FAILED, None) | ||
assert result == (_email.VERIFICATION_FAILED, None, None) | ||
actual = P('alice').email_address | ||
assert actual == None | ||
|
||
|
@@ -182,12 +182,12 @@ def test_finish_email_verification(self): | |
def test_empty_email_fails(self): | ||
for empty in ('', ' '): | ||
result = self.alice.finish_email_verification(empty, 'foobar') | ||
assert result == (_email.VERIFICATION_FAILED, None) | ||
assert result == (_email.VERIFICATION_FAILED, None, None) | ||
|
||
def test_empty_nonce_fails(self): | ||
for empty in ('', ' '): | ||
result = self.alice.finish_email_verification('foobar', empty) | ||
assert result == (_email.VERIFICATION_FAILED, None) | ||
assert result == (_email.VERIFICATION_FAILED, None, None) | ||
|
||
def test_email_verification_is_backwards_compatible(self): | ||
"""Test email verification still works with unencoded email in verification link. | ||
|
@@ -550,13 +550,13 @@ def test_finishing_verification_clears_competing_claims_and_emails(self): | |
assert emails() == [self.alice.id, bob.id] | ||
|
||
result = self.alice.finish_email_verification('[email protected]', anonce) | ||
assert result == (_email.VERIFICATION_SUCCEEDED, [foo]) | ||
assert result == (_email.VERIFICATION_SUCCEEDED, [foo], True) | ||
|
||
assert claims() == {} | ||
assert emails() == [self.alice.id] | ||
|
||
result = bob.finish_email_verification('[email protected]', bnonce) | ||
assert result == (_email.VERIFICATION_FAILED, None) | ||
assert result == (_email.VERIFICATION_FAILED, None, None) | ||
|
||
|
||
class RemoveEmail(Alice): | ||
|
@@ -740,7 +740,7 @@ def check(self, *package_names): | |
|
||
# email? | ||
packages = [Package.from_names(NPM, name) for name in package_names] | ||
assert result == (_email.VERIFICATION_SUCCEEDED, packages) | ||
assert result == (_email.VERIFICATION_SUCCEEDED, packages, bool(packages)) | ||
assert self.alice.email_address == P('alice').email_address == self.address | ||
|
||
# database? | ||
|
@@ -802,11 +802,11 @@ def test_bob_cannot_steal_a_package_claim_from_alice(self): | |
bob = self.make_participant('bob', claimed_time='now') | ||
bob.start_email_verification(self.address, foo) | ||
result = bob.finish_email_verification(self.address, nonce) # using alice's nonce, even! | ||
assert result == (_email.VERIFICATION_FAILED, None) | ||
assert result == (_email.VERIFICATION_FAILED, None, None) | ||
assert len(bob.get_teams()) == 0 | ||
|
||
result = self.alice.finish_email_verification(self.address, nonce) | ||
assert result == (_email.VERIFICATION_SUCCEEDED, [foo]) | ||
assert result == (_email.VERIFICATION_SUCCEEDED, [foo], True) | ||
teams = self.alice.get_teams() | ||
assert len(teams) == 1 | ||
assert teams[0].package == foo | ||
|
@@ -823,6 +823,15 @@ def test_while_we_are_at_it_that_packages_have_unique_teams_that_survive_compari | |
assert foo.team != bar.team | ||
|
||
|
||
def test_finishing_email_verification_with_preexisting_paypal_doesnt_update_paypal(self): | ||
self.add_and_verify_email(self.alice, self.address) | ||
self.alice.set_paypal_address(self.address) | ||
nonce = self.start(self.address, 'foo') | ||
result = self.alice.finish_email_verification(self.address, nonce) | ||
foo = Package.from_names('npm', 'foo') | ||
assert result == (_email.VERIFICATION_SUCCEEDED, [foo], False) | ||
|
||
|
||
def test_finishing_email_verification_is_thread_safe(self): | ||
foo = self.make_package() | ||
self.alice.start_email_verification(self.address, foo) | ||
|
@@ -857,5 +866,5 @@ def monkey(self, *a, **kw): | |
finally: | ||
Package.get_or_create_linked_team = old_get_or_create_linked_team | ||
|
||
assert results[a.ident] == (_email.VERIFICATION_SUCCEEDED, [foo]) | ||
assert results[b.ident] == (_email.VERIFICATION_REDUNDANT, None) | ||
assert results[a.ident] == (_email.VERIFICATION_SUCCEEDED, [foo], True) | ||
assert results[b.ident] == (_email.VERIFICATION_REDUNDANT, None, None) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters