firebase / firebase-functions-test

MIT License
232 stars 48 forks source link

Way to init without using pathToServiceAccountKey? #52

Closed garyforsterio closed 4 years ago

garyforsterio commented 4 years ago

Version info

firebase-functions-test: 0.1.7 firebase-functions: 3.0.1 firebase-admin: 8.1.0

Test case

const test = require('firebase-functions-test')({
  databaseURL: 'https://.....firebaseio.com',
  storageBucket: '....appspot.com',
  projectId: 'project-name...',
}, 'etc/keys/key.json');
// Can we remove this ^ and somehow use environment variables in CI environment?

Steps to reproduce

  1. Import and initialize firebase-functions-test
  2. Wonder how and if it's possible to not have to include key in source control. I.e. if we can use an environment variable like to firebase CLI --token to handle authentication.

Expected behavior

The it should be required to commit keys into source control to run testing in CI

Actual behavior

I can't find any documentation on this, so I'm opening an issue here. Sorry if it's in the wrong place

laurenzlong commented 4 years ago

Hey @garyforsterio good question. That parameter sets the GOOGLE_APPLICATION_CREDENTIAL environment variable (see https://github.com/firebase/firebase-functions-test/blob/master/src/lifecycle.ts#L65), in order to initialize firebase-admin.

Here is the documentation on how the various credentials that are accepted by firebase-admin: https://firebase.google.com/docs/admin/setup#initialize-sdk. It doesn't appear like there's a way to supply a token in an environment variable. You can make a feature request for firebase-admin here: https://github.com/firebase/firebase-admin-node