Closed esQmo closed 4 years ago
Hi @esQmo
Please make sure that you created a secret and added a role you your firebase credentials to use it.
The test function is trying to get the key but it's not finding it:
Create a new secret in Secret Manager and add a new version with the key generated above. Note that this requires Billing enabled.
This is explained in cloud-functions under this section called:
Encryption Key
Thanks,
Jongi
Hello @valduze I did everything mentionned in the ReadMe file and even the more detailed one updated recently. Still failing at that step
@esQmo, besides what @valduze mentioned, you need to ensure the steps specified at https://github.com/opentrace-community/opentrace-cloud-functions#test are done and you have the GOOGLE_APPLICATION_CREDENTIALS
variable set.
You can run this command to test whether the variable is set correctly:
node -e 'const admin = require("firebase-admin"); admin.initializeApp(); admin.auth().listUsers(1).then(_ => console.log(_))'
It should output:
{ users: [ ... ], pageToken: '...' }
@qtangs I have done all the steps, even started a new project.still stuck at the same step with the test! Can't past these 2 errors
@esQmo
cd https://github.com/opentrace-community/opentrace-cloud-functions/blob/master/functions/test/index.test.ts**
//import * as admin from "firebase-admin";
import config from "../src/config";
if (!process.env.GOOGLE_APPLICATION_CREDENTIALS) {
throw new Error("Environment variable GOOGLE_APPLICATION_CREDENTIALS is required to access Firebase. Refer to: https://cloud.google.com/docs/authentication/production ");
}
var admin = require("firebase-admin");
export const FunctionsTestWrapper = require("firebase-functions-test")({projectId: config.projectId});
if (admin.apps.length === 0) {
var serAcc = require(process.env.GOOGLE_APPLICATION_CREDENTIALS);
admin.initializeApp({credential: admin.credential.cert(serAcc), databaseURL: "https://{$PROJECT_ID}.firebaseio.com"});
}
@esQmo: hi, what steps.are you trying to do here? The firebase deploy or npm --prefix functions test?
Remember to run those 2 commands you need to run the export command for GOOGLE_APPLICATION_CREDENTIALS
export GOOGLE_APPLICATION_CREDENTIALS="path/to/your/service-account.json"
I'm trying to
npm --prefix function test
but only 2 tests succeed and 2 fails. Below are the errors:I'm certain that the buckets are valid and the authorization are also given to the user. I'm on Windows.
Please assist.
Thanks