diff --git a/packages/actions/test/e2e/00-authentication.test.ts b/packages/actions/test/e2e/00-authentication.test.ts index dc966a47..bb446819 100644 --- a/packages/actions/test/e2e/00-authentication.test.ts +++ b/packages/actions/test/e2e/00-authentication.test.ts @@ -51,7 +51,6 @@ describe("Authentication", () => { expect(currentAuthenticatedUser.emailVerified).to.be.equal(user.data.emailVerified) expect(currentAuthenticatedUser.emailVerified).to.be.equal(data?.emailVerified) expect(currentAuthenticatedUser.displayName).to.be.null // due to mail/pw provider. - // expect(currentAuthenticatedUser.displayName).to.be.equal(data?.displayName) expect(currentAuthenticatedUser.photoURL).to.be.null // due to mail/pw provider. expect(data?.photoURL).to.be.empty // due to mail/pw provider. expect(new Date(String(currentAuthenticatedUser.metadata.creationTime)).valueOf()).to.be.equal( @@ -67,6 +66,7 @@ describe("Authentication", () => { const disabledRecord = await adminAuth.updateUser(user.uid, { disabled: true }) expect(disabledRecord.disabled).to.be.true + // Try to authenticate with the disabled user. await expect(signInWithEmailAndPassword(userAuth, user.data.email, userPassword)).to.be.rejectedWith( "Firebase: Error (auth/user-disabled)." ) @@ -79,18 +79,21 @@ describe("Authentication", () => { }) it("should not be possible to authenticate with an incorrect password", async () => { + // Try to authenticate with the wrong password. await expect(signInWithEmailAndPassword(userAuth, user.data.email, "wrongPassword")).to.be.rejectedWith( "Firebase: Error (auth/wrong-password)." ) }) it("should not be possible to authenticate with an incorrect email", async () => { + // Try to authenticate with the wrong email. await expect(signInWithEmailAndPassword(userAuth, "wrongEmail", userPassword)).to.be.rejected }) it("should not be possible to authenticate if Firebase is unreachable", async () => { // @todo mock unreachable firebase. }) + it("should not be possible to authenticate twice", async () => { // @todo Implement checks to prevent double authentication. }) diff --git a/packages/actions/test/utils/authentication.ts b/packages/actions/test/utils/authentication.ts index 8cfdcb53..a78da120 100644 --- a/packages/actions/test/utils/authentication.ts +++ b/packages/actions/test/utils/authentication.ts @@ -35,6 +35,7 @@ export const createNewFirebaseUserWithEmailAndPw = async ( * @param gmailRefreshToken - the GMail refresh token. * @dev You should have the GMail APIs for OAuth2.0 must be enabled and configured properly in order to get correct results. * @returns > - return the 6 digits verification code needed to complete the access with Github. + * @todo this method will not be used for testing right now. See PR #286 and #289 for info. */ export const getLastGithubVerificationCode = async ( gmailUserEmail: string, @@ -78,9 +79,9 @@ export const getLastGithubVerificationCode = async ( /** * Simulate callback to manage the data requested for Github OAuth2.0 device flow. * @param verification - the data from Github OAuth2.0 device flow. + * @todo this method will not be used for testing right now. See PR #286 and #289 for info. */ export const simulateOnVerification = async (verification: Verification): Promise => { - // NB. this method will not be used for testing right now. See PR #286 for info. // 0.A Prepare data and plugins. const { userEmail, githubUserPw, gmailClientId, gmailClientSecret, gmailRedirectUrl, gmailRefreshToken } = getAuthenticationConfiguration() @@ -198,9 +199,9 @@ export const simulateOnVerification = async (verification: Verification): Promis /** * Simulate callback to cancel authorization for Github OAuth2.0 device flow. * @param verification - the data from Github OAuth2.0 device flow. + * @todo this method will not be used for testing right now. See PR #286 and #289 for info. */ export const simulateCancelledOnVerification = async (verification: Verification): Promise => { - // NB. this method will not be used for testing right now. See PR #286 for info. // 0.A Prepare data and plugins. const { userEmail, githubUserPw, gmailClientId, gmailClientSecret, gmailRedirectUrl, gmailRefreshToken } = getAuthenticationConfiguration() @@ -311,9 +312,9 @@ export const simulateCancelledOnVerification = async (verification: Verification /** * Simulate callback sending an invalid device code for Github OAuth2.0 device flow. * @param verification - the data from Github OAuth2.0 device flow. + * @todo this method will not be used for testing right now. See PR #286 and #289 for info. */ export const simulateInvalidTokenOnVerification = async (verification: Verification): Promise => { - // NB. this method will not be used for testing right now. See PR #286 for info. // 0.A Prepare data and plugins. const { userEmail, githubUserPw, gmailClientId, gmailClientSecret, gmailRedirectUrl, gmailRefreshToken } = getAuthenticationConfiguration() @@ -418,10 +419,10 @@ export const simulateInvalidTokenOnVerification = async (verification: Verificat /** * Simulate callback for unreachable GitHub website for Github OAuth2.0 device flow. * @param verification - the data from Github OAuth2.0 device flow. + * @todo this method will not be used for testing right now. See PR #286 and #289 for info. */ /* eslint-disable @typescript-eslint/no-unused-vars */ export const simulateUnreachablePageOnVerification = async (verification: Verification): Promise => { - // NB. this method will not be used for testing right now. See PR #286 for info. puppeteerExtra.use(stealthMode()) puppeteerExtra.use(anonUserAgent({ stripHeadless: true })) @@ -474,6 +475,7 @@ export const simulateUnreachablePageOnVerification = async (verification: Verifi * @param userApp - the Firebase user Application instance. * @param clientId - the Github client id. * @returns > - the credential of the user after the handshake with Firebase. + * @todo this method will not be used for testing right now. See PR #286 and #289 for info. */ export const authenticateUserWithGithub = async (userApp: FirebaseApp, clientId: string): Promise => { const clientType = "oauth-app" diff --git a/packages/actions/test/utils/index.ts b/packages/actions/test/utils/index.ts index 7f9358d6..0da9c490 100644 --- a/packages/actions/test/utils/index.ts +++ b/packages/actions/test/utils/index.ts @@ -9,12 +9,4 @@ export { generatePseudoRandomStringOfNumbers } from "./configs" -export { - createNewFirebaseUserWithEmailAndPw, - getLastGithubVerificationCode, - simulateOnVerification, - authenticateUserWithGithub, - simulateCancelledOnVerification, - simulateUnreachablePageOnVerification, - simulateInvalidTokenOnVerification -} from "./authentication" +export { createNewFirebaseUserWithEmailAndPw } from "./authentication"