-
Notifications
You must be signed in to change notification settings - Fork 1k
Closed
Description
When running the node admin SDK locally with an Authentication Emulator, user operations allow multifactor data on write, but do not reflect multifactor data on read.
[REQUIRED] Environment info
firebase-tools:
% ./node_modules/.bin/firebase --version
9.5.0
Platform:
% node -v
v12.16.3
% npm -v
6.14.4
% ./node_modules/.bin/tsc -v
Version 4.1.3
% uname -mrsv
Darwin 20.2.0 Darwin Kernel Version 20.2.0: Wed Dec 2 20:39:59 PST 2020; root:xnu-7195.60.75~1/RELEASE_X86_64 x86_64
[REQUIRED] Test case
Assumes a typescript project with firebase-admin
and jest
installed, and firebase-tools
installed as a dev dependency.
import firebaseAdmin from 'firebase-admin';
let app: firebaseAdmin.app.App;
beforeAll(() => {
app = firebaseAdmin.initializeApp({
projectId: 'run-me-in-an-emulator',
});
});
afterAll(async () => {
await app.delete();
});
test.only('Firebase Authentication Emulator Returns MultiFactorSettings Data', async () => {
const user = await app.auth().createUser({
email: `[email protected]`,
emailVerified: true,
password: undefined,
multiFactor: {
enrolledFactors: [
{
phoneNumber: '+12813308004',
factorId: 'phone',
displayName: 'Mobile',
} as firebaseAdmin.auth.CreatePhoneMultiFactorInfoRequest,
],
},
});
expect(user.multiFactor).toBeTruthy();
});
[REQUIRED] Steps to reproduce
Run the following test with the node.js
admin SDK using a local firebase authentication emulator, something like:
./node_modules/.bin/firebase emulators:exec 'npm run test firebaseRepro.test.ts'
The test does the following:
- Create a user with multi-factor info using the node admin sdk.
[REQUIRED] Expected behavior
UserRecord object is returned with a non-null multiFactor
MultiFactorSettings object.
[REQUIRED] Actual behavior
UserRecord object is returned with an undefined multiFactor
MultiFactorSettings object.
% ./node_modules/.bin/firebase emulators:exec 'npm run test firebaseRepro.test.ts'
i emulators: Starting emulators: auth, pubsub
i pubsub: Pub/Sub Emulator logging to pubsub-debug.log
i Running script: npm run test firebaseRepro.test.ts
> jest "firebaseRepro.test.ts"
FAIL src/firebaseRepro.test.ts (5.781 s)
✕ Firebase Authentication Emulator Returns MultiFactorSettings Data (74 ms)
● Firebase Authentication Emulator Returns MultiFactorSettings Data
expect(received).toBeTruthy()
Received: undefined
29 | });
30 |
> 31 | expect(user.multiFactor).toBeTruthy();
| ^
32 | });
33 |
at src/firebaseRepro.test.ts:31:30
at fulfilled (src/firebaseRepro.test.ts:5:58)
Test Suites: 1 failed, 1 total
Tests: 1 failed, 1 total
Snapshots: 0 total
Time: 5.818 s, estimated 7 s
Ran all test suites matching /firebaseRepro.test.ts/i.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! test: `jest "firebaseRepro.test.ts"`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the test script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/wokkaflokka/.npm/_logs/2021-02-24T00_05_17_664Z-debug.log
⚠ Script exited unsuccessfully (code 1)
i emulators: Shutting down emulators.
i pubsub: Stopping Pub/Sub Emulator
i auth: Stopping Authentication Emulator
i hub: Stopping emulator hub
Error: Script "npm run test firebaseRepro.test.ts" exited with code 1
Having trouble? Try firebase [command] --help