Skip to content
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

Add mockUserToken support for database emulator. #4792

Merged
merged 22 commits into from Apr 29, 2021

Conversation

yuchenshi
Copy link
Member

@yuchenshi yuchenshi commented Apr 15, 2021

POC for new API with RTDB first.

Open questions

With this implementation, it doesn't look too challenging to support changing the mock token through repeated calls of useEmulator(host, port, {mockUserToken}) (provided that host and port stays the same). However, there are further implications for the underlying requests (e.g. pending requests or retries). I'd prefer we have a discussion before proceeding with a separate PR.

Testing

Unit testing in @firebase/util done, manually tested end to end for @firebase/database

API Changes

Internally approved. See go/firebase-rules-unit-testing-next-api (Googlers only)

@changeset-bot
Copy link

changeset-bot bot commented Apr 15, 2021

🦋 Changeset detected

Latest commit: dc72577

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 37 packages
Name Type
@firebase/database Minor
firebase Minor
@firebase/util Minor
@firebase/rules-unit-testing Patch
@firebase/analytics Patch
@firebase/app Patch
@firebase/component Patch
@firebase/firestore Patch
@firebase/installations Patch
@firebase/messaging Patch
@firebase/performance Patch
@firebase/remote-config Patch
@firebase/storage Patch
@firebase/functions Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

/* eslint-disable camelcase */

