Skip to content

Commit

Permalink
✅(e2e) sync keycloak users w/ backend users
Browse files Browse the repository at this point in the history
The user full name was not the same, it would induce
flaky test, while the user name is updated at user
login from the KC data.
  • Loading branch information
qbey committed Dec 5, 2024
1 parent 514414d commit 99b6181
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 60 deletions.
90 changes: 45 additions & 45 deletions docker/auth/realm.json
Original file line number Diff line number Diff line change
Expand Up @@ -101,211 +101,211 @@
"realmRoles": ["user"]
},
{
"username": "jean.team-member",
"email": "jean[email protected]",
"username": "e2e.team-member",
"email": "e2e[email protected]",
"firstName": "E2E",
"lastName": "Group Member",
"enabled": true,
"credentials": [
{
"type": "password",
"value": "password-e2e-jean.team-member"
"value": "password-e2e.team-member"
}
],
"realmRoles": ["user"]
},
{
"username": "jean.team-administrator",
"email": "jean[email protected]",
"username": "e2e.team-administrator",
"email": "e2e[email protected]",
"firstName": "E2E",
"lastName": "Group Administrator",
"enabled": true,
"credentials": [
{
"type": "password",
"value": "password-e2e-jean.team-administrator"
"value": "password-e2e.team-administrator"
}
],
"realmRoles": ["user"]
},
{
"username": "jean.team-owner",
"email": "jean[email protected]",
"username": "e2e.team-owner",
"email": "e2e[email protected]",
"firstName": "E2E",
"lastName": "Group Owner",
"enabled": true,
"credentials": [
{
"type": "password",
"value": "password-e2e-jean.team-owner"
"value": "password-e2e.team-owner"
}
],
"realmRoles": ["user"]
},
{
"username": "jean.mail-member",
"email": "jean[email protected]",
"username": "e2e.mail-member",
"email": "e2e[email protected]",
"firstName": "E2E",
"lastName": "Mailbox Member",
"enabled": true,
"credentials": [
{
"type": "password",
"value": "password-e2e-jean.mail-member"
"value": "password-e2e.mail-member"
}
],
"realmRoles": ["user"]
},
{
"username": "jean.mail-administrator",
"email": "jean[email protected]",
"username": "e2e.mail-administrator",
"email": "e2e[email protected]",
"firstName": "E2E",
"lastName": "Mailbox Administrator",
"enabled": true,
"credentials": [
{
"type": "password",
"value": "password-e2e-jean.mail-administrator"
"value": "password-e2e.mail-administrator"
}
],
"realmRoles": ["user"]
},
{
"username": "jean.mail-owner",
"email": "jean[email protected]",
"username": "e2e.mail-owner",
"email": "e2e[email protected]",
"firstName": "E2E",
"lastName": "Mailbox Owner",
"enabled": true,
"credentials": [
{
"type": "password",
"value": "password-e2e-jean.mail-owner"
"value": "password-e2e.mail-owner"
}
],
"realmRoles": ["user"]
},
{
"username": "jean.team-member-mail-member",
"email": "jean[email protected]",
"username": "e2e.team-member-mail-member",
"email": "e2e[email protected]",
"firstName": "E2E",
"lastName": "Group Member Mailbox Member",
"enabled": true,
"credentials": [
{
"type": "password",
"value": "password-e2e-jean.team-member-mail-member"
"value": "password-e2e.team-member-mail-member"
}
],
"realmRoles": ["user"]
},
{
"username": "jean.team-member-mail-administrator",
"email": "jean[email protected]",
"username": "e2e.team-member-mail-administrator",
"email": "e2e[email protected]",
"firstName": "E2E",
"lastName": "Group Member Mailbox Administrator",
"enabled": true,
"credentials": [
{
"type": "password",
"value": "password-e2e-jean.team-member-mail-administrator"
"value": "password-e2e.team-member-mail-administrator"
}
],
"realmRoles": ["user"]
},
{
"username": "jean.team-member-mail-owner",
"email": "jean[email protected]",
"username": "e2e.team-member-mail-owner",
"email": "e2e[email protected]",
"firstName": "E2E",
"lastName": "Group Member Mailbox Owner",
"enabled": true,
"credentials": [
{
"type": "password",
"value": "password-e2e-jean.team-member-mail-owner"
"value": "password-e2e.team-member-mail-owner"
}
],
"realmRoles": ["user"]
},
{
"username": "jean.team-administrator-mail-member",
"email": "jean[email protected]",
"username": "e2e.team-administrator-mail-member",
"email": "e2e[email protected]",
"firstName": "E2E",
"lastName": "Group Administrator Mailbox Member",
"enabled": true,
"credentials": [
{
"type": "password",
"value": "password-e2e-jean.team-administrator-mail-member"
"value": "password-e2e.team-administrator-mail-member"
}
],
"realmRoles": ["user"]
},
{
"username": "jean.team-administrator-mail-administrator",
"email": "jean[email protected]",
"username": "e2e.team-administrator-mail-administrator",
"email": "e2e[email protected]",
"firstName": "E2E",
"lastName": "Group Administrator Mailbox Administrator",
"enabled": true,
"credentials": [
{
"type": "password",
"value": "password-e2e-jean.team-administrator-mail-administrator"
"value": "password-e2e.team-administrator-mail-administrator"
}
],
"realmRoles": ["user"]
},
{
"username": "jean.team-administrator-mail-owner",
"email": "jean[email protected]",
"username": "e2e.team-administrator-mail-owner",
"email": "e2e[email protected]",
"firstName": "E2E",
"lastName": "Group Administrator Mailbox Owner",
"enabled": true,
"credentials": [
{
"type": "password",
"value": "password-e2e-jean.team-administrator-mail-owner"
"value": "password-e2e.team-administrator-mail-owner"
}
],
"realmRoles": ["user"]
},
{
"username": "jean.team-owner-mail-member",
"email": "jean[email protected]",
"username": "e2e.team-owner-mail-member",
"email": "e2e[email protected]",
"firstName": "E2E",
"lastName": "Group Owner Mailbox Member",
"enabled": true,
"credentials": [
{
"type": "password",
"value": "password-e2e-jean.team-owner-mail-member"
"value": "password-e2e.team-owner-mail-member"
}
],
"realmRoles": ["user"]
},
{
"username": "jean.team-owner-mail-administrator",
"email": "jean[email protected]",
"username": "e2e.team-owner-mail-administrator",
"email": "e2e[email protected]",
"firstName": "E2E",
"lastName": "Group Owner Mailbox Administrator",
"enabled": true,
"credentials": [
{
"type": "password",
"value": "password-e2e-jean.team-owner-mail-administrator"
"value": "password-e2e.team-owner-mail-administrator"
}
],
"realmRoles": ["user"]
},
{
"username": "jean.team-owner-mail-owner",
"email": "jean[email protected]",
"username": "e2e.team-owner-mail-owner",
"email": "e2e[email protected]",
"firstName": "E2E",
"lastName": "Mailbox Owner",
"enabled": true,
"credentials": [
{
"type": "password",
"value": "password-e2e-jean.team-owner-mail-owner"
"value": "password-e2e.team-owner-mail-owner"
}
],
"realmRoles": ["user"]
Expand Down
10 changes: 5 additions & 5 deletions docs/testsE2E.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,18 @@ A new browser window will open and you will be able to run the tests.
## Available accounts

The `make demo` command creates the following accounts:
- `jean.team-<role>@example.com` where `<role>` is one of `administrator`, `member`, `owner`:
- `e2e.team-<role>@example.com` where `<role>` is one of `administrator`, `member`, `owner`:
this account only belong to a team with the specified role.
- `jean.mail-<role>@example.com` where `<role>` is one of `administrator`, `member`, `owner`:
- `e2e.mail-<role>@example.com` where `<role>` is one of `administrator`, `member`, `owner`:
this account only have a mailbox with the specified role access.
- `jean.team-<team_role>-mail-<domain_role>@example.com` with a combination of roles as for the
- `e2e.team-<team_role>-mail-<domain_role>@example.com` with a combination of roles as for the
previous accounts.

For each account, the password is `password-e2e-<username>`, for instance `password-e2e-jean.team-member`.
For each account, the password is `password-e2e.<role>`, for instance `password-e2e.team-member`.

In the E2E tests you can use these accounts to benefit from there accesses,
using the `keyCloakSignIn(page, browserName, <account_name>)`. The account name is the
username without the prefix `jean.`.
username without the prefix `e2e.`.

``` typescript jsx
await keyCloakSignIn(page, browserName, 'mail-owner');
Expand Down
12 changes: 6 additions & 6 deletions src/backend/demo/management/commands/create_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,8 +233,8 @@ def create_demo(stdout): # pylint: disable=too-many-locals
for role in models.RoleChoices.values:
team_user = models.User(
sub=uuid4(),
email=f"jean.team-{role}@example.com",
name=f"Jean Group {role.capitalize()}",
email=f"e2e.team-{role}@example.com",
name=f"E2E Group {role.capitalize()}",
password="!",
is_superuser=False,
is_active=True,
Expand All @@ -249,8 +249,8 @@ def create_demo(stdout): # pylint: disable=too-many-locals
for role in models.RoleChoices.values:
user_with_mail = models.User(
sub=uuid4(),
email=f"jean.mail-{role}@example.com",
name=f"Jean Mail {role.capitalize()}",
email=f"e2e.mail-{role}@example.com",
name=f"E2E Mail {role.capitalize()}",
password="!",
is_superuser=False,
is_active=True,
Expand All @@ -270,8 +270,8 @@ def create_demo(stdout): # pylint: disable=too-many-locals
for domain_role in models.RoleChoices.values:
team_mail_user = models.User(
sub=uuid4(),
email=f"jean.team-{team_role}-mail-{domain_role}@example.com",
name=f"Jean Group {team_role.capitalize()} Mail {domain_role.capitalize()}",
email=f"e2e.team-{team_role}-mail-{domain_role}@example.com",
name=f"E2E Group {team_role.capitalize()} Mail {domain_role.capitalize()}",
password="!",
is_superuser=False,
is_active=True,
Expand Down
4 changes: 2 additions & 2 deletions src/frontend/apps/e2e/__tests__/app-desk/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ export const keyCloakSignIn = async (
});

const username = accountName
? `jean.${accountName}`
? `e2e.${accountName}`
: `user-e2e-${browserName}`;
const password = accountName
? `password-e2e-jean.${accountName}`
? `password-e2e.${accountName}`
: `password-e2e-${browserName}`;

if (title?.includes('Sign in to your account')) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ test.describe('Members Delete', () => {
const table = page.getByLabel('List members card').getByRole('table');

const cells = table.getByRole('row').nth(1).getByRole('cell');
await expect(cells.nth(1)).toHaveText('Jean Group Member');
await expect(cells.nth(1)).toHaveText('E2E Group Member');
await cells.nth(4).getByLabel('Member options').click();
await page.getByLabel('Open the modal to delete this member').click();

Expand Down Expand Up @@ -137,7 +137,7 @@ test.describe('Members Delete', () => {
await createTeam(page, 'member-delete-6', browserName, 1);

// To not be the only owner
await addNewMember(page, 0, 'Owner', 'Jean');
await addNewMember(page, 0, 'Owner', 'E2E');

const username = await addNewMember(page, 0, 'Administration', 'Monique');

Expand Down

0 comments on commit 99b6181

Please sign in to comment.