Skip to content

Impossible to test wrapped functions with App check #122

@LeMimit

Description

@LeMimit

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

  • Create a Callable function which check if context.app is defined
  • Try to pass an app object while calling a wrapped function
  • Get the the error Options object {"auth":{"uid":""},"app":{}} has invalid key "app"

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.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions