Skip to content

Allow passing context.app to wrapped callable functions. #123

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 6, 2021

Conversation

taeold
Copy link
Contributor

@taeold taeold commented Oct 4, 2021

Change allows users to pass app property in the mocked callable context, e.g.

export myFunc = functions.https.onCall((data, context) => {
  if (context.app == undefined) {
    throw new functions.https.HttpsError(
        'failed-precondition',
        'The function must be called from an App Check verified app.')
  }
});

Before

wrap(myFunc)('data', { app: { appId: 'my-app-123' }});
// => Options object {"auth":{"uid":""},"app":{}} has invalid key "app"

After

wrap(myFunc)('data', { app: { appId: 'my-app-123' }});
// no error

The diff on main.spec.ts looks terrible - I'm just adding a few test cases for callable functions, and indenting the ones that existed before.

Fixes #122

@taeold taeold requested review from colerogers and inlined October 4, 2021 22:07
@taeold taeold merged commit 1e3ac7c into master Oct 6, 2021
taeold added a commit that referenced this pull request Oct 6, 2021
taeold added a commit that referenced this pull request Oct 6, 2021
taeold added a commit that referenced this pull request Oct 6, 2021

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Impossible to test wrapped functions with App check
4 participants