🧑💻(demo) add aliases to demo
add aliases to all domains in demo
This commit is contained in:
committed by
Marie
parent
aaa9b27c61
commit
1d4d40aad0
@@ -10,6 +10,7 @@ and this project adheres to
|
|||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|
||||||
|
- ✨(demo) add aliases to demo #1050
|
||||||
- ✨(front) add icon to button to configure a domain
|
- ✨(front) add icon to button to configure a domain
|
||||||
- ✨(invitations) allow delete invitations mails domains access by an admin
|
- ✨(invitations) allow delete invitations mails domains access by an admin
|
||||||
- ✨(front) delete invitations mails domains access
|
- ✨(front) delete invitations mails domains access
|
||||||
|
|||||||
@@ -5,4 +5,6 @@ NB_OBJECTS = {
|
|||||||
"teams": 100,
|
"teams": 100,
|
||||||
"max_users_per_team": 100,
|
"max_users_per_team": 100,
|
||||||
"domains": 10,
|
"domains": 10,
|
||||||
|
"mailboxes_per_domain": 2,
|
||||||
|
"aliases_per_domain": 2,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -288,14 +288,12 @@ def create_demo(stdout): # pylint: disable=too-many-branches too-many-statement
|
|||||||
)
|
)
|
||||||
queue.flush()
|
queue.flush()
|
||||||
|
|
||||||
|
domains = mailbox_models.MailDomain.objects.all()
|
||||||
with Timeit(stdout, "Creating accesses to domains"):
|
with Timeit(stdout, "Creating accesses to domains"):
|
||||||
domains_ids = list(
|
for domain in domains:
|
||||||
mailbox_models.MailDomain.objects.values_list("id", flat=True)
|
|
||||||
)
|
|
||||||
for domain_id in domains_ids:
|
|
||||||
queue.push(
|
queue.push(
|
||||||
mailbox_models.MailDomainAccess(
|
mailbox_models.MailDomainAccess(
|
||||||
domain_id=domain_id,
|
domain=domain,
|
||||||
user_id=random.choice(users_ids),
|
user_id=random.choice(users_ids),
|
||||||
role=models.RoleChoices.OWNER,
|
role=models.RoleChoices.OWNER,
|
||||||
)
|
)
|
||||||
@@ -304,11 +302,8 @@ def create_demo(stdout): # pylint: disable=too-many-branches too-many-statement
|
|||||||
queue.flush()
|
queue.flush()
|
||||||
|
|
||||||
with Timeit(stdout, "Creating mailboxes"):
|
with Timeit(stdout, "Creating mailboxes"):
|
||||||
domains_ids = list(
|
for domain in domains:
|
||||||
mailbox_models.MailDomain.objects.values_list("id", flat=True)
|
for i in range(defaults.NB_OBJECTS["mailboxes_per_domain"]):
|
||||||
)
|
|
||||||
for domain_id in domains_ids:
|
|
||||||
for i in range(random.randint(1, 10)):
|
|
||||||
first_name = fake.first_name()
|
first_name = fake.first_name()
|
||||||
last_name = fake.last_name()
|
last_name = fake.last_name()
|
||||||
local_part = f"{first_name.lower()}.{last_name.lower()}{i}"
|
local_part = f"{first_name.lower()}.{last_name.lower()}{i}"
|
||||||
@@ -318,7 +313,7 @@ def create_demo(stdout): # pylint: disable=too-many-branches too-many-statement
|
|||||||
first_name=first_name,
|
first_name=first_name,
|
||||||
last_name=last_name,
|
last_name=last_name,
|
||||||
local_part=local_part,
|
local_part=local_part,
|
||||||
domain_id=domain_id,
|
domain=domain,
|
||||||
secondary_email=f"{local_part}@example.fr",
|
secondary_email=f"{local_part}@example.fr",
|
||||||
status=random.choice(MailboxStatusChoices.values),
|
status=random.choice(MailboxStatusChoices.values),
|
||||||
dn_email=local_part,
|
dn_email=local_part,
|
||||||
@@ -327,6 +322,19 @@ def create_demo(stdout): # pylint: disable=too-many-branches too-many-statement
|
|||||||
|
|
||||||
queue.flush()
|
queue.flush()
|
||||||
|
|
||||||
|
with Timeit(stdout, "Creating aliases"):
|
||||||
|
for domain in domains:
|
||||||
|
for _i in range(defaults.NB_OBJECTS["aliases_per_domain"]):
|
||||||
|
queue.push(
|
||||||
|
mailbox_models.Alias(
|
||||||
|
local_part=fake.word(),
|
||||||
|
destination=fake.email(),
|
||||||
|
domain=domain,
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
queue.flush()
|
||||||
|
|
||||||
with Timeit(stdout, "Creating specific users"):
|
with Timeit(stdout, "Creating specific users"):
|
||||||
# ⚠️ Warning: this users also need to be created in the keycloak
|
# ⚠️ Warning: this users also need to be created in the keycloak
|
||||||
# realm.json AND the OIDC setting to fallback on user email
|
# realm.json AND the OIDC setting to fallback on user email
|
||||||
@@ -361,7 +369,7 @@ def create_demo(stdout): # pylint: disable=too-many-branches too-many-statement
|
|||||||
queue.push(user_with_mail)
|
queue.push(user_with_mail)
|
||||||
queue.push(
|
queue.push(
|
||||||
mailbox_models.MailDomainAccess(
|
mailbox_models.MailDomainAccess(
|
||||||
domain_id=domains_ids[0],
|
domain=domains[0],
|
||||||
user_id=user_with_mail.pk,
|
user_id=user_with_mail.pk,
|
||||||
role=role,
|
role=role,
|
||||||
)
|
)
|
||||||
@@ -387,7 +395,7 @@ def create_demo(stdout): # pylint: disable=too-many-branches too-many-statement
|
|||||||
)
|
)
|
||||||
queue.push(
|
queue.push(
|
||||||
mailbox_models.MailDomainAccess(
|
mailbox_models.MailDomainAccess(
|
||||||
domain_id=domains_ids[0],
|
domain=domains[0],
|
||||||
user_id=team_mail_user.pk,
|
user_id=team_mail_user.pk,
|
||||||
role=domain_role,
|
role=domain_role,
|
||||||
)
|
)
|
||||||
@@ -414,21 +422,20 @@ def create_demo(stdout): # pylint: disable=too-many-branches too-many-statement
|
|||||||
role=MailDomainRoleChoices.ADMIN,
|
role=MailDomainRoleChoices.ADMIN,
|
||||||
)
|
)
|
||||||
|
|
||||||
# Many mailboxes domain
|
# Many objects domain
|
||||||
many_boxes_domain, _created = mailbox_models.MailDomain.objects.get_or_create(
|
many_objects_domain, _created = mailbox_models.MailDomain.objects.get_or_create(
|
||||||
name="many-boxes-domain.com",
|
name="many-objects-domain.com",
|
||||||
status=MailDomainStatusChoices.ENABLED,
|
status=MailDomainStatusChoices.ENABLED,
|
||||||
support_email="support@mbd.com",
|
support_email="support@mbd.com",
|
||||||
)
|
)
|
||||||
domain_owner = models.User.objects.get(email="e2e.mail-owner@example.com")
|
|
||||||
mailbox_models.MailDomainAccess.objects.get_or_create(
|
mailbox_models.MailDomainAccess.objects.get_or_create(
|
||||||
domain=many_boxes_domain,
|
domain=many_objects_domain,
|
||||||
user=domain_owner,
|
user=domain_owner,
|
||||||
role=MailDomainRoleChoices.OWNER,
|
role=MailDomainRoleChoices.OWNER,
|
||||||
)
|
)
|
||||||
mailbox_models.MailDomainInvitation.objects.create(
|
mailbox_models.MailDomainInvitation.objects.create(
|
||||||
issuer=domain_owner,
|
issuer=domain_owner,
|
||||||
domain=many_boxes_domain,
|
domain=many_objects_domain,
|
||||||
email="people@people.world",
|
email="people@people.world",
|
||||||
role=MailDomainRoleChoices.OWNER,
|
role=MailDomainRoleChoices.OWNER,
|
||||||
)
|
)
|
||||||
@@ -436,15 +443,22 @@ def create_demo(stdout): # pylint: disable=too-many-branches too-many-statement
|
|||||||
first_name = fake.first_name()
|
first_name = fake.first_name()
|
||||||
last_name = fake.last_name()
|
last_name = fake.last_name()
|
||||||
local_part = f"{first_name.lower()}.{last_name.lower()}"
|
local_part = f"{first_name.lower()}.{last_name.lower()}"
|
||||||
|
|
||||||
mailbox_models.Mailbox.objects.create(
|
mailbox_models.Mailbox.objects.create(
|
||||||
domain=many_boxes_domain,
|
domain=many_objects_domain,
|
||||||
first_name=first_name,
|
first_name=first_name,
|
||||||
last_name=last_name,
|
last_name=last_name,
|
||||||
local_part=local_part,
|
local_part=local_part,
|
||||||
secondary_email=f"{local_part}@example.fr",
|
secondary_email=f"{local_part}@example.fr",
|
||||||
status=random.choice(MailboxStatusChoices.values),
|
status=random.choice(MailboxStatusChoices.values),
|
||||||
password=make_password(None), # unusable password
|
password=make_password(None), # unusable password
|
||||||
dn_email=f"{local_part}@{many_boxes_domain}",
|
dn_email=f"{local_part}@{many_objects_domain}",
|
||||||
|
)
|
||||||
|
|
||||||
|
mailbox_models.Alias.objects.create(
|
||||||
|
local_part=fake.word(),
|
||||||
|
destination=fake.email(),
|
||||||
|
domain=many_objects_domain,
|
||||||
)
|
)
|
||||||
|
|
||||||
# OIDC configuration
|
# OIDC configuration
|
||||||
|
|||||||
@@ -20,6 +20,8 @@ TEST_NB_OBJECTS = {
|
|||||||
"teams": 100,
|
"teams": 100,
|
||||||
"max_users_per_team": 5,
|
"max_users_per_team": 5,
|
||||||
"domains": 10,
|
"domains": 10,
|
||||||
|
"mailboxes_per_domain": 2,
|
||||||
|
"aliases_per_domain": 2,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -33,8 +35,8 @@ def test_commands_create_demo(settings):
|
|||||||
call_command("create_demo")
|
call_command("create_demo")
|
||||||
|
|
||||||
# Monique Test, Jeanne Test and Jean Something (quick fix for e2e)
|
# Monique Test, Jeanne Test and Jean Something (quick fix for e2e)
|
||||||
# 3 user with team rights
|
# 3 users with team rights
|
||||||
# 3 user with domain rights
|
# 3 users with domain rights
|
||||||
# 3 x 3 user with both rights
|
# 3 x 3 user with both rights
|
||||||
assert models.User.objects.count() == TEST_NB_OBJECTS["users"] + 3 + 3 + 3 + 9
|
assert models.User.objects.count() == TEST_NB_OBJECTS["users"] + 3 + 3 + 3 + 9
|
||||||
|
|
||||||
@@ -55,6 +57,16 @@ def test_commands_create_demo(settings):
|
|||||||
== TEST_NB_OBJECTS["domains"] + 3 + 9 + 2
|
== TEST_NB_OBJECTS["domains"] + 3 + 9 + 2
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# TEST_NB_OBJECTS["domains"]*TEST_NB_OBJECTS["mailboxes_per_domain"] = 20
|
||||||
|
# + 30 in the many-object-domain
|
||||||
|
# + 1 mailbox for user-e2e@example.com
|
||||||
|
# = 51
|
||||||
|
assert mailbox_models.Mailbox.objects.count() == 51
|
||||||
|
|
||||||
|
# TEST_NB_OBJECTS["domains"]*TEST_NB_OBJECTS["mailboxes_per_alias"] = 20
|
||||||
|
# + 30 in the many-object-domain
|
||||||
|
assert mailbox_models.Alias.objects.count() == 50
|
||||||
|
|
||||||
|
|
||||||
def test_commands_createsuperuser():
|
def test_commands_createsuperuser():
|
||||||
"""
|
"""
|
||||||
|
|||||||
Reference in New Issue
Block a user