Skip to content

Commit 14ef748

Browse files
authored
Merge pull request #20323 from mozilla/fxa-13401-otp-prod-tests
fix(func-tests): update otp tests for prod
2 parents ba7d846 + 1edcf97 commit 14ef748

3 files changed

Lines changed: 41 additions & 39 deletions

File tree

packages/functional-tests/lib/testAccountTracker.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ enum EmailPrefix {
2525
SYNC = 'sync',
2626
}
2727

28-
const RELIER_CLIENT_ID = 'dcdb5ae7add825d2';
2928
const SUPPORTED_SERVICE = 'smoketests';
3029

3130
type AccountDetails = {
@@ -263,7 +262,7 @@ export class TestAccountTracker {
263262

264263
// Send passwordless code
265264
await this.target.authClient.passwordlessSendCode(email, {
266-
clientId: RELIER_CLIENT_ID,
265+
clientId: this.target.relierClientID,
267266
service: SUPPORTED_SERVICE,
268267
});
269268

@@ -275,7 +274,7 @@ export class TestAccountTracker {
275274
email,
276275
code,
277276
{
278-
clientId: RELIER_CLIENT_ID,
277+
clientId: this.target.relierClientID,
279278
service: SUPPORTED_SERVICE,
280279
}
281280
);
@@ -459,7 +458,7 @@ export class TestAccountTracker {
459458
try {
460459
// Send passwordless code
461460
await this.target.authClient.passwordlessSendCode(account.email, {
462-
clientId: RELIER_CLIENT_ID,
461+
clientId: this.target.relierClientID,
463462
service: SUPPORTED_SERVICE,
464463
});
465464

@@ -473,7 +472,7 @@ export class TestAccountTracker {
473472
account.email,
474473
code,
475474
{
476-
clientId: RELIER_CLIENT_ID,
475+
clientId: this.target.relierClientID,
477476
service: SUPPORTED_SERVICE,
478477
}
479478
);

packages/functional-tests/tests/passwordless/passwordlessApi.spec.ts

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import { expect, test } from '../../lib/fixtures/standard';
66
import { getTotpCode } from '../../lib/totp';
77

8-
const CLIENT_ID = 'dcdb5ae7add825d2';
98
const SUPPORTED_SERVICE = 'smoketests';
109

1110
async function getPasswordlessSession(
@@ -14,14 +13,14 @@ async function getPasswordlessSession(
1413
isNew: boolean
1514
) {
1615
await target.authClient.passwordlessSendCode(email, {
17-
clientId: CLIENT_ID,
16+
clientId: target.relierClientID,
1817
service: SUPPORTED_SERVICE,
1918
});
2019
const code = isNew
2120
? await target.emailClient.getPasswordlessSignupCode(email)
2221
: await target.emailClient.getPasswordlessSigninCode(email);
2322
return target.authClient.passwordlessConfirmCode(email, code, {
24-
clientId: CLIENT_ID,
23+
clientId: target.relierClientID,
2524
service: SUPPORTED_SERVICE,
2625
});
2726
}
@@ -38,7 +37,7 @@ test.describe('severity-2', () => {
3837
testAccountTracker.generatePasswordlessAccountDetails();
3938

4039
await target.authClient.passwordlessSendCode(email, {
41-
clientId: CLIENT_ID,
40+
clientId: target.relierClientID,
4241
service: SUPPORTED_SERVICE,
4342
});
4443

@@ -53,7 +52,7 @@ test.describe('severity-2', () => {
5352
const { email } = await testAccountTracker.signUpPasswordless();
5453

5554
await target.authClient.passwordlessSendCode(email, {
56-
clientId: CLIENT_ID,
55+
clientId: target.relierClientID,
5756
service: SUPPORTED_SERVICE,
5857
});
5958

@@ -69,7 +68,7 @@ test.describe('severity-2', () => {
6968

7069
try {
7170
await target.authClient.passwordlessSendCode(credentials.email, {
72-
clientId: CLIENT_ID,
71+
clientId: target.relierClientID,
7372
service: SUPPORTED_SERVICE,
7473
});
7574
expect(
@@ -114,7 +113,7 @@ test.describe('severity-2', () => {
114113
);
115114

116115
await target.authClient.passwordlessSendCode(email, {
117-
clientId: CLIENT_ID,
116+
clientId: target.relierClientID,
118117
service: SUPPORTED_SERVICE,
119118
});
120119

@@ -123,7 +122,7 @@ test.describe('severity-2', () => {
123122
email,
124123
code,
125124
{
126-
clientId: CLIENT_ID,
125+
clientId: target.relierClientID,
127126
service: SUPPORTED_SERVICE,
128127
}
129128
);
@@ -152,7 +151,7 @@ test.describe('severity-2', () => {
152151
const password = account?.password || '';
153152

154153
await target.authClient.passwordlessSendCode(email, {
155-
clientId: CLIENT_ID,
154+
clientId: target.relierClientID,
156155
service: SUPPORTED_SERVICE,
157156
});
158157

@@ -161,7 +160,7 @@ test.describe('severity-2', () => {
161160
email,
162161
code,
163162
{
164-
clientId: CLIENT_ID,
163+
clientId: target.relierClientID,
165164
service: SUPPORTED_SERVICE,
166165
}
167166
);
@@ -187,7 +186,7 @@ test.describe('severity-2', () => {
187186
testAccountTracker.generatePasswordlessAccountDetails();
188187

189188
await target.authClient.passwordlessSendCode(email, {
190-
clientId: CLIENT_ID,
189+
clientId: target.relierClientID,
191190
service: SUPPORTED_SERVICE,
192191
});
193192

@@ -196,7 +195,7 @@ test.describe('severity-2', () => {
196195

197196
try {
198197
await target.authClient.passwordlessConfirmCode(email, '00000000', {
199-
clientId: CLIENT_ID,
198+
clientId: target.relierClientID,
200199
service: SUPPORTED_SERVICE,
201200
});
202201
expect(
@@ -233,15 +232,15 @@ test.describe('severity-2', () => {
233232
}
234233

235234
await target.authClient.passwordlessSendCode(email, {
236-
clientId: CLIENT_ID,
235+
clientId: target.relierClientID,
237236
service: SUPPORTED_SERVICE,
238237
});
239238

240239
const code = await target.emailClient.getPasswordlessSigninCode(email);
241240
const result = await target.authClient.passwordlessConfirmCode(
242241
email,
243242
code,
244-
{ clientId: CLIENT_ID, service: SUPPORTED_SERVICE }
243+
{ clientId: target.relierClientID, service: SUPPORTED_SERVICE }
245244
);
246245

247246
expect(result.verified).toBe(false);
@@ -275,14 +274,14 @@ test.describe('severity-2', () => {
275274
);
276275

277276
await target.authClient.passwordlessSendCode(email, {
278-
clientId: CLIENT_ID,
277+
clientId: target.relierClientID,
279278
service: SUPPORTED_SERVICE,
280279
});
281280

282281
await target.emailClient.getPasswordlessSignupCode(email);
283282

284283
await target.authClient.passwordlessResendCode(email, {
285-
clientId: CLIENT_ID,
284+
clientId: target.relierClientID,
286285
service: SUPPORTED_SERVICE,
287286
});
288287

@@ -291,7 +290,7 @@ test.describe('severity-2', () => {
291290
const result = await target.authClient.passwordlessConfirmCode(
292291
email,
293292
code,
294-
{ clientId: CLIENT_ID, service: SUPPORTED_SERVICE }
293+
{ clientId: target.relierClientID, service: SUPPORTED_SERVICE }
295294
);
296295
expect(result.verified).toBe(true);
297296

@@ -432,7 +431,7 @@ test.describe('severity-2', () => {
432431
// Passwordless send should be rejected after password creation
433432
try {
434433
await target.authClient.passwordlessSendCode(email, {
435-
clientId: CLIENT_ID,
434+
clientId: target.relierClientID,
436435
service: SUPPORTED_SERVICE,
437436
});
438437
expect(

packages/functional-tests/tests/passwordless/signinPasswordless.spec.ts

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -166,14 +166,14 @@ test.describe('severity-1 #smoke', () => {
166166
// Use the API directly to get an unverified session token
167167
// (bypasses browser UI so we can test the session before TOTP)
168168
await target.authClient.passwordlessSendCode(email, {
169-
clientId: 'dcdb5ae7add825d2',
169+
clientId: target.relierClientID,
170170
});
171171
const otpCode =
172172
await target.emailClient.getPasswordlessSigninCode(email);
173173
const confirmResult = await target.authClient.passwordlessConfirmCode(
174174
email,
175175
otpCode,
176-
{ clientId: 'dcdb5ae7add825d2' }
176+
{ clientId: target.relierClientID }
177177
);
178178

179179
// The session should be unverified (TOTP pending)
@@ -184,7 +184,7 @@ test.describe('severity-1 #smoke', () => {
184184
try {
185185
await target.authClient.createOAuthCode(
186186
confirmResult.sessionToken,
187-
'dcdb5ae7add825d2',
187+
target.relierClientID,
188188
'teststate',
189189
{ scope: 'profile' }
190190
);
@@ -217,7 +217,6 @@ test.describe('severity-1 #smoke', () => {
217217
});
218218

219219
test.describe('Session verification state invariants', () => {
220-
const CLIENT_ID = 'dcdb5ae7add825d2';
221220
const SUPPORTED_SERVICE = 'smoketests';
222221

223222
async function getPasswordlessSession(
@@ -226,14 +225,14 @@ test.describe('severity-1 #smoke', () => {
226225
isNew: boolean
227226
) {
228227
await target.authClient.passwordlessSendCode(email, {
229-
clientId: CLIENT_ID,
228+
clientId: target.relierClientID,
230229
service: SUPPORTED_SERVICE,
231230
});
232231
const code = isNew
233232
? await target.emailClient.getPasswordlessSignupCode(email)
234233
: await target.emailClient.getPasswordlessSigninCode(email);
235234
return target.authClient.passwordlessConfirmCode(email, code, {
236-
clientId: CLIENT_ID,
235+
clientId: target.relierClientID,
237236
service: SUPPORTED_SERVICE,
238237
});
239238
}
@@ -356,7 +355,7 @@ test.describe('severity-1 #smoke', () => {
356355

357356
const oauthResult = await target.authClient.createOAuthCode(
358357
result.sessionToken,
359-
CLIENT_ID,
358+
target.relierClientID,
360359
'teststate',
361360
{ scope: 'profile' }
362361
);
@@ -530,7 +529,7 @@ test.describe('severity-1 #smoke', () => {
530529
// OAuth should now succeed
531530
const oauthResult = await target.authClient.createOAuthCode(
532531
result.sessionToken,
533-
CLIENT_ID,
532+
target.relierClientID,
534533
'teststate',
535534
{ scope: 'profile' }
536535
);
@@ -578,7 +577,7 @@ test.describe('severity-1 #smoke', () => {
578577
// Account now has a password — passwordless send should be rejected
579578
try {
580579
await target.authClient.passwordlessSendCode(email, {
581-
clientId: CLIENT_ID,
580+
clientId: target.relierClientID,
582581
});
583582
expect(
584583
true,
@@ -758,14 +757,14 @@ test.describe('severity-1 #smoke', () => {
758757
// Cleanup: Set password so testAccountTracker can sign in and destroy
759758
// Re-authenticate to get a fresh session since the old one may be stale
760759
await target.authClient.passwordlessSendCode(email, {
761-
clientId: 'dcdb5ae7add825d2',
760+
clientId: target.relierClientID,
762761
});
763762
const cleanupCode =
764763
await target.emailClient.getPasswordlessSigninCode(email);
765764
const cleanupResult = await target.authClient.passwordlessConfirmCode(
766765
email,
767766
cleanupCode,
768-
{ clientId: 'dcdb5ae7add825d2' }
767+
{ clientId: target.relierClientID }
769768
);
770769
// Elevate to AAL2 for password creation
771770
const cleanupTotpCode = await getTotpCode(secret);
@@ -937,13 +936,13 @@ test.describe('severity-2', () => {
937936

938937
// Create a password on the first account via API
939938
await target.authClient.passwordlessSendCode(email, {
940-
clientId: 'dcdb5ae7add825d2',
939+
clientId: target.relierClientID,
941940
});
942941
const otpCode = await target.emailClient.getPasswordlessSigninCode(email);
943942
const result = await target.authClient.passwordlessConfirmCode(
944943
email,
945944
otpCode,
946-
{ clientId: 'dcdb5ae7add825d2' }
945+
{ clientId: target.relierClientID }
947946
);
948947
await target.authClient.createPassword(
949948
result.sessionToken,
@@ -1148,7 +1147,12 @@ test.describe('severity-2', () => {
11481147

11491148
test('passwordless signin via Relay OAuth flow - account with 2FA proceeds to TOTP verification', async ({
11501149
target,
1151-
syncOAuthBrowserPages: { page, signin, signinPasswordlessCode, signinTotpCode },
1150+
syncOAuthBrowserPages: {
1151+
page,
1152+
signin,
1153+
signinPasswordlessCode,
1154+
signinTotpCode,
1155+
},
11521156
testAccountTracker,
11531157
}) => {
11541158
// Create passwordless account and set up TOTP via API
@@ -1204,14 +1208,14 @@ test.describe('severity-2', () => {
12041208

12051209
// Cleanup: set password so testAccountTracker can destroy the account
12061210
await target.authClient.passwordlessSendCode(email, {
1207-
clientId: 'dcdb5ae7add825d2',
1211+
clientId: target.relierClientID,
12081212
});
12091213
const cleanupCode =
12101214
await target.emailClient.getPasswordlessSigninCode(email);
12111215
const cleanupResult = await target.authClient.passwordlessConfirmCode(
12121216
email,
12131217
cleanupCode,
1214-
{ clientId: 'dcdb5ae7add825d2' }
1218+
{ clientId: target.relierClientID }
12151219
);
12161220
const cleanupTotpCode = await getTotpCode(secret);
12171221
await target.authClient.verifyTotpCode(

0 commit comments

Comments
 (0)