Skip to content

Commit 9b8d3e8

Browse files
committed
[MS] Updated e2e tests with new auth
1 parent 254af4e commit 9b8d3e8

17 files changed

Lines changed: 127 additions & 175 deletions

client/src/components/devices/ChooseAuthentication.vue

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -25,25 +25,25 @@
2525
class="item-radio radio-list-item"
2626
label-placement="end"
2727
justify="start"
28-
:value="DeviceSaveStrategyTag.Keyring"
29-
:disabled="!keyringAvailable || activeAuth === AvailableDeviceTypeTag.Keyring"
28+
:value="DeviceSaveStrategyTag.Password"
3029
>
3130
<authentication-card
32-
:auth-method="DeviceSaveStrategyTag.Keyring"
33-
:state="getAuthCardState(AvailableDeviceTypeTag.Keyring)"
34-
:disabled="!keyringAvailable"
31+
@click="onMethodSelected(DeviceSaveStrategyTag.Password)"
32+
:state="getAuthCardState(AvailableDeviceTypeTag.Password)"
33+
:auth-method="DeviceSaveStrategyTag.Password"
3534
/>
3635
</ion-radio>
3736
<ion-radio
3837
class="item-radio radio-list-item"
3938
label-placement="end"
4039
justify="start"
41-
:value="DeviceSaveStrategyTag.Password"
40+
:value="DeviceSaveStrategyTag.Keyring"
41+
:disabled="!keyringAvailable || activeAuth === AvailableDeviceTypeTag.Keyring"
4242
>
4343
<authentication-card
44-
@click="onMethodSelected(DeviceSaveStrategyTag.Password)"
45-
:state="getAuthCardState(AvailableDeviceTypeTag.Password)"
46-
:auth-method="DeviceSaveStrategyTag.Password"
44+
:auth-method="DeviceSaveStrategyTag.Keyring"
45+
:state="getAuthCardState(AvailableDeviceTypeTag.Keyring)"
46+
:disabled="!keyringAvailable"
4747
/>
4848
</ion-radio>
4949

@@ -58,21 +58,22 @@
5858
@click="onMethodSelected(DeviceSaveStrategyTag.PKI)"
5959
:state="getAuthCardState(AvailableDeviceTypeTag.PKI)"
6060
:auth-method="DeviceSaveStrategyTag.PKI"
61+
:disabled="!smartcardAvailable"
6162
/>
6263
</ion-radio>
6364

6465
<ion-radio
65-
v-show="showOpenBaoAuth"
6666
class="item-radio radio-list-item"
6767
label-placement="end"
6868
:value="DeviceSaveStrategyTag.OpenBao"
6969
justify="start"
70-
:disabled="activeAuth === AvailableDeviceTypeTag.OpenBao"
70+
:disabled="!openBaoAuthAvailable || activeAuth === AvailableDeviceTypeTag.OpenBao"
7171
>
7272
<authentication-card
7373
:state="getAuthCardState(AvailableDeviceTypeTag.OpenBao)"
7474
@click="onMethodSelected(DeviceSaveStrategyTag.OpenBao)"
7575
:auth-method="DeviceSaveStrategyTag.OpenBao"
76+
:disabled="!openBaoAuthAvailable"
7677
/>
7778
</ion-radio>
7879
</ion-radio-group>
@@ -122,7 +123,7 @@
122123
<choose-certificate ref="chooseCertificate" />
123124
</div>
124125

