Skip to content

Commit

Permalink
fix: wrong usage of secrets in development test pipeline
Browse files Browse the repository at this point in the history
  • Loading branch information
0xjei committed Jan 23, 2023
1 parent ae94bcc commit e122c19
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
14 changes: 7 additions & 7 deletions packages/actions/test/e2e/00-authentication.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
simulateOnVerification
} from "../utils"
import { TestingEnvironment } from "../../types"
import { fakeUsersData } from "../data/samples"

/**
* E2E authentication tests.
Expand All @@ -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
Expand Down Expand Up @@ -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(
Expand All @@ -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)
})
})

Expand Down
10 changes: 7 additions & 3 deletions packages/actions/test/e2e/02-contribution.test.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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

Expand Down

0 comments on commit e122c19

Please sign in to comment.