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.
Protect against identity merging during take_over
- Loading branch information
1 parent
c64b3ba
commit df1f985
Showing
2 changed files
with
38 additions
and
1 deletion.
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 |
---|---|---|
|
@@ -22,7 +22,8 @@ | |
from gratipay.models.account_elsewhere import AccountElsewhere | ||
from gratipay.models.exchange_route import ExchangeRoute | ||
from gratipay.models.participant import ( | ||
LastElsewhere, NeedConfirmation, NonexistingElsewhere, Participant, TeamCantBeOnlyAuth | ||
LastElsewhere, NeedConfirmation, NonexistingElsewhere, Participant, TeamCantBeOnlyAuth, | ||
WontTakeOverWithIdentities | ||
) | ||
from gratipay.models.team import Team | ||
from gratipay.testing import Harness | ||
|
@@ -192,6 +193,31 @@ def test_take_over_fails_if_it_would_result_in_just_a_team_account(self): | |
, have_confirmation=True | ||
) | ||
|
||
def test_take_over_is_fine_with_identity_info_on_primary(self): | ||
TT = self.db.one("SELECT id FROM countries WHERE code='TT'") | ||
alice = self.make_participant('alice') | ||
alice.add_email('[email protected]') | ||
alice.verify_email('[email protected]', alice.get_email('[email protected]').nonce) | ||
alice.store_identity_info(TT, 'nothing-enforced', {}) | ||
|
||
bob_github = self.make_elsewhere('github', 2, 'bob') | ||
bob_github.opt_in('bob') | ||
|
||
alice.take_over(bob_github, have_confirmation=True) | ||
self.db.self_check() | ||
|
||
def test_take_over_fails_if_secondary_has_identity_info(self): | ||
TT = self.db.one("SELECT id FROM countries WHERE code='TT'") | ||
alice = self.make_participant('alice') | ||
|
||
bob_github = self.make_elsewhere('github', 2, 'bob') | ||
bob = bob_github.opt_in('bob')[0].participant | ||
bob.add_email('[email protected]') | ||
bob.verify_email('[email protected]', bob.get_email('[email protected]').nonce) | ||
bob.store_identity_info(TT, 'nothing-enforced', {}) | ||
|
||
pytest.raises(WontTakeOverWithIdentities, alice.take_over, bob_github) | ||
|
||
def test_idempotent(self): | ||
alice_twitter = self.make_elsewhere('twitter', 1, 'alice') | ||
bob_github = self.make_elsewhere('github', 2, 'bob') | ||
|