firebase / firebase-functions-test

MIT License
232 stars 48 forks source link

Impossible to test wrapped functions with App check #122

Closed LeMimit closed 2 years ago

LeMimit commented 2 years ago

Version info

firebase-functions-test: 0.3.2

firebase-functions: 3.15.5

firebase-admin: 9.11.1

Test case

I would like to test a callable function which check if there is an app context because App check is activated on my project.

The following function is called at the beginning of the callable function:

export function verifyAppCheck(context: functions.https.CallableContext) : void {
  if (context.app == undefined) {
    throw new functions.https.HttpsError("unauthenticated", "Unauthorized Access");
  }
}

For now it is impossible to test my function because the wrap function from firebase-functions-test do the following call

if (isCallableFunction) {
  _checkOptionValidity(['auth', 'instanceIdToken', 'rawRequest'], options);
  let callableContextOptions = options;
  context = Object.assign({}, callableContextOptions);
}

It is impossble to specify an app object.

Steps to reproduce

Expected behavior

Be able to specify a fake app object to test a callable function when using App check.

Actual behavior

Get an error while trying to specify a fake app object.

taeold commented 2 years ago

@LeMimit Thanks for the report. Yes, it looks like wrap function is incompatible with AppCheck integration we've introduced. We will fix this in the next release.

LeMimit commented 2 years ago

@taeold Thanks for your answer. Looking forward the next release then !

fiveable-jferg commented 2 years ago

Is there any sort of ETA for when this might be fixed? It's kind of got me blocked on some things. :-(

taeold commented 2 years ago

Sorry for the delays folks. I will try to get the new release by end of week.

taeold commented 2 years ago

This is available in v0.3.3!

LeMimit commented 2 years ago

Thanks a lot @taeold . I will update my dependencies 👍🏻