describe('createMockUserToken()', () => {
it('creates a well-formed JWT', () => {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Migrated from an old rules unit testing library test

@google-oss-bot
Copy link
Contributor

google-oss-bot commented Apr 15, 2021

Size Analysis Report

Affected Products

No changes between base commit (d422436) and head commit (cbf6c03).

@google-oss-bot
Copy link
Contributor

google-oss-bot commented Apr 22, 2021

Binary Size Report

Affected SDKs

  • @firebase/analytics

    Type Base (d422436) Head (cbf6c03) Diff
    esm2017 ? 18.7 kB ? (?)
    main ? 24.2 kB ? (?)
    module ? 23.4 kB ? (?)
  • @firebase/api-documenter

    Type Base (d422436) Head (cbf6c03) Diff
    main ? 3.72 kB ? (?)
  • @firebase/app

    Type Base (d422436) Head (cbf6c03) Diff
    browser ? 10.8 kB ? (?)
    esm2017 ? 9.57 kB ? (?)
    lite ? 8.88 kB ? (?)
    lite-esm2017 ? 7.87 kB ? (?)
    main ? 9.93 kB ? (?)
    module ? 10.8 kB ? (?)
    react-native ? 9.64 kB ? (?)
  • @firebase/auth

    Type Base (d422436) Head (cbf6c03) Diff
    browser ? 181 kB ? (?)
    main ? 181 kB ? (?)
    module ? 181 kB ? (?)
  • @firebase/component

    Type Base (d422436) Head (cbf6c03) Diff
    browser ? 7.24 kB ? (?)
    esm2017 ? 5.55 kB ? (?)
    main ? 7.57 kB ? (?)
    module ? 7.24 kB ? (?)
  • @firebase/database

    Type Base (d422436) Head (cbf6c03) Diff
    browser ? 296 kB ? (?)
    esm2017 ? 265 kB ? (?)
    main ? 298 kB ? (?)
    module ? 296 kB ? (?)
  • @firebase/database-compat

    Type Base (d422436) Head (cbf6c03) Diff
    browser ? 86.3 kB ? (?)
    main ? 102 kB ? (?)
    module ? 86.3 kB ? (?)
  • @firebase/database-exp

    Type Base (d422436) Head (cbf6c03) Diff
    browser ? 246 kB ? (?)
    main ? 278 kB ? (?)
    module ? 246 kB ? (?)
  • @firebase/firestore

    Type Base (d422436) Head (cbf6c03) Diff
    browser ? 283 kB ? (?)
    esm2017 ? 225 kB ? (?)
    main ? 529 kB ? (?)
    module ? 283 kB ? (?)
    react-native ? 225 kB ? (?)
  • @firebase/firestore-compat

    Type Base (d422436) Head (cbf6c03) Diff
    browser ? 28.4 kB ? (?)
    main ? 37.4 kB ? (?)
    module ? 28.4 kB ? (?)
    react-native ? 28.1 kB ? (?)
  • @firebase/firestore-exp

    Type Base (d422436) Head (cbf6c03) Diff
    browser ? 223 kB ? (?)
    main ? 505 kB ? (?)
    module ? 223 kB ? (?)
    react-native ? 223 kB ? (?)
  • @firebase/firestore-lite

    Type Base (d422436) Head (cbf6c03) Diff
    browser ? 71.4 kB ? (?)
    main ? 145 kB ? (?)
    module ? 71.4 kB ? (?)
    react-native ? 71.6 kB ? (?)
  • @firebase/firestore/bundle

    Type Base (d422436) Head (cbf6c03) Diff
    browser ? 289 kB ? (?)
    esm2017 ? 175 kB ? (?)
    main ? 525 kB ? (?)
    module ? 289 kB ? (?)
    react-native ? 175 kB ? (?)
  • @firebase/firestore/memory

    Type Base (d422436) Head (cbf6c03) Diff
    browser ? 215 kB ? (?)
    esm2017 ? 171 kB ? (?)
    main ? 323 kB ? (?)
    module ? 215 kB ? (?)
    react-native ? 171 kB ? (?)
  • @firebase/firestore/memory-bundle

    Type Base (d422436) Head (cbf6c03) Diff
    browser ? 223 kB ? (?)
    esm2017 ? 175 kB ? (?)
    main ? 320 kB ? (?)
    module ? 223 kB ? (?)
    react-native ? 175 kB ? (?)
  • @firebase/functions

    Type Base (d422436) Head (cbf6c03) Diff
    browser ? 10.6 kB ? (?)
    esm2017 ? 8.15 kB ? (?)
    main ? 11.0 kB ? (?)
    module ? 10.6 kB ? (?)
  • @firebase/installations

    Type Base (d422436) Head (cbf6c03) Diff
    esm2017 ? 16.6 kB ? (?)
    main ? 22.2 kB ? (?)
    module ? 21.6 kB ? (?)
  • @firebase/logger

    Type Base (d422436) Head (cbf6c03) Diff
    esm2017 ? 3.25 kB ? (?)
    main ? 5.38 kB ? (?)
    module ? 4.65 kB ? (?)
  • @firebase/messaging

    Type Base (d422436) Head (cbf6c03) Diff
    esm2017 ? 26.2 kB ? (?)
    main ? 34.9 kB ? (?)
    module ? 34.4 kB ? (?)
  • @firebase/performance

    Type Base (d422436) Head (cbf6c03) Diff
    browser ? 27.7 kB ? (?)
    esm2017 ? 25.9 kB ? (?)
    main ? 28.0 kB ? (?)
    module ? 27.7 kB ? (?)
  • @firebase/polyfill

    Type Base (d422436) Head (cbf6c03) Diff
    main ? 747 B ? (?)
    module ? 705 B ? (?)
  • @firebase/remote-config

    Type Base (d422436) Head (cbf6c03) Diff
    browser ? 22.4 kB ? (?)
    esm2017 ? 17.4 kB ? (?)
    main ? 23.0 kB ? (?)
    module ? 22.4 kB ? (?)
  • @firebase/rules-unit-testing

    Type Base (d422436) Head (cbf6c03) Diff
    main ? 12.6 kB ? (?)
  • @firebase/storage

    Type Base (d422436) Head (cbf6c03) Diff
    browser ? 63.4 kB ? (?)
    esm2017 ? 54.6 kB ? (?)
    main ? 63.8 kB ? (?)
    module ? 63.4 kB ? (?)
  • @firebase/storage-compat

    Type Base (d422436) Head (cbf6c03) Diff
    browser ? 10.2 kB ? (?)
    main ? 29.1 kB ? (?)
    module ? 10.2 kB ? (?)
  • @firebase/storage-exp

    Type Base (d422436) Head (cbf6c03) Diff
    browser ? 51.5 kB ? (?)
    main ? 52.6 kB ? (?)
    module ? 51.5 kB ? (?)
  • @firebase/util

    Type Base (d422436) Head (cbf6c03) Diff
    browser ? 21.0 kB ? (?)
    esm2017 ? 19.7 kB ? (?)
    main ? 25.5 kB ? (?)
    module ? 21.0 kB ? (?)
  • @firebase/webchannel-wrapper

    Type Base (d422436) Head (cbf6c03) Diff
    esm2017 ? 39.5 kB ? (?)
    main ? 46.9 kB ? (?)
    module ? 40.8 kB ? (?)
  • firebase

    Click to show 15 binary size changes.
    Type Base (d422436) Head (cbf6c03) Diff
    firebase-analytics.js ? 35.8 kB ? (?)
    firebase-app.js ? 21.2 kB ? (?)
    firebase-auth.js ? 177 kB ? (?)
    firebase-database.js ? 187 kB ? (?)
    firebase-firestore.js ? 328 kB ? (?)
    firebase-firestore.memory.js ? 262 kB ? (?)
    firebase-functions.js ? 10.7 kB ? (?)
    firebase-installations.js ? 19.3 kB ? (?)
    firebase-messaging.js ? 41.0 kB ? (?)
    firebase-performance-standalone.es2017.js ? 72.9 kB ? (?)
    firebase-performance-standalone.js ? 49.2 kB ? (?)
    firebase-performance.js ? 38.3 kB ? (?)
    firebase-remote-config.js ? 36.9 kB ? (?)
    firebase-storage.js ? 41.6 kB ? (?)
    firebase.js ? 874 kB ? (?)

Test Logs

packages/database/src/api/Database.ts Outdated Show resolved Hide resolved
packages/database/src/exp/Database.ts Outdated Show resolved Hide resolved
packages/database/src/exp/Database.ts Outdated Show resolved Hide resolved
packages/util/test/emulator.test.ts Outdated Show resolved Hide resolved
@schmidt-sebastian schmidt-sebastian removed their assignment Apr 22, 2021
schmidt-sebastian and others added 4 commits April 23, 2021 09:55
Co-authored-by: Sebastian Schmidt <mrschmidt@google.com>
Co-authored-by: Sebastian Schmidt <mrschmidt@google.com>
@yuchenshi yuchenshi assigned yuchenshi and unassigned samtstern Apr 23, 2021
@yuchenshi yuchenshi changed the base branch from master to mrschmidt/emulator April 24, 2021 02:06
@github-actions
Copy link
Contributor

github-actions bot commented Apr 24, 2021

Changeset File Check ✅

  • No modified packages are missing from the changeset file.
  • No changeset formatting errors detected.

Base automatically changed from mrschmidt/emulator to master April 27, 2021 16:33
@yuchenshi yuchenshi assigned samtstern and unassigned yuchenshi Apr 27, 2021
@yuchenshi yuchenshi assigned Feiyang1 and hsubox76 and unassigned samtstern Apr 28, 2021
packages/util/src/emulator.ts Outdated Show resolved Hide resolved
packages/util/src/emulator.ts Show resolved Hide resolved
@yuchenshi yuchenshi requested a review from Feiyang1 April 29, 2021 20:37
@yuchenshi yuchenshi merged commit ac4ad08 into master Apr 29, 2021
@yuchenshi yuchenshi deleted the ys/mockUserToken-database branch April 29, 2021 21:36
@google-oss-bot google-oss-bot mentioned this pull request May 4, 2021
@firebase firebase locked and limited conversation to collaborators May 30, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants