-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
97bb00c
commit 551c8e8
Showing
2 changed files
with
43 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 |
---|---|---|
|
@@ -4,36 +4,55 @@ | |
|
||
|
||
class TestFxaClient: | ||
def test_is_in_allow_list(self): | ||
os.environ['FXA_ALLOW_LIST'] = '' | ||
def test_is_in_allow_list(self, with_db): | ||
with with_db() as db: | ||
os.environ['FXA_ALLOW_LIST'] = '' | ||
|
||
fxa_client = FxaClient(None, None, None) | ||
fxa_client = FxaClient(None, None, None) | ||
|
||
test_email = 'test@example.org' | ||
test_email = 'cooltestguy@example.org' | ||
|
||
assert fxa_client.is_in_allow_list(test_email) | ||
assert fxa_client.is_in_allow_list(db, test_email) | ||
|
||
# Domain is in allow list | ||
os.environ['FXA_ALLOW_LIST'] = '@example.org' | ||
assert fxa_client.is_in_allow_list(test_email) | ||
# Domain is in allow list | ||
os.environ['FXA_ALLOW_LIST'] = '@example.org' | ||
assert fxa_client.is_in_allow_list(db, test_email) | ||
|
||
# Email is in allow list | ||
os.environ['FXA_ALLOW_LIST'] = test_email | ||
assert fxa_client.is_in_allow_list(test_email) | ||
# Email is in allow list | ||
os.environ['FXA_ALLOW_LIST'] = test_email | ||
assert fxa_client.is_in_allow_list(db, test_email) | ||
|
||
# Domain is not in allow list | ||
os.environ['FXA_ALLOW_LIST'] = '@example.com' | ||
assert not fxa_client.is_in_allow_list(test_email) | ||
# Domain is not in allow list | ||
os.environ['FXA_ALLOW_LIST'] = '@example.com' | ||
assert not fxa_client.is_in_allow_list(db, test_email) | ||
|
||
# Domain is in allow list | ||
os.environ['FXA_ALLOW_LIST'] = '@example.com,@example.org' | ||
assert fxa_client.is_in_allow_list(test_email) | ||
# Domain is in allow list | ||
os.environ['FXA_ALLOW_LIST'] = '@example.com,@example.org' | ||
assert fxa_client.is_in_allow_list(db, test_email) | ||
|
||
# Email is not allow list | ||
os.environ['FXA_ALLOW_LIST'] = '@example.com,[email protected]' | ||
assert not fxa_client.is_in_allow_list(db, test_email) | ||
|
||
# Email is not allow list | ||
os.environ['FXA_ALLOW_LIST'] = '@example.com,[email protected]' | ||
assert not fxa_client.is_in_allow_list(db, '[email protected]@bad.org') | ||
|
||
def test_allow_list_allows_subscriber(self, with_db, make_basic_subscriber): | ||
with with_db() as db: | ||
os.environ['FXA_ALLOW_LIST'] = '@abadexample.org' | ||
|
||
fxa_client = FxaClient(None, None, None) | ||
|
||
test_email = '[email protected]' | ||
|
||
# They're not a user, and they're not in the allow list | ||
assert not fxa_client.is_in_allow_list(db, test_email) | ||
|
||
make_basic_subscriber(email=test_email) | ||
|
||
# They're not in the allow list, but they are a user! | ||
assert fxa_client.is_in_allow_list(db, test_email) | ||
|
||
# Email is not allow list | ||
os.environ['FXA_ALLOW_LIST'] = '@example.com,[email protected]' | ||
assert not fxa_client.is_in_allow_list(test_email) | ||
|
||
# Email is not allow list | ||
os.environ['FXA_ALLOW_LIST'] = '@example.com,[email protected]' | ||
assert not fxa_client.is_in_allow_list('[email protected]@bad.org') | ||
|