mirror of
https://github.com/simple-login/app.git
synced 2024-11-13 07:31:12 +01:00
Do not show the default domain twice (#1772)
Co-authored-by: Adrià Casajús <adria.casajus@proton.ch>
This commit is contained in:
parent
37ffe4d5fe
commit
03c67ead44
2 changed files with 19 additions and 2 deletions
|
@ -162,8 +162,6 @@ def get_alias_suffixes(
|
|||
or user.default_alias_public_domain_id != sl_domain.id
|
||||
):
|
||||
alias_suffixes.append(alias_suffix)
|
||||
# If no default domain mark it as found
|
||||
default_domain_found = user.default_alias_public_domain_id is None
|
||||
else:
|
||||
default_domain_found = True
|
||||
alias_suffixes.insert(0, alias_suffix)
|
||||
|
|
|
@ -131,3 +131,22 @@ def test_suffixes_are_valid():
|
|||
if len(match.groups()) >= 1:
|
||||
has_prefix += 1
|
||||
assert has_prefix > 0
|
||||
|
||||
|
||||
def test_get_default_domain_is_only_shown_once():
|
||||
user = create_new_user()
|
||||
default_domain = SLDomain.filter_by(hidden=False).order_by(SLDomain.order).first()
|
||||
user.default_alias_public_domain_id = default_domain.id
|
||||
Session.flush()
|
||||
options = AliasOptions(
|
||||
show_sl_domains=True, show_partner_domains=get_proton_partner()
|
||||
)
|
||||
suffixes = get_alias_suffixes(user, alias_options=options)
|
||||
found_default = False
|
||||
found_domains = set()
|
||||
for suffix in suffixes:
|
||||
assert suffix.domain not in found_domains
|
||||
found_domains.add(suffix.domain)
|
||||
if default_domain.domain == suffix.domain:
|
||||
found_default = True
|
||||
assert found_default
|
||||
|
|
Loading…
Reference in a new issue