From e122c19af838a37e160080fc6c2960f0c4cba856 Mon Sep 17 00:00:00 2001 From: Jeeiii Date: Mon, 23 Jan 2023 16:15:58 +0100 Subject: [PATCH] fix: wrong usage of secrets in development test pipeline --- .../actions/test/e2e/00-authentication.test.ts | 14 +++++++------- packages/actions/test/e2e/02-contribution.test.ts | 10 +++++++--- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/packages/actions/test/e2e/00-authentication.test.ts b/packages/actions/test/e2e/00-authentication.test.ts index d67e2669..c4415dda 100644 --- a/packages/actions/test/e2e/00-authentication.test.ts +++ b/packages/actions/test/e2e/00-authentication.test.ts @@ -14,6 +14,7 @@ import { simulateOnVerification } from "../utils" import { TestingEnvironment } from "../../types" +import { fakeUsersData } from "../data/samples" /** * E2E authentication tests. @@ -29,17 +30,10 @@ describe("Authentication", () => { beforeAll(async () => { // Get and assign configs. - const { userEmail } = getAuthenticationConfiguration() - userEmailAddress = userEmail - const { userApp } = initializeUserServices() firebaseUserApp = userApp }) - beforeEach(async () => { - // Given: establish a known state to the system before each case. - }) - if (envType === TestingEnvironment.PRODUCTION) /** * Remote production workflow @@ -106,6 +100,11 @@ describe("Authentication", () => { * These tests do not use secrets. Please, refer to the production tests for the real Firebase Authentication service test. */ else describe("Development", () => { + beforeAll(async () => { + // Get and assign configs. + userEmailAddress = fakeUsersData.fakeUser1.data.email + }) + it("authenticate a new user using email and password", async () => { // Development workflow: authenticate use through email/pw authentication when using the emulator. const userFirebaseCredentials = await createNewFirebaseUserWithEmailAndPw( @@ -120,6 +119,7 @@ describe("Authentication", () => { expect(currentAuthUser.uid.length > 0).to.be.equal(true) expect(userFirebaseCredentials.user.uid).to.be.equal(currentAuthUser.uid) + expect(userFirebaseCredentials.user.email).to.be.equal(currentAuthUser.email) }) }) diff --git a/packages/actions/test/e2e/02-contribution.test.ts b/packages/actions/test/e2e/02-contribution.test.ts index 5c85ee76..84f61eb6 100644 --- a/packages/actions/test/e2e/02-contribution.test.ts +++ b/packages/actions/test/e2e/02-contribution.test.ts @@ -1,7 +1,7 @@ import chai from "chai" import chaiAsPromised from "chai-as-promised" import { getOpenedCeremonies, getCeremonyCircuits } from "../../src" -import { fakeCeremoniesData, fakeCircuitsData } from "../data/samples" +import { fakeCeremoniesData, fakeCircuitsData, fakeUsersData } from "../data/samples" import { initializeAdminServices, initializeUserServices, @@ -25,13 +25,17 @@ describe("Contribution", () => { // Initialize admin and user services. const { adminFirestore, adminAuth } = initializeAdminServices() const { userApp, userFirestore } = initializeUserServices() - const { userEmail, githubClientId } = getAuthenticationConfiguration() + const { githubClientId } = getAuthenticationConfiguration() beforeAll(async () => { // Authenticate user. const userFirebaseCredentials = envType === TestingEnvironment.DEVELOPMENT - ? await createNewFirebaseUserWithEmailAndPw(userApp, userEmail, generatePseudoRandomStringOfNumbers(24)) + ? await createNewFirebaseUserWithEmailAndPw( + userApp, + fakeUsersData.fakeUser1.data.email, + generatePseudoRandomStringOfNumbers(24) + ) : await authenticateUserWithGithub(userApp, githubClientId) userId = userFirebaseCredentials.user.uid