Search code examples
firebasegoogle-cloud-firestorefirebase-security

How to unit test firestore rules with token.firebase.identities


Just trying to test rules with google login and phone login e.g. request.auth.token.firebase.identities["google.com"], But I can't find any document about firebase.initializeTestApp from '@firebase/rules-unit-testing' package. The offical video only mentioned about initialize with userId and email. Anyone know How to test this kind of rules?


Solution

  • Seems initializeTestApp is outdated, Better use version 9 javascript SDK instead

    const alice = testEnv.authenticatedContext("alice", {
          firebase: {
            sign_in_provider: "google.com",
            identities: {
              "phone": ["test"]
            }
          }
        });