125-
<div v-if="authentication === DeviceSaveStrategyTag.OpenBao && serverConfig?.openbao && showOpenBaoAuth">
126+
<div v-if="authentication === DeviceSaveStrategyTag.OpenBao && serverConfig?.openbao && openBaoAuthAvailable">
126127
<div class="method-chosen">
127128
<ion-text class="method-chosen__title subtitles-sm">{{ $msTranslate('Authentication.methodChosen') }}</ion-text>
128129
<authentication-card
@@ -190,7 +191,7 @@ const querying = ref(false);
190191
191192
const error = ref('');
192193
193-
const showOpenBaoAuth = computed(() => {
194+
const openBaoAuthAvailable = computed(() => {
194195
return props.serverConfig?.openbao && props.serverConfig?.openbao.auths.some((auth) => isSSOProviderHandled(auth.tag));
195196
});
196197
@@ -236,6 +237,9 @@ function getAuthCardState(auth: AvailableDeviceTypeTag): AuthenticationCardState
236237
}
237238
return auth === props.activeAuth ? AuthenticationCardState.Active : AuthenticationCardState.Default;
238239
case AvailableDeviceTypeTag.OpenBao:
240+
if (!openBaoAuthAvailable.value) {
241+
return AuthenticationCardState.Unavailable;
242+
}
239243
return auth === props.activeAuth ? AuthenticationCardState.Active : AuthenticationCardState.Default;
240244
default:
241245
return AuthenticationCardState.Default;

client/src/components/profile/AuthenticationCard.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ const methodConfig: Record<
122122
imageAlt: 'OpenBao',
123123
methodName: 'Authentication.method.sso.title',
124124
description: 'Authentication.method.sso.description',
125+
unavailableExplanation: 'Authentication.method.sso.unavailable',
125126
},
126127
};
127128

client/src/locales/en-US.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1290,7 +1290,8 @@
12901290
"sso": {
12911291
"title": "Single Sign-On",
12921292
"description": "Login with an external account",
1293-
"connected": "Connected"
1293+
"connected": "Connected",
1294+
"unavailable": "This method is not allowed by this server."
12941295
}
12951296
},
12961297
"methodChosen": "Method chosen:",

client/src/locales/fr-FR.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1290,7 +1290,8 @@
12901290
"sso": {
12911291
"title": "Authentification unique (SSO)",
12921292
"description": "S'authentifier avec un compte externe",
1293-
"connected": "Connecté"
1293+
"connected": "Connecté",
1294+
"unavailable": "Cette méthode n'est pas autorisée par ce serveur."
12941295
}
12951296
},
12961297
"methodChosen": "Méthode choisie :",

client/tests/e2e/helpers/assertions.ts

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -484,4 +484,49 @@ export const expect = baseExpect.extend({
484484
pass: true,
485485
};
486486
},
487+
488+
async toHaveAuthentication(
489+
authRadio: Locator,
490+
state?: { passwordDisabled?: boolean; ssoDisabled?: boolean; pkiDisabled?: boolean; keyringDisabled?: boolean },
491+
): Promise<AssertReturnType> {
492+
await baseExpect(authRadio).toHaveCount(4);
493+
await baseExpect(authRadio.nth(0).locator('.authentication-card-text__title')).toHaveText('Password');
494+
await baseExpect(authRadio.nth(1).locator('.authentication-card-text__title')).toHaveText('System authentication');
495+
await baseExpect(authRadio.nth(2).locator('.authentication-card-text__title')).toHaveText('Smartcard');
496+
await baseExpect(authRadio.nth(3).locator('.authentication-card-text__title')).toHaveText('Single Sign-On');
497+
498+
if (state?.passwordDisabled) {
499+
await baseExpect(authRadio.nth(0)).toHaveClass(/radio-disabled/);
500+
} else {
501+
await baseExpect(authRadio.nth(0)).not.toHaveClass(/radio-disabled/);
502+
}
503+
if (state?.keyringDisabled) {
504+
await baseExpect(authRadio.nth(1)).toHaveClass(/radio-disabled/);
505+
await baseExpect(authRadio.nth(1).locator('.authentication-card-text__description')).toHaveText('Unavailable on web');
506+
} else {
507+
await baseExpect(authRadio.nth(1)).not.toHaveClass(/radio-disabled/);
508+
}
509+
if (state?.pkiDisabled) {
510+
await baseExpect(authRadio.nth(2)).toHaveClass(/radio-disabled/);
511+
await baseExpect(authRadio.nth(2).locator('.authentication-card-text__description')).toHaveText(
512+
'Smartcard authentication is unavailable.',
513+
);
514+
} else {
515+
await baseExpect(authRadio.nth(2)).not.toHaveClass(/radio-disabled/);
516+
await baseExpect(authRadio.nth(2).locator('.authentication-card-text__description')).toHaveText('Login with an external account');
517+
}
518+
if (state?.ssoDisabled) {
519+
await baseExpect(authRadio.nth(3)).toHaveClass(/radio-disabled/);
520+
await baseExpect(authRadio.nth(3).locator('.authentication-card-text__description')).toHaveText(
521+
'This method is not allowed by this server.',
522+
);
523+
} else {
524+
await baseExpect(authRadio.nth(3)).not.toHaveClass(/radio-disabled/);
525+
await baseExpect(authRadio.nth(3).locator('.authentication-card-text__description')).toHaveText('Login with an external account');
526+
}
527+
return {
528+
message: () => '',
529+
pass: true,
530+
};
531+
},
487532
});

