Skip to content

Commit

Permalink
Fixing interdependency in mfa totp integration tests ax (#7362)
Browse files Browse the repository at this point in the history
* reorganized mfa totp integration tests

* formatted the code

* added await for enroll function calls

* created fakePassword to store password

* fixed typo in mfaUser

* moved fakePassword into integration helpers file

* changed fakePassword var name to password
  • Loading branch information
AngelAngelXie committed Jun 14, 2023
1 parent 574585a commit 8e9aac2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion packages/auth/test/helpers/integration/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,6 @@ export function getTotpCode(
return token;
}
export const email = 'totpuser-donotdelete@test.com';
export const fakePassword = 'password';
export const password = 'password';
//1000000 is always incorrect since it has 7 digits and we expect 6.
export const incorrectTotpCode = '1000000';
14 changes: 7 additions & 7 deletions packages/auth/test/integration/flows/totp.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import {
getTestInstance,
getTotpCode,
email,
fakePassword,
password,
incorrectTotpCode
} from '../../helpers/integration/helpers';

Expand Down Expand Up @@ -77,7 +77,7 @@ describe(' Integration tests: Mfa enrollement using totp', () => {
this.skip();
}

const cr = await signInWithEmailAndPassword(auth, email, fakePassword);
const cr = await signInWithEmailAndPassword(auth, email, password);
mfaUser = multiFactor(cr.user);
const session = await mfaUser.getSession();
totpSecret = await TotpMultiFactorGenerator.generateSecret(session);
Expand All @@ -98,7 +98,7 @@ describe(' Integration tests: Mfa enrollement using totp', () => {
this.skip();
}

const cr = await signInWithEmailAndPassword(auth, email, fakePassword);
const cr = await signInWithEmailAndPassword(auth, email, password);
mfaUser = multiFactor(cr.user);
const session = await mfaUser.getSession();
totpSecret = await TotpMultiFactorGenerator.generateSecret(session);
Expand Down Expand Up @@ -130,7 +130,7 @@ describe('Integration tests: sign-in for mfa-enrolled users', () => {
auth = getTestInstance();
displayName = 'totp-integration-test';

const cr = await signInWithEmailAndPassword(auth, email, fakePassword);
const cr = await signInWithEmailAndPassword(auth, email, password);
mfaUser = multiFactor(cr.user);
const session = await mfaUser.getSession();
totpSecret = await TotpMultiFactorGenerator.generateSecret(session);
Expand Down Expand Up @@ -169,7 +169,7 @@ describe('Integration tests: sign-in for mfa-enrolled users', () => {
this.skip();
}
try {
await signInWithEmailAndPassword(auth, email, fakePassword);
await signInWithEmailAndPassword(auth, email, password);

throw new Error('Signin should not have been successful');
} catch (error) {
Expand All @@ -196,7 +196,7 @@ describe('Integration tests: sign-in for mfa-enrolled users', () => {
this.skip();
}
try {
await signInWithEmailAndPassword(auth, email, fakePassword);
await signInWithEmailAndPassword(auth, email, password);

throw new Error('Signin should not have been successful');
} catch (error) {
Expand All @@ -223,7 +223,7 @@ describe('Integration tests: sign-in for mfa-enrolled users', () => {
mfaUser = multiFactor(userCredential.user);

await expect(mfaUser.unenroll(resolver.hints[0].uid)).to.be.fulfilled;
await expect(signInWithEmailAndPassword(auth, email, fakePassword)).to.be
await expect(signInWithEmailAndPassword(auth, email, password)).to.be
.fulfilled;
}
});
Expand Down

0 comments on commit 8e9aac2

Please sign in to comment.