client/tests/e2e/helpers/fixtures.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ export async function setupNewPage(page: MsPage, opts: SetupOptions = {}): Promi
6868
if (options.enableUpdateEvent) {
6969
(window as any).TESTING_ENABLE_UPDATE_EVENT = options.enableUpdateEvent;
7070
}
71-
(window as any).TESTING_PKI = true;
7271
if (options.openBaoServer) {
7372
(window as any).TESTING_OPEN_BAO_SERVER = options.openBaoServer;
7473
}
@@ -443,7 +442,7 @@ export const msTest = debugTest.extend<{
443442

444443
invitationsPage: async ({ connected }, use) => {
445444
await connected.locator('.sidebar').locator('#sidebar-invitations').click();
446-
await expect(connected).toHavePageTitle('Invitations');
445+
await expect(connected).toHavePageTitle('Invitations & Requests');
447446
await expect(connected).toBeInvitationPage();
448447
use(connected);
449448
},

client/tests/e2e/helpers/greet.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -153,11 +153,8 @@ export async function addUser(
153153

154154
// Joiner sets password
155155
const authRadio = joinData.content.locator('.choose-auth-page').locator('.radio-list-item:visible');
156-
await expect(authRadio).toHaveCount(3);
157-
await expect(authRadio.nth(0)).toHaveTheClass('radio-disabled');
158-
await expect(authRadio.nth(0).locator('.authentication-card-text__title')).toHaveText('System authentication');
159-
await expect(authRadio.nth(1)).toHaveText('Password');
160-
await authRadio.nth(1).click();
156+
await expect(authRadio).toHaveAuthentication({ pkiDisabled: true, keyringDisabled: true });
157+
await authRadio.nth(0).click();
161158

162159
const passwordChoice = joinData.content.locator('#get-password').locator('.choose-password');
163160
await passwordChoice.scrollIntoViewIfNeeded();

client/tests/e2e/specs/auth_with_sso.spec.ts

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,8 @@ msTest('Go through custom org creation process, auth SSO', async ({ home }) => {
4040
await expect(authContainer.locator('.modal-header-title__text')).toHaveText('Authentication');
4141

4242
const authRadio = authContainer.locator('.choose-auth-page').locator('.radio-list-item:visible');
43-
await expect(authRadio).toHaveCount(3);
44-
await expect(authRadio.nth(0)).toHaveTheClass('radio-disabled');
45-
await expect(authRadio.nth(0).locator('.authentication-card-text__title')).toHaveText('System authentication');
46-
await expect(authRadio.nth(1)).toHaveText('Password');
47-
await expect(authRadio.nth(2).locator('.authentication-card-text__title')).toHaveText('Single Sign-On');
48-
await expect(authRadio.nth(2).locator('.authentication-card-text__description')).toHaveText('Login with an external account');
49-
await authRadio.nth(2).click();
43+
await expect(authRadio).toHaveAuthentication({ pkiDisabled: true, keyringDisabled: true });
44+
await authRadio.nth(3).click();
5045
await expect(authContainer.locator('.proconnect-button')).toBeVisible();
5146
await expect(modal.locator('.proconnect-group--connected')).toBeHidden();
5247
await expect(authNext).toBeTrulyDisabled();
@@ -156,13 +151,8 @@ for (const error of ['timeout', '400', 'popup']) {
156151
await expect(authContainer.locator('.modal-header-title__text')).toHaveText('Authentication');
157152

158153
const authRadio = authContainer.locator('.choose-auth-page').locator('.radio-list-item:visible');
159-
await expect(authRadio).toHaveCount(3);
160-
await expect(authRadio.nth(0)).toHaveTheClass('radio-disabled');
161-
await expect(authRadio.nth(0).locator('.authentication-card-text__title')).toHaveText('System authentication');
162-
await expect(authRadio.nth(1)).toHaveText('Password');
163-
await expect(authRadio.nth(2).locator('.authentication-card-text__title')).toHaveText('Single Sign-On');
164-
await expect(authRadio.nth(2).locator('.authentication-card-text__description')).toHaveText('Login with an external account');
165-
await authRadio.nth(2).click();
154+
await expect(authRadio).toHaveAuthentication({ pkiDisabled: true, keyringDisabled: true });
155+
await authRadio.nth(3).click();
166156
await expect(authContainer.locator('.proconnect-button')).toBeVisible();
167157
await expect(modal.locator('.proconnect-group--connected')).toBeHidden();
168158
await expect(authNext).toBeTrulyDisabled();
@@ -222,10 +212,8 @@ msTest('Check ProConnect link', async ({ home }) => {
222212
await expect(authContainer).toBeVisible();
223213

224214
const authRadio = authContainer.locator('.choose-auth-page').locator('.radio-list-item:visible');
225-
await expect(authRadio).toHaveCount(3);
226-
await expect(authRadio.nth(2).locator('.authentication-card-text__title')).toHaveText('Single Sign-On');
227-
await expect(authRadio.nth(2).locator('.authentication-card-text__description')).toHaveText('Login with an external account');
228-
await authRadio.nth(2).click();
215+
await expect(authRadio).toHaveAuthentication({ pkiDisabled: true, keyringDisabled: true });
216+
await authRadio.nth(3).click();
229217
const card = authContainer.locator('.sso-provider-card');
230218
await expect(card).toHaveCount(1);
231219
await expect(card.locator('a')).toHaveText("What's ProConnect?");

client/tests/e2e/specs/create_organization_custom.spec.ts

Lines changed: 12 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -139,11 +139,9 @@ msTest('Go through custom org creation process', { tag: '@important' }, async ({
139139
await expect(authNext).toHaveDisabledAttribute();
140140

141141
const authRadio = authContainer.locator('.choose-auth-page').locator('.radio-list-item:visible');
142-
await expect(authRadio).toHaveCount(3);
143-
await expect(authRadio.nth(0)).toHaveTheClass('radio-disabled');
144-
await expect(authRadio.nth(0).locator('.authentication-card-text__title')).toHaveText('System authentication');
145-
await expect(authRadio.nth(1)).toHaveText('Password');
146-
await authRadio.nth(1).click();
142+
await expect(authRadio).toHaveCount(4);
143+
await expect(authRadio).toHaveAuthentication({ pkiDisabled: true, keyringDisabled: true });
144+
await authRadio.nth(0).click();
147145

148146
await fillIonInput(authContainer.locator('.choose-password').locator('ion-input').nth(0), DEFAULT_USER_INFORMATION.password);
149147
await expect(authNext).toHaveDisabledAttribute();
@@ -280,11 +278,8 @@ msTest('Go through custom org creation process from bootstrap link', async ({ co
280278
await expect(authNext).toHaveDisabledAttribute();
281279

282280
const authRadio = authContainer.locator('.choose-auth-page').locator('.radio-list-item:visible');
283-
await expect(authRadio).toHaveCount(3);
284-
await expect(authRadio.nth(0)).toHaveTheClass('radio-disabled');
285-
await expect(authRadio.nth(0).locator('.authentication-card-text__title')).toHaveText('System authentication');
286-
await expect(authRadio.nth(1)).toHaveText('Password');
287-
await authRadio.nth(1).click();
281+
await expect(authRadio).toHaveAuthentication({ pkiDisabled: true, keyringDisabled: true });
282+
await authRadio.nth(0).click();
288283

289284
await fillIonInput(authContainer.locator('.choose-password').locator('ion-input').nth(0), DEFAULT_USER_INFORMATION.password);
290285
await expect(authNext).toHaveDisabledAttribute();
@@ -418,11 +413,8 @@ for (const displaySize of ['small', 'large']) {
418413
await expect(authNext).toHaveDisabledAttribute();
419414

420415
const authRadio = authContainer.locator('.choose-auth-page').locator('.radio-list-item:visible');
421-
await expect(authRadio).toHaveCount(3);
422-
await expect(authRadio.nth(0)).toHaveTheClass('radio-disabled');
423-
await expect(authRadio.nth(0).locator('.authentication-card-text__title')).toHaveText('System authentication');
424-
await expect(authRadio.nth(1)).toHaveText('Password');
425-
await authRadio.nth(1).click();
416+
await expect(authRadio).toHaveAuthentication({ pkiDisabled: true, keyringDisabled: true });
417+
await authRadio.nth(0).click();
426418
await fillIonInput(authContainer.locator('.choose-password').locator('ion-input').nth(0), DEFAULT_USER_INFORMATION.password);
427419
await expect(authNext).toHaveDisabledAttribute();
428420
await fillIonInput(authContainer.locator('.choose-password').locator('ion-input').nth(1), DEFAULT_USER_INFORMATION.password);
@@ -554,11 +546,8 @@ for (const displaySize of ['small', 'large']) {
554546
await expect(authNext).toHaveDisabledAttribute();
555547

556548
const authRadio = authContainer.locator('.choose-auth-page').locator('.radio-list-item:visible');
557-
await expect(authRadio).toHaveCount(3);
558-
await expect(authRadio.nth(0)).toHaveTheClass('radio-disabled');
559-
await expect(authRadio.nth(0).locator('.authentication-card-text__title')).toHaveText('System authentication');
560-
await expect(authRadio.nth(1)).toHaveText('Password');
561-
await authRadio.nth(1).click();
549+
await expect(authRadio).toHaveAuthentication({ pkiDisabled: true, keyringDisabled: true });
550+
await authRadio.nth(0).click();
562551
await fillIonInput(authContainer.locator('.choose-password').locator('ion-input').nth(0), DEFAULT_USER_INFORMATION.password);
563552
await expect(authNext).toHaveDisabledAttribute();
564553
await fillIonInput(authContainer.locator('.choose-password').locator('ion-input').nth(1), DEFAULT_USER_INFORMATION.password);
@@ -655,11 +644,8 @@ for (const displaySize of ['small', 'large']) {
655644
await expect(authNext).toHaveDisabledAttribute();
656645

657646
const authRadio = authContainer.locator('.choose-auth-page').locator('.radio-list-item:visible');
658-
await expect(authRadio).toHaveCount(3);
659-
await expect(authRadio.nth(0)).toHaveTheClass('radio-disabled');
660-
await expect(authRadio.nth(0).locator('.authentication-card-text__title')).toHaveText('System authentication');
661-
await expect(authRadio.nth(1)).toHaveText('Password');
662-
await authRadio.nth(1).click();
647+
await expect(authRadio).toHaveAuthentication({ pkiDisabled: true, keyringDisabled: true });
648+
await authRadio.nth(0).click();
663649
await fillIonInput(authContainer.locator('.choose-password').locator('ion-input').nth(0), DEFAULT_USER_INFORMATION.password);
664650
await expect(authNext).toHaveDisabledAttribute();
665651
await fillIonInput(authContainer.locator('.choose-password').locator('ion-input').nth(1), DEFAULT_USER_INFORMATION.password);
@@ -775,11 +761,7 @@ msTest.skip('Go through custom org creation process with smartcard auth', async
775761
await expect(authNext).toHaveDisabledAttribute();
776762

777763
const authRadio = authContainer.locator('.choose-auth-page').locator('.radio-list-item:visible');
778-
await expect(authRadio).toHaveCount(3);
779-
await expect(authRadio.nth(0)).toHaveTheClass('radio-disabled');
780-
await expect(authRadio.nth(0).locator('.authentication-card-text__title')).toHaveText('System authentication');
781-
await expect(authRadio.nth(1)).toHaveText('Password');
782-
await expect(authRadio.nth(2).locator('.authentication-card-text__title')).toHaveText('Smartcard');
764+
await expect(authRadio).toHaveAuthentication({ pkiDisabled: false, keyringDisabled: true });
783765
const certBtn = authContainer.locator('.choose-certificate-button');
784766
await expect(certBtn).toBeHidden();
785767
await authRadio.nth(2).click();
@@ -793,7 +775,6 @@ msTest.skip('Go through custom org creation process with smartcard auth', async
793775

794776
await expect(authNext).toNotHaveDisabledAttribute();
795777
await authNext.click();
796-
797778
const summaryContainer = modal.locator('.summary-page');
798779
const summaryPrevious = modal.locator('.summary-page-footer').locator('ion-button').nth(0);
799780
const summaryNext = modal.locator('.summary-page-footer').locator('ion-button').nth(1);

0 commit comments

Comments
 (0)