@dereekb/firebase-server 12.6.21 → 13.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/index.cjs.js +2937 -0
- package/index.esm.js +2775 -0
- package/mailgun/index.cjs.js +48 -0
- package/mailgun/index.esm.js +46 -0
- package/mailgun/package.json +26 -6
- package/model/index.cjs.js +5298 -0
- package/model/index.d.ts +1 -0
- package/model/index.esm.js +5161 -0
- package/model/package.json +31 -3
- package/model/src/lib/notification/notification.module.d.ts +10 -10
- package/model/src/lib/storagefile/storagefile.task.service.handler.d.ts +3 -14
- package/package.json +48 -27
- package/src/lib/auth/auth.context.d.ts +1 -1
- package/src/lib/auth/auth.service.d.ts +1 -1
- package/src/lib/function/assert.d.ts +2 -2
- package/src/lib/function/context.d.ts +1 -1
- package/src/lib/index.d.ts +1 -0
- package/src/lib/nest/app.d.ts +1 -1
- package/src/lib/nest/development/development.app.function.d.ts +1 -2
- package/src/lib/nest/function/call.d.ts +1 -1
- package/src/lib/nest/function/context.d.ts +0 -4
- package/src/lib/nest/function/index.d.ts +0 -1
- package/src/lib/nest/function/nest.d.ts +1 -1
- package/src/lib/nest/function/v2/blocking.d.ts +3 -2
- package/src/lib/nest/model/crud.assert.function.d.ts +0 -4
- package/src/lib/storage/storage.d.ts +1 -1
- package/src/lib/type.d.ts +9 -0
- package/test/index.cjs.js +1324 -0
- package/test/index.d.ts +1 -0
- package/test/index.esm.js +1247 -0
- package/test/package.json +34 -3
- package/test/src/lib/firebase/firebase.admin.auth.d.ts +22 -13
- package/test/src/lib/firebase/firebase.admin.collection.d.ts +6 -6
- package/test/src/lib/firebase/firebase.admin.d.ts +10 -10
- package/test/src/lib/firebase/firebase.admin.function.d.ts +9 -9
- package/test/src/lib/firebase/firebase.admin.nest.d.ts +8 -8
- package/test/src/lib/firebase/firebase.admin.nest.function.d.ts +9 -9
- package/test/src/lib/firebase/firebase.test.d.ts +30 -0
- package/test/src/lib/firebase/index.d.ts +1 -1
- package/test/src/lib/firestore/firestore.admin.d.ts +3 -3
- package/test/src/lib/firestore/firestore.d.ts +2 -2
- package/test/src/lib/storage/storage.admin.d.ts +3 -3
- package/test/src/lib/storage/storage.d.ts +2 -2
- package/zoho/LICENSE +1 -1
- package/zoho/index.d.ts +1 -0
- package/zoho/index.esm.js +2 -2
- package/zoho/package.json +12 -8
- package/CHANGELOG.md +0 -2233
- package/mailgun/src/index.js +0 -5
- package/mailgun/src/index.js.map +0 -1
- package/mailgun/src/lib/auth.mailgun.js +0 -41
- package/mailgun/src/lib/auth.mailgun.js.map +0 -1
- package/mailgun/src/lib/index.js +0 -5
- package/mailgun/src/lib/index.js.map +0 -1
- package/model/src/index.js +0 -5
- package/model/src/index.js.map +0 -1
- package/model/src/lib/index.js +0 -7
- package/model/src/lib/index.js.map +0 -1
- package/model/src/lib/mailgun/index.js +0 -5
- package/model/src/lib/mailgun/index.js.map +0 -1
- package/model/src/lib/mailgun/notification.send.service.mailgun.js +0 -68
- package/model/src/lib/mailgun/notification.send.service.mailgun.js.map +0 -1
- package/model/src/lib/notification/index.js +0 -20
- package/model/src/lib/notification/index.js.map +0 -1
- package/model/src/lib/notification/notification.action.init.service.js +0 -230
- package/model/src/lib/notification/notification.action.init.service.js.map +0 -1
- package/model/src/lib/notification/notification.action.service.js +0 -1487
- package/model/src/lib/notification/notification.action.service.js.map +0 -1
- package/model/src/lib/notification/notification.config.js +0 -13
- package/model/src/lib/notification/notification.config.js.map +0 -1
- package/model/src/lib/notification/notification.config.service.js +0 -60
- package/model/src/lib/notification/notification.config.service.js.map +0 -1
- package/model/src/lib/notification/notification.create.run.js +0 -59
- package/model/src/lib/notification/notification.create.run.js.map +0 -1
- package/model/src/lib/notification/notification.error.js +0 -87
- package/model/src/lib/notification/notification.error.js.map +0 -1
- package/model/src/lib/notification/notification.expedite.service.js +0 -112
- package/model/src/lib/notification/notification.expedite.service.js.map +0 -1
- package/model/src/lib/notification/notification.module.js +0 -106
- package/model/src/lib/notification/notification.module.js.map +0 -1
- package/model/src/lib/notification/notification.send.js +0 -3
- package/model/src/lib/notification/notification.send.js.map +0 -1
- package/model/src/lib/notification/notification.send.service.js +0 -10
- package/model/src/lib/notification/notification.send.service.js.map +0 -1
- package/model/src/lib/notification/notification.send.service.notificationsummary.js +0 -104
- package/model/src/lib/notification/notification.send.service.notificationsummary.js.map +0 -1
- package/model/src/lib/notification/notification.send.service.text.js +0 -29
- package/model/src/lib/notification/notification.send.service.text.js.map +0 -1
- package/model/src/lib/notification/notification.task.service.handler.js +0 -65
- package/model/src/lib/notification/notification.task.service.handler.js.map +0 -1
- package/model/src/lib/notification/notification.task.service.js +0 -10
- package/model/src/lib/notification/notification.task.service.js.map +0 -1
- package/model/src/lib/notification/notification.task.service.util.js +0 -27
- package/model/src/lib/notification/notification.task.service.util.js.map +0 -1
- package/model/src/lib/notification/notification.task.subtask.handler.js +0 -256
- package/model/src/lib/notification/notification.task.subtask.handler.js.map +0 -1
- package/model/src/lib/notification/notification.util.js +0 -478
- package/model/src/lib/notification/notification.util.js.map +0 -1
- package/model/src/lib/storagefile/index.js +0 -12
- package/model/src/lib/storagefile/index.js.map +0 -1
- package/model/src/lib/storagefile/storagefile.action.init.service.js +0 -155
- package/model/src/lib/storagefile/storagefile.action.init.service.js.map +0 -1
- package/model/src/lib/storagefile/storagefile.action.server.js +0 -797
- package/model/src/lib/storagefile/storagefile.action.server.js.map +0 -1
- package/model/src/lib/storagefile/storagefile.error.js +0 -106
- package/model/src/lib/storagefile/storagefile.error.js.map +0 -1
- package/model/src/lib/storagefile/storagefile.module.js +0 -64
- package/model/src/lib/storagefile/storagefile.module.js.map +0 -1
- package/model/src/lib/storagefile/storagefile.task.service.handler.js +0 -287
- package/model/src/lib/storagefile/storagefile.task.service.handler.js.map +0 -1
- package/model/src/lib/storagefile/storagefile.upload.service.initializer.js +0 -180
- package/model/src/lib/storagefile/storagefile.upload.service.initializer.js.map +0 -1
- package/model/src/lib/storagefile/storagefile.upload.service.js +0 -10
- package/model/src/lib/storagefile/storagefile.upload.service.js.map +0 -1
- package/model/src/lib/storagefile/storagefile.util.js +0 -54
- package/model/src/lib/storagefile/storagefile.util.js.map +0 -1
- package/src/index.js +0 -5
- package/src/index.js.map +0 -1
- package/src/lib/auth/auth.context.js +0 -13
- package/src/lib/auth/auth.context.js.map +0 -1
- package/src/lib/auth/auth.service.error.js +0 -34
- package/src/lib/auth/auth.service.error.js.map +0 -1
- package/src/lib/auth/auth.service.js +0 -427
- package/src/lib/auth/auth.service.js.map +0 -1
- package/src/lib/auth/auth.util.js +0 -23
- package/src/lib/auth/auth.util.js.map +0 -1
- package/src/lib/auth/index.js +0 -8
- package/src/lib/auth/index.js.map +0 -1
- package/src/lib/env/env.service.js +0 -7
- package/src/lib/env/env.service.js.map +0 -1
- package/src/lib/env/index.js +0 -5
- package/src/lib/env/index.js.map +0 -1
- package/src/lib/firestore/array.js +0 -34
- package/src/lib/firestore/array.js.map +0 -1
- package/src/lib/firestore/driver.accessor.batch.js +0 -93
- package/src/lib/firestore/driver.accessor.batch.js.map +0 -1
- package/src/lib/firestore/driver.accessor.default.js +0 -62
- package/src/lib/firestore/driver.accessor.default.js.map +0 -1
- package/src/lib/firestore/driver.accessor.js +0 -50
- package/src/lib/firestore/driver.accessor.js.map +0 -1
- package/src/lib/firestore/driver.accessor.transaction.js +0 -96
- package/src/lib/firestore/driver.accessor.transaction.js.map +0 -1
- package/src/lib/firestore/driver.js +0 -14
- package/src/lib/firestore/driver.js.map +0 -1
- package/src/lib/firestore/driver.query.js +0 -55
- package/src/lib/firestore/driver.query.js.map +0 -1
- package/src/lib/firestore/firestore.js +0 -10
- package/src/lib/firestore/firestore.js.map +0 -1
- package/src/lib/firestore/increment.js +0 -17
- package/src/lib/firestore/increment.js.map +0 -1
- package/src/lib/firestore/index.js +0 -9
- package/src/lib/firestore/index.js.map +0 -1
- package/src/lib/function/assert.js +0 -68
- package/src/lib/function/assert.js.map +0 -1
- package/src/lib/function/context.js +0 -14
- package/src/lib/function/context.js.map +0 -1
- package/src/lib/function/error.auth.js +0 -25
- package/src/lib/function/error.auth.js.map +0 -1
- package/src/lib/function/error.js +0 -221
- package/src/lib/function/error.js.map +0 -1
- package/src/lib/function/index.js +0 -9
- package/src/lib/function/index.js.map +0 -1
- package/src/lib/function/type.js +0 -3
- package/src/lib/function/type.js.map +0 -1
- package/src/lib/index.js +0 -11
- package/src/lib/index.js.map +0 -1
- package/src/lib/nest/app.js +0 -114
- package/src/lib/nest/app.js.map +0 -1
- package/src/lib/nest/auth/auth.module.js +0 -60
- package/src/lib/nest/auth/auth.module.js.map +0 -1
- package/src/lib/nest/auth/auth.util.js +0 -72
- package/src/lib/nest/auth/auth.util.js.map +0 -1
- package/src/lib/nest/auth/index.js +0 -6
- package/src/lib/nest/auth/index.js.map +0 -1
- package/src/lib/nest/development/development.app.function.js +0 -38
- package/src/lib/nest/development/development.app.function.js.map +0 -1
- package/src/lib/nest/development/development.assert.function.js +0 -3
- package/src/lib/nest/development/development.assert.function.js.map +0 -1
- package/src/lib/nest/development/development.function.js +0 -41
- package/src/lib/nest/development/development.function.js.map +0 -1
- package/src/lib/nest/development/development.schedule.function.error.js +0 -35
- package/src/lib/nest/development/development.schedule.function.error.js.map +0 -1
- package/src/lib/nest/development/development.schedule.function.js +0 -54
- package/src/lib/nest/development/development.schedule.function.js.map +0 -1
- package/src/lib/nest/development/index.js +0 -9
- package/src/lib/nest/development/index.js.map +0 -1
- package/src/lib/nest/env/env.service.js +0 -19
- package/src/lib/nest/env/env.service.js.map +0 -1
- package/src/lib/nest/env/env.util.js +0 -12
- package/src/lib/nest/env/env.util.js.map +0 -1
- package/src/lib/nest/env/index.js +0 -6
- package/src/lib/nest/env/index.js.map +0 -1
- package/src/lib/nest/firebase/firebase.module.js +0 -17
- package/src/lib/nest/firebase/firebase.module.js.map +0 -1
- package/src/lib/nest/firebase/index.js +0 -5
- package/src/lib/nest/firebase/index.js.map +0 -1
- package/src/lib/nest/firestore/firestore.module.js +0 -86
- package/src/lib/nest/firestore/firestore.module.js.map +0 -1
- package/src/lib/nest/firestore/index.js +0 -5
- package/src/lib/nest/firestore/index.js.map +0 -1
- package/src/lib/nest/function/call.js +0 -46
- package/src/lib/nest/function/call.js.map +0 -1
- package/src/lib/nest/function/context.js +0 -79
- package/src/lib/nest/function/context.js.map +0 -1
- package/src/lib/nest/function/index.js +0 -10
- package/src/lib/nest/function/index.js.map +0 -1
- package/src/lib/nest/function/nest.js +0 -17
- package/src/lib/nest/function/nest.js.map +0 -1
- package/src/lib/nest/function/schedule.js +0 -8
- package/src/lib/nest/function/schedule.js.map +0 -1
- package/src/lib/nest/function/v1/call.d.ts +0 -59
- package/src/lib/nest/function/v1/call.js +0 -55
- package/src/lib/nest/function/v1/call.js.map +0 -1
- package/src/lib/nest/function/v1/event.d.ts +0 -80
- package/src/lib/nest/function/v1/event.js +0 -52
- package/src/lib/nest/function/v1/event.js.map +0 -1
- package/src/lib/nest/function/v1/index.d.ts +0 -3
- package/src/lib/nest/function/v1/index.js +0 -7
- package/src/lib/nest/function/v1/index.js.map +0 -1
- package/src/lib/nest/function/v1/schedule.d.ts +0 -47
- package/src/lib/nest/function/v1/schedule.js +0 -68
- package/src/lib/nest/function/v1/schedule.js.map +0 -1
- package/src/lib/nest/function/v2/blocking.js +0 -38
- package/src/lib/nest/function/v2/blocking.js.map +0 -1
- package/src/lib/nest/function/v2/call.js +0 -31
- package/src/lib/nest/function/v2/call.js.map +0 -1
- package/src/lib/nest/function/v2/event.js +0 -25
- package/src/lib/nest/function/v2/event.js.map +0 -1
- package/src/lib/nest/function/v2/index.js +0 -9
- package/src/lib/nest/function/v2/index.js.map +0 -1
- package/src/lib/nest/function/v2/schedule.js +0 -56
- package/src/lib/nest/function/v2/schedule.js.map +0 -1
- package/src/lib/nest/function/v2/taskqueue.js +0 -26
- package/src/lib/nest/function/v2/taskqueue.js.map +0 -1
- package/src/lib/nest/index.js +0 -15
- package/src/lib/nest/index.js.map +0 -1
- package/src/lib/nest/middleware/appcheck.decorator.js +0 -12
- package/src/lib/nest/middleware/appcheck.decorator.js.map +0 -1
- package/src/lib/nest/middleware/appcheck.js +0 -3
- package/src/lib/nest/middleware/appcheck.js.map +0 -1
- package/src/lib/nest/middleware/appcheck.middleware.js +0 -74
- package/src/lib/nest/middleware/appcheck.middleware.js.map +0 -1
- package/src/lib/nest/middleware/appcheck.module.js +0 -21
- package/src/lib/nest/middleware/appcheck.module.js.map +0 -1
- package/src/lib/nest/middleware/globalprefix.js +0 -11
- package/src/lib/nest/middleware/globalprefix.js.map +0 -1
- package/src/lib/nest/middleware/index.js +0 -10
- package/src/lib/nest/middleware/index.js.map +0 -1
- package/src/lib/nest/middleware/rawbody.middleware.js +0 -16
- package/src/lib/nest/middleware/rawbody.middleware.js.map +0 -1
- package/src/lib/nest/middleware/webhook.js +0 -24
- package/src/lib/nest/middleware/webhook.js.map +0 -1
- package/src/lib/nest/model/call.model.function.js +0 -73
- package/src/lib/nest/model/call.model.function.js.map +0 -1
- package/src/lib/nest/model/create.model.function.js +0 -27
- package/src/lib/nest/model/create.model.function.js.map +0 -1
- package/src/lib/nest/model/crud.assert.function.js +0 -3
- package/src/lib/nest/model/crud.assert.function.js.map +0 -1
- package/src/lib/nest/model/delete.model.function.js +0 -27
- package/src/lib/nest/model/delete.model.function.js.map +0 -1
- package/src/lib/nest/model/index.js +0 -11
- package/src/lib/nest/model/index.js.map +0 -1
- package/src/lib/nest/model/permission.error.js +0 -24
- package/src/lib/nest/model/permission.error.js.map +0 -1
- package/src/lib/nest/model/read.model.function.js +0 -27
- package/src/lib/nest/model/read.model.function.js.map +0 -1
- package/src/lib/nest/model/specifier.function.js +0 -35
- package/src/lib/nest/model/specifier.function.js.map +0 -1
- package/src/lib/nest/model/update.model.function.js +0 -27
- package/src/lib/nest/model/update.model.function.js.map +0 -1
- package/src/lib/nest/nest.provider.js +0 -89
- package/src/lib/nest/nest.provider.js.map +0 -1
- package/src/lib/nest/storage/index.js +0 -5
- package/src/lib/nest/storage/index.js.map +0 -1
- package/src/lib/nest/storage/storage.module.js +0 -112
- package/src/lib/nest/storage/storage.module.js.map +0 -1
- package/src/lib/storage/driver.accessor.js +0 -299
- package/src/lib/storage/driver.accessor.js.map +0 -1
- package/src/lib/storage/driver.js +0 -12
- package/src/lib/storage/driver.js.map +0 -1
- package/src/lib/storage/index.js +0 -8
- package/src/lib/storage/index.js.map +0 -1
- package/src/lib/storage/storage.js +0 -20
- package/src/lib/storage/storage.js.map +0 -1
- package/src/lib/storage/storage.service.js +0 -26
- package/src/lib/storage/storage.service.js.map +0 -1
- package/test/src/index.js +0 -5
- package/test/src/index.js.map +0 -1
- package/test/src/lib/firebase/firebase.admin.auth.js +0 -260
- package/test/src/lib/firebase/firebase.admin.auth.js.map +0 -1
- package/test/src/lib/firebase/firebase.admin.collection.js +0 -108
- package/test/src/lib/firebase/firebase.admin.collection.js.map +0 -1
- package/test/src/lib/firebase/firebase.admin.function.js +0 -132
- package/test/src/lib/firebase/firebase.admin.function.js.map +0 -1
- package/test/src/lib/firebase/firebase.admin.js +0 -174
- package/test/src/lib/firebase/firebase.admin.js.map +0 -1
- package/test/src/lib/firebase/firebase.admin.nest.function.callable.context.js +0 -42
- package/test/src/lib/firebase/firebase.admin.nest.function.callable.context.js.map +0 -1
- package/test/src/lib/firebase/firebase.admin.nest.function.cloud.context.js +0 -40
- package/test/src/lib/firebase/firebase.admin.nest.function.cloud.context.js.map +0 -1
- package/test/src/lib/firebase/firebase.admin.nest.function.js +0 -64
- package/test/src/lib/firebase/firebase.admin.nest.function.js.map +0 -1
- package/test/src/lib/firebase/firebase.admin.nest.js +0 -107
- package/test/src/lib/firebase/firebase.admin.nest.js.map +0 -1
- package/test/src/lib/firebase/firebase.admin.test.server.js +0 -37
- package/test/src/lib/firebase/firebase.admin.test.server.js.map +0 -1
- package/test/src/lib/firebase/firebase.function.js +0 -58
- package/test/src/lib/firebase/firebase.function.js.map +0 -1
- package/test/src/lib/firebase/firebase.jest.d.ts +0 -21
- package/test/src/lib/firebase/firebase.jest.js +0 -45
- package/test/src/lib/firebase/firebase.jest.js.map +0 -1
- package/test/src/lib/firebase/firebase.js +0 -74
- package/test/src/lib/firebase/firebase.js.map +0 -1
- package/test/src/lib/firebase/index.js +0 -15
- package/test/src/lib/firebase/index.js.map +0 -1
- package/test/src/lib/firestore/firestore.admin.js +0 -21
- package/test/src/lib/firestore/firestore.admin.js.map +0 -1
- package/test/src/lib/firestore/firestore.js +0 -57
- package/test/src/lib/firestore/firestore.js.map +0 -1
- package/test/src/lib/firestore/index.js +0 -6
- package/test/src/lib/firestore/index.js.map +0 -1
- package/test/src/lib/index.js +0 -7
- package/test/src/lib/index.js.map +0 -1
- package/test/src/lib/storage/index.js +0 -6
- package/test/src/lib/storage/index.js.map +0 -1
- package/test/src/lib/storage/storage.admin.js +0 -21
- package/test/src/lib/storage/storage.admin.js.map +0 -1
- package/test/src/lib/storage/storage.js +0 -59
- package/test/src/lib/storage/storage.js.map +0 -1
- /package/{zoho/index.cjs.d.ts → index.d.ts} +0 -0
- /package/{zoho/index.esm.d.ts → mailgun/index.d.ts} +0 -0
|
@@ -0,0 +1,1324 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
require('core-js/modules/es.json.parse.js');
|
|
4
|
+
require('core-js/modules/es.json.stringify.js');
|
|
5
|
+
var util = require('@dereekb/util');
|
|
6
|
+
var test = require('@dereekb/util/test');
|
|
7
|
+
var jsonwebtoken = require('jsonwebtoken');
|
|
8
|
+
var firebase = require('@dereekb/firebase');
|
|
9
|
+
var admin = require('firebase-admin');
|
|
10
|
+
var functions = require('firebase-functions-test');
|
|
11
|
+
var test$1 = require('@dereekb/firebase/test');
|
|
12
|
+
var firebaseServer = require('@dereekb/firebase-server');
|
|
13
|
+
var firestore = require('@google-cloud/firestore');
|
|
14
|
+
var storage = require('@google-cloud/storage');
|
|
15
|
+
require('core-js/modules/es.iterator.constructor.js');
|
|
16
|
+
require('core-js/modules/es.iterator.for-each.js');
|
|
17
|
+
var testing = require('@nestjs/testing');
|
|
18
|
+
var nestjs = require('@dereekb/nestjs');
|
|
19
|
+
var https = require('firebase-functions/v1/https');
|
|
20
|
+
var makeError = require('make-error');
|
|
21
|
+
|
|
22
|
+
class AuthorizedUserTestContextFixture extends test.AbstractChildTestContextFixture {
|
|
23
|
+
// MARK: AuthorizedUserTestContext (Forwarded)
|
|
24
|
+
get uid() {
|
|
25
|
+
return this.instance.uid;
|
|
26
|
+
}
|
|
27
|
+
loadUserRecord() {
|
|
28
|
+
return this.instance.loadUserRecord();
|
|
29
|
+
}
|
|
30
|
+
loadUserEmailAndPhone() {
|
|
31
|
+
return this.instance.loadUserEmailAndPhone();
|
|
32
|
+
}
|
|
33
|
+
loadIdToken() {
|
|
34
|
+
return this.instance.loadIdToken();
|
|
35
|
+
}
|
|
36
|
+
loadDecodedIdToken() {
|
|
37
|
+
return this.instance.loadDecodedIdToken();
|
|
38
|
+
}
|
|
39
|
+
makeContextOptions() {
|
|
40
|
+
return this.instance.makeContextOptions();
|
|
41
|
+
}
|
|
42
|
+
callWrappedFunction(fn, params, skipJsonConversion) {
|
|
43
|
+
return this.instance.callWrappedFunction(fn, params, skipJsonConversion);
|
|
44
|
+
}
|
|
45
|
+
callCloudFunction(fn, params, skipJsonConversion = false) {
|
|
46
|
+
return this.instance.callCloudFunction(fn, params, skipJsonConversion);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
function convertParamsToParsedJsonObjectAndBack(object) {
|
|
50
|
+
const paramsAsJson = JSON.parse(JSON.stringify(object));
|
|
51
|
+
return paramsAsJson;
|
|
52
|
+
}
|
|
53
|
+
class AuthorizedUserTestContextInstance {
|
|
54
|
+
constructor(uid, testContext) {
|
|
55
|
+
this.uid = void 0;
|
|
56
|
+
this.testContext = void 0;
|
|
57
|
+
this.uid = uid;
|
|
58
|
+
this.testContext = testContext;
|
|
59
|
+
}
|
|
60
|
+
loadUserRecord() {
|
|
61
|
+
return this.testContext.auth.getUser(this.uid);
|
|
62
|
+
}
|
|
63
|
+
async loadUserEmailAndPhone() {
|
|
64
|
+
const record = await this.loadUserRecord();
|
|
65
|
+
return {
|
|
66
|
+
email: record.email,
|
|
67
|
+
phone: record.phoneNumber
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
loadIdToken() {
|
|
71
|
+
return this.loadUserRecord().then(record => createEncodedTestFirestoreTokenForUserRecord(this.testContext.auth, record));
|
|
72
|
+
}
|
|
73
|
+
loadDecodedIdToken() {
|
|
74
|
+
return this.loadIdToken().then(decodeEncodedCreateCustomTokenResult);
|
|
75
|
+
}
|
|
76
|
+
makeContextOptions() {
|
|
77
|
+
return this.loadUserRecord().then(record => createTestFunctionContextOptions(this.testContext.auth, record));
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Calls a wrapped function with the input params and the context from makeContextOptions().
|
|
81
|
+
*
|
|
82
|
+
* @param fn
|
|
83
|
+
* @param params
|
|
84
|
+
* @param skipJsonConversion
|
|
85
|
+
*/
|
|
86
|
+
callWrappedFunction(fn, params, skipJsonConversion) {
|
|
87
|
+
// Parse to JSON then back to simulate sending JSON to the server, and the server parsing it as a POJO.
|
|
88
|
+
const parsedParams = params == null || skipJsonConversion ? params : convertParamsToParsedJsonObjectAndBack(params);
|
|
89
|
+
return this.makeContextOptions().then(options => fn(parsedParams, options));
|
|
90
|
+
}
|
|
91
|
+
callCloudFunction(fn, params, skipJsonConversion = false) {
|
|
92
|
+
if (params != null && params.scheduleTime) {
|
|
93
|
+
// Workaround for https://github.com/firebase/firebase-functions-test/issues/210
|
|
94
|
+
const scheduleTime = params.scheduleTime;
|
|
95
|
+
delete params.scheduleTime;
|
|
96
|
+
params.timestamp = scheduleTime;
|
|
97
|
+
}
|
|
98
|
+
return this.callWrappedFunction(fn, params, skipJsonConversion);
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Calls a wrapped gen 2 auth blocking function with the input params and context options from makeContextOptions().
|
|
102
|
+
*
|
|
103
|
+
* @param fn
|
|
104
|
+
* @param userRecord
|
|
105
|
+
* @param eventType
|
|
106
|
+
* @param eventOverride
|
|
107
|
+
* @param skipJsonConversion
|
|
108
|
+
* @returns
|
|
109
|
+
*/
|
|
110
|
+
callAuthBlockingFunction(fn, userRecord, eventType, eventOverride, skipJsonConversion = false) {
|
|
111
|
+
const timestamp = new Date().toISOString();
|
|
112
|
+
const event = {
|
|
113
|
+
ipAddress: '127.0.0.1',
|
|
114
|
+
userAgent: 'testing',
|
|
115
|
+
eventId: '0',
|
|
116
|
+
params: {},
|
|
117
|
+
resource: {
|
|
118
|
+
service: 'dbx-test',
|
|
119
|
+
name: 'fake-resource'
|
|
120
|
+
},
|
|
121
|
+
timestamp,
|
|
122
|
+
...eventOverride,
|
|
123
|
+
data: userRecord,
|
|
124
|
+
eventType
|
|
125
|
+
};
|
|
126
|
+
return this.callCloudFunction(fn, event, skipJsonConversion);
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* @deprecated gen 1
|
|
130
|
+
*
|
|
131
|
+
* @param fn
|
|
132
|
+
* @param params
|
|
133
|
+
* @param contextOptions
|
|
134
|
+
* @param skipJsonConversion
|
|
135
|
+
* @returns
|
|
136
|
+
*/
|
|
137
|
+
callEventCloudFunction(fn, params, contextOptions, skipJsonConversion = false) {
|
|
138
|
+
const parsedParams = params == null || skipJsonConversion ? params : convertParamsToParsedJsonObjectAndBack(params);
|
|
139
|
+
return this.makeContextOptions().then(options => fn(parsedParams, contextOptions ? {
|
|
140
|
+
...contextOptions,
|
|
141
|
+
...options
|
|
142
|
+
} : options));
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Convenience function for using authorizedUserContextFactory directly and passing buildTests.
|
|
147
|
+
*/
|
|
148
|
+
function authorizedUserContext(config, buildTests) {
|
|
149
|
+
authorizedUserContextFactory(config)({
|
|
150
|
+
f: config.f
|
|
151
|
+
}, buildTests);
|
|
152
|
+
}
|
|
153
|
+
const AUTHORIZED_USER_RANDOM_EMAIL_FACTORY = util.randomEmailFactory();
|
|
154
|
+
const AUTHORIZED_USER_RANDOM_PHONE_NUMBER_FACTORY = util.randomPhoneNumberFactory();
|
|
155
|
+
/**
|
|
156
|
+
* Creates a new Jest Context that has a random user for authorization for use in firebase server tests.
|
|
157
|
+
*/
|
|
158
|
+
function authorizedUserContextFactory(config) {
|
|
159
|
+
const {
|
|
160
|
+
uid: uidGetter,
|
|
161
|
+
makeInstance = (uid, testInstance) => new AuthorizedUserTestContextInstance(uid, testInstance),
|
|
162
|
+
makeFixture = f => new AuthorizedUserTestContextFixture(f),
|
|
163
|
+
makeUserDetails = () => ({}),
|
|
164
|
+
initUser
|
|
165
|
+
} = config;
|
|
166
|
+
const makeUid = uidGetter ? util.asGetter(uidGetter) : testUidFactory;
|
|
167
|
+
return (params, buildTests) => {
|
|
168
|
+
const {
|
|
169
|
+
f,
|
|
170
|
+
user: inputUserGetterOrValue,
|
|
171
|
+
addContactInfo: inputAddContactInfoGetterOrValue,
|
|
172
|
+
template: inputTemplateGetterOrValue
|
|
173
|
+
} = params;
|
|
174
|
+
const inputAddContactInfoGetter = util.asGetter(inputAddContactInfoGetterOrValue);
|
|
175
|
+
const inputUserGetter = util.asGetter(inputUserGetterOrValue);
|
|
176
|
+
const templateGetter = util.asGetter(inputTemplateGetterOrValue);
|
|
177
|
+
return test.useTestContextFixture({
|
|
178
|
+
fixture: makeFixture(f),
|
|
179
|
+
buildTests,
|
|
180
|
+
initInstance: async () => {
|
|
181
|
+
const inputAddContactInfo = await inputAddContactInfoGetter();
|
|
182
|
+
const inputUser = await inputUserGetter();
|
|
183
|
+
const inputTemplate = await templateGetter();
|
|
184
|
+
const uid = inputUser?.uid || makeUid();
|
|
185
|
+
const {
|
|
186
|
+
details,
|
|
187
|
+
claims,
|
|
188
|
+
addContactInfo: userDetailsAddContactInfo
|
|
189
|
+
} = {
|
|
190
|
+
...makeUserDetails(uid, params),
|
|
191
|
+
...inputTemplate
|
|
192
|
+
};
|
|
193
|
+
const {
|
|
194
|
+
phoneNumber: detailsPhoneNumber,
|
|
195
|
+
email: detailsEmail
|
|
196
|
+
} = details ?? {}; // keep details if provided
|
|
197
|
+
const addContactInfo = inputAddContactInfo || userDetailsAddContactInfo;
|
|
198
|
+
const auth = f.instance.auth;
|
|
199
|
+
let email;
|
|
200
|
+
let phoneNumber;
|
|
201
|
+
if (addContactInfo) {
|
|
202
|
+
email = detailsEmail ?? AUTHORIZED_USER_RANDOM_EMAIL_FACTORY();
|
|
203
|
+
phoneNumber = detailsPhoneNumber ?? AUTHORIZED_USER_RANDOM_PHONE_NUMBER_FACTORY();
|
|
204
|
+
} else {
|
|
205
|
+
email = detailsEmail;
|
|
206
|
+
phoneNumber = detailsPhoneNumber ?? undefined;
|
|
207
|
+
}
|
|
208
|
+
const userRecord = await auth.createUser({
|
|
209
|
+
uid,
|
|
210
|
+
displayName: 'Test Person',
|
|
211
|
+
...details,
|
|
212
|
+
email,
|
|
213
|
+
phoneNumber,
|
|
214
|
+
...inputUser
|
|
215
|
+
});
|
|
216
|
+
if (claims) {
|
|
217
|
+
await auth.setCustomUserClaims(uid, claims);
|
|
218
|
+
}
|
|
219
|
+
const instance = await makeInstance(uid, f.instance, params, userRecord);
|
|
220
|
+
if (initUser) {
|
|
221
|
+
await initUser(instance, params);
|
|
222
|
+
}
|
|
223
|
+
return instance;
|
|
224
|
+
},
|
|
225
|
+
destroyInstance: async instance => {
|
|
226
|
+
const app = instance.testContext.app;
|
|
227
|
+
const uid = instance.uid;
|
|
228
|
+
await app.auth().deleteUser(uid);
|
|
229
|
+
}
|
|
230
|
+
});
|
|
231
|
+
};
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* Incrementing number factory for generating test UID values.
|
|
235
|
+
*
|
|
236
|
+
* Has the format 'test-uid-<number>'
|
|
237
|
+
*/
|
|
238
|
+
const testUidFactory = util.mapGetter(util.incrementingNumberFactory(), i => `${new Date().getTime()}0${i}`);
|
|
239
|
+
/**
|
|
240
|
+
* Creates a CallableContextOptions with auth attached corresponding to the input UserRecord.
|
|
241
|
+
*
|
|
242
|
+
* @param auth
|
|
243
|
+
* @param userRecord
|
|
244
|
+
* @returns
|
|
245
|
+
*/
|
|
246
|
+
async function createTestFunctionContextOptions(auth, userRecord) {
|
|
247
|
+
const authData = await createTestFunctionContextAuthData(auth, userRecord);
|
|
248
|
+
const contextOptions = {
|
|
249
|
+
auth: authData
|
|
250
|
+
};
|
|
251
|
+
return contextOptions;
|
|
252
|
+
}
|
|
253
|
+
/**
|
|
254
|
+
* Creates AuthData from the input auth and user record.
|
|
255
|
+
*
|
|
256
|
+
* @param auth
|
|
257
|
+
* @param userRecord
|
|
258
|
+
* @returns
|
|
259
|
+
*/
|
|
260
|
+
async function createTestFunctionContextAuthData(auth, userRecord) {
|
|
261
|
+
const token = await createTestFirestoreTokenForUserRecord(auth, userRecord);
|
|
262
|
+
const authData = {
|
|
263
|
+
uid: token.uid,
|
|
264
|
+
token,
|
|
265
|
+
rawToken: ''
|
|
266
|
+
};
|
|
267
|
+
return authData;
|
|
268
|
+
}
|
|
269
|
+
/**
|
|
270
|
+
* Creates and decodes a firestore token used for testing.
|
|
271
|
+
*
|
|
272
|
+
* @param auth
|
|
273
|
+
* @param userRecord
|
|
274
|
+
* @returns
|
|
275
|
+
*/
|
|
276
|
+
function createTestFirestoreTokenForUserRecord(auth, userRecord) {
|
|
277
|
+
return createEncodedTestFirestoreTokenForUserRecord(auth, userRecord).then(decodeEncodedCreateCustomTokenResult);
|
|
278
|
+
}
|
|
279
|
+
/**
|
|
280
|
+
* Creates an encoded firestore token used for testing.
|
|
281
|
+
*
|
|
282
|
+
* @param auth
|
|
283
|
+
* @param userRecord
|
|
284
|
+
* @returns
|
|
285
|
+
*/
|
|
286
|
+
function createEncodedTestFirestoreTokenForUserRecord(auth, userRecord) {
|
|
287
|
+
// TODO: Consider replacing createCustomToken, as the custom claims are put into an object called claims in the JWT, instead of spread over. The decodeEncodedCreateCustomTokenResult() function handles this issue, but it may not be expected.
|
|
288
|
+
return auth.createCustomToken(userRecord.uid, testFirestoreClaimsFromUserRecord(userRecord));
|
|
289
|
+
}
|
|
290
|
+
function decodeEncodedCreateCustomTokenResult(token) {
|
|
291
|
+
const decoded = jsonwebtoken.decode(token);
|
|
292
|
+
const decodedToken = {
|
|
293
|
+
...decoded,
|
|
294
|
+
...decoded.claims,
|
|
295
|
+
auth_time: decoded.iat,
|
|
296
|
+
firebase: decoded.claims?.firebase ?? {}
|
|
297
|
+
};
|
|
298
|
+
delete decodedToken.claims; // remove the "claims" item if it exists.
|
|
299
|
+
return decodedToken;
|
|
300
|
+
}
|
|
301
|
+
function testFirestoreClaimsFromUserRecord(userRecord) {
|
|
302
|
+
// Copy claims to be similar to DecodedIdToken pieces.
|
|
303
|
+
const baseClaims = {
|
|
304
|
+
picture: userRecord.photoURL,
|
|
305
|
+
email: userRecord.email,
|
|
306
|
+
email_verified: userRecord.emailVerified ?? false,
|
|
307
|
+
firebase: {
|
|
308
|
+
sign_in_provider: '@dereekb/firebase-server/test',
|
|
309
|
+
identities: []
|
|
310
|
+
}
|
|
311
|
+
};
|
|
312
|
+
const customClaims = userRecord.customClaims;
|
|
313
|
+
const claims = {
|
|
314
|
+
...customClaims,
|
|
315
|
+
...baseClaims
|
|
316
|
+
};
|
|
317
|
+
return claims;
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
class ModelTestContextFixture extends test.AbstractChildTestContextFixture {
|
|
321
|
+
// MARK: ModelTestContext (Forwarded)
|
|
322
|
+
get documentId() {
|
|
323
|
+
return this.instance.documentId;
|
|
324
|
+
}
|
|
325
|
+
get documentKey() {
|
|
326
|
+
return this.instance.documentKey;
|
|
327
|
+
}
|
|
328
|
+
get documentFlatKey() {
|
|
329
|
+
return this.instance.documentFlatKey;
|
|
330
|
+
}
|
|
331
|
+
get documentTwoWayFlatKey() {
|
|
332
|
+
return this.instance.documentTwoWayFlatKey;
|
|
333
|
+
}
|
|
334
|
+
get documentRef() {
|
|
335
|
+
return this.instance.documentRef;
|
|
336
|
+
}
|
|
337
|
+
get document() {
|
|
338
|
+
return this.instance.document;
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
class ModelTestContextInstance {
|
|
342
|
+
constructor(collection, ref, testContext) {
|
|
343
|
+
this.collection = void 0;
|
|
344
|
+
this.ref = void 0;
|
|
345
|
+
this.testContext = void 0;
|
|
346
|
+
this.collection = collection;
|
|
347
|
+
this.ref = ref;
|
|
348
|
+
this.testContext = testContext;
|
|
349
|
+
}
|
|
350
|
+
get documentId() {
|
|
351
|
+
return this.ref.id;
|
|
352
|
+
}
|
|
353
|
+
get documentKey() {
|
|
354
|
+
return this.ref.path;
|
|
355
|
+
}
|
|
356
|
+
get documentFlatKey() {
|
|
357
|
+
return firebase.flatFirestoreModelKey(this.documentKey);
|
|
358
|
+
}
|
|
359
|
+
get documentTwoWayFlatKey() {
|
|
360
|
+
return firebase.twoWayFlatFirestoreModelKey(this.documentKey);
|
|
361
|
+
}
|
|
362
|
+
get documentRef() {
|
|
363
|
+
return this.ref;
|
|
364
|
+
}
|
|
365
|
+
get document() {
|
|
366
|
+
return this.collection.documentAccessor().loadDocument(this.ref);
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
/**
|
|
370
|
+
* Creates a new Test Context that has a random user for authorization for use in firebase server tests.
|
|
371
|
+
*/
|
|
372
|
+
function modelTestContextFactory(config) {
|
|
373
|
+
const {
|
|
374
|
+
getCollection,
|
|
375
|
+
collectionForDocument,
|
|
376
|
+
makeRef = collection => {
|
|
377
|
+
const accessor = collection.documentAccessor();
|
|
378
|
+
if (accessor.newDocument == null) {
|
|
379
|
+
throw new Error('collection passed to makeRef() was not a full FirestoreCollection. Either supply a custom makeRef() function or a FirestoreCollection that has newDocument() available on the documentAccessor.');
|
|
380
|
+
}
|
|
381
|
+
return accessor.newDocument().documentRef;
|
|
382
|
+
},
|
|
383
|
+
makeInstance = (collection, ref, testInstance) => new ModelTestContextInstance(collection, ref, testInstance),
|
|
384
|
+
makeFixture = f => new ModelTestContextFixture(f),
|
|
385
|
+
initDocument,
|
|
386
|
+
destroyInstance
|
|
387
|
+
} = config;
|
|
388
|
+
return (params, buildTests) => {
|
|
389
|
+
const {
|
|
390
|
+
f
|
|
391
|
+
} = params;
|
|
392
|
+
return test.useTestContextFixture({
|
|
393
|
+
fixture: makeFixture(f),
|
|
394
|
+
buildTests,
|
|
395
|
+
initInstance: async () => {
|
|
396
|
+
const parentInstance = f.instance;
|
|
397
|
+
let ref;
|
|
398
|
+
let collection;
|
|
399
|
+
let init;
|
|
400
|
+
if (params.doc) {
|
|
401
|
+
const doc = await util.getValueFromGetter(params.doc);
|
|
402
|
+
if (!collectionForDocument) {
|
|
403
|
+
throw new Error('collectionForDocument() is required when using ModelTestContextDocumentRefParams values as input.');
|
|
404
|
+
}
|
|
405
|
+
collection = collectionForDocument(parentInstance, doc);
|
|
406
|
+
const expectedCollectionName = collection.documentAccessor().modelIdentity.collectionName;
|
|
407
|
+
if (expectedCollectionName !== doc.modelIdentity.collectionName) {
|
|
408
|
+
throw new Error(`Input doc is in a different collection (${doc.modelIdentity.collectionName}) than expected (${expectedCollectionName}).`);
|
|
409
|
+
}
|
|
410
|
+
ref = doc.documentRef;
|
|
411
|
+
init = false;
|
|
412
|
+
} else {
|
|
413
|
+
collection = getCollection(parentInstance, params);
|
|
414
|
+
ref = await makeRef(collection, params, parentInstance);
|
|
415
|
+
init = true;
|
|
416
|
+
}
|
|
417
|
+
const instance = await makeInstance(collection, ref, parentInstance);
|
|
418
|
+
if (init && initDocument) {
|
|
419
|
+
await initDocument(instance, params);
|
|
420
|
+
}
|
|
421
|
+
return instance;
|
|
422
|
+
},
|
|
423
|
+
destroyInstance
|
|
424
|
+
});
|
|
425
|
+
};
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
let adminEnvironmentInitialized = false;
|
|
429
|
+
function isAdminEnvironmentInitialized() {
|
|
430
|
+
return adminEnvironmentInitialized;
|
|
431
|
+
}
|
|
432
|
+
function generateNewProjectId() {
|
|
433
|
+
const projectId = 'firebase-test-' + new Date().getTime();
|
|
434
|
+
return projectId;
|
|
435
|
+
}
|
|
436
|
+
function rollNewGCloudProjectEnvironmentVariable() {
|
|
437
|
+
const projectId = generateNewProjectId();
|
|
438
|
+
process.env.GCLOUD_TEST_PROJECT = projectId;
|
|
439
|
+
process.env.GCLOUD_PROJECT = projectId;
|
|
440
|
+
applyFirebaseGCloudTestProjectIdToFirebaseConfigEnv();
|
|
441
|
+
return projectId;
|
|
442
|
+
}
|
|
443
|
+
function getGCloudProjectId() {
|
|
444
|
+
return process.env.GCLOUD_PROJECT;
|
|
445
|
+
}
|
|
446
|
+
function getGCloudTestProjectId() {
|
|
447
|
+
return process.env.GCLOUD_TEST_PROJECT;
|
|
448
|
+
}
|
|
449
|
+
/**
|
|
450
|
+
* Applies the current GCLOUD_PROJECT to FIREBASE_CONFIG.
|
|
451
|
+
*
|
|
452
|
+
* This is done as some external testing libraries (firebase-functions-test) will overwrite but we want to enforce using our project id
|
|
453
|
+
* so that each component can also
|
|
454
|
+
*/
|
|
455
|
+
function applyFirebaseGCloudTestProjectIdToFirebaseConfigEnv() {
|
|
456
|
+
// firebase-functions-test overwrites this each time.
|
|
457
|
+
// https://github.com/firebase/firebase-functions-test/blob/acb068f4c086f3355b2960b9e9e5895716c7f8cc/src/lifecycle.ts#L37
|
|
458
|
+
const testProjectId = getGCloudTestProjectId();
|
|
459
|
+
// console.log('Test project: ', testProjectId);
|
|
460
|
+
if (!testProjectId) {
|
|
461
|
+
throw new Error('No test project id was available in the environment. Did you call initFirebaseAdminTestEnvironment() first?');
|
|
462
|
+
}
|
|
463
|
+
const config = JSON.parse(process.env.FIREBASE_CONFIG ?? '{}');
|
|
464
|
+
config.projectId = testProjectId;
|
|
465
|
+
process.env.FIREBASE_CONFIG = JSON.stringify(config);
|
|
466
|
+
process.env.GCLOUD_PROJECT = testProjectId; // re-apply to GCLOUD_PROJECT too
|
|
467
|
+
return testProjectId;
|
|
468
|
+
}
|
|
469
|
+
/**
|
|
470
|
+
* Should be called before calling/using adminFirebaseTestBuilder(). This should only be called once.
|
|
471
|
+
*/
|
|
472
|
+
function initFirebaseAdminTestEnvironment(config) {
|
|
473
|
+
function crashForEmulator(emulator) {
|
|
474
|
+
throw new Error(`Emulator for ${emulator} was not set null or to a host. Crashing to prevent contamination.`);
|
|
475
|
+
}
|
|
476
|
+
function configureEmulator(emulator, envKey) {
|
|
477
|
+
const emulatorConfig = config.emulators[emulator];
|
|
478
|
+
if (emulatorConfig) {
|
|
479
|
+
process.env[envKey] = emulatorConfig;
|
|
480
|
+
} else if (config.emulators.firestore !== null) {
|
|
481
|
+
crashForEmulator(emulator);
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
rollNewGCloudProjectEnvironmentVariable();
|
|
485
|
+
configureEmulator('auth', 'FIREBASE_AUTH_EMULATOR_HOST');
|
|
486
|
+
configureEmulator('firestore', 'FIRESTORE_EMULATOR_HOST');
|
|
487
|
+
configureEmulator('storage', 'FIREBASE_STORAGE_EMULATOR_HOST');
|
|
488
|
+
applyFirebaseGCloudTestProjectIdToFirebaseConfigEnv();
|
|
489
|
+
adminEnvironmentInitialized = true;
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
function makeGoogleFirestoreContext(drivers, firestore) {
|
|
493
|
+
const context = firebase.firestoreContextFactory(drivers)(firestore);
|
|
494
|
+
context.drivers = drivers;
|
|
495
|
+
return context;
|
|
496
|
+
}
|
|
497
|
+
class GoogleCloudTestFirestoreInstance extends test$1.TestFirestoreInstance {
|
|
498
|
+
constructor(drivers, firestore) {
|
|
499
|
+
super(makeGoogleFirestoreContext(drivers, firestore));
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
class GoogleCloudTestFirestoreContextFixture extends test$1.TestFirestoreContextFixture {}
|
|
503
|
+
let COUNTER$1 = 0;
|
|
504
|
+
/**
|
|
505
|
+
* A TestContextBuilderFunction for building firestore test context factories using @google-cloud/firestore. This means SERVER TESTING ONLY. For client testing, look at @dereekb/firestore.
|
|
506
|
+
*
|
|
507
|
+
* This is used to build a @google-cloud/firestore Firestore instance for testing and point it to the emulators.
|
|
508
|
+
*
|
|
509
|
+
* If you need all of Firebase (firebase-admin library), look at adminFirebaseAdminTestBuilder() instead.
|
|
510
|
+
*/
|
|
511
|
+
const googleCloudTestFirestoreBuilder = test.testContextBuilder({
|
|
512
|
+
buildConfig: input => {
|
|
513
|
+
const config = {
|
|
514
|
+
host: input?.host ?? 'localhost',
|
|
515
|
+
port: input?.port ?? 0
|
|
516
|
+
};
|
|
517
|
+
return config;
|
|
518
|
+
},
|
|
519
|
+
buildFixture: () => new GoogleCloudTestFirestoreContextFixture(),
|
|
520
|
+
setupInstance: async config => {
|
|
521
|
+
const random = Math.floor(Math.random() * 10000);
|
|
522
|
+
const drivers = test$1.makeTestingFirestoreDrivers(firebaseServer.googleCloudFirestoreDrivers());
|
|
523
|
+
const projectId = `test-${COUNTER$1++}-${Date.now()}-${random}`.substring(0, 30);
|
|
524
|
+
const firestore$1 = new firestore.Firestore({
|
|
525
|
+
projectId,
|
|
526
|
+
host: config.host,
|
|
527
|
+
port: config.port,
|
|
528
|
+
maxIdleChannels: 0
|
|
529
|
+
});
|
|
530
|
+
return new GoogleCloudTestFirestoreInstance(drivers, firestore$1);
|
|
531
|
+
},
|
|
532
|
+
teardownInstance: async (instance, config) => {
|
|
533
|
+
await instance.firestore.terminate();
|
|
534
|
+
}
|
|
535
|
+
});
|
|
536
|
+
|
|
537
|
+
function makeGoogleFirebaseStorageContext(drivers, firebaseStorage, defaultBucketId) {
|
|
538
|
+
const context = firebase.firebaseStorageContextFactory(drivers)(firebaseStorage, {
|
|
539
|
+
defaultBucketId
|
|
540
|
+
});
|
|
541
|
+
context.drivers = drivers;
|
|
542
|
+
return context;
|
|
543
|
+
}
|
|
544
|
+
class GoogleCloudTestFirebaseStorageInstance extends test$1.TestFirebaseStorageInstance {
|
|
545
|
+
constructor(drivers, firebaseStorage, defaultBucketId) {
|
|
546
|
+
super(makeGoogleFirebaseStorageContext(drivers, firebaseStorage, defaultBucketId));
|
|
547
|
+
}
|
|
548
|
+
}
|
|
549
|
+
class GoogleCloudTestFirebaseStorageContextFixture extends test$1.TestFirebaseStorageContextFixture {}
|
|
550
|
+
let COUNTER = 0;
|
|
551
|
+
/**
|
|
552
|
+
* A TestContextBuilderFunction for building firebase storage test context factories using @google-cloud/storage. This means SERVER TESTING ONLY. For client testing, look at @dereekb/firestore.
|
|
553
|
+
*
|
|
554
|
+
* This is used to build a @google-cloud/storage FirebaseStorage instance for testing and point it to the emulators.
|
|
555
|
+
*
|
|
556
|
+
* If you need all of Firebase (firebase-admin library), look at adminFirebaseAdminTestBuilder() instead.
|
|
557
|
+
*/
|
|
558
|
+
const googleCloudTestFirebaseStorageBuilder = test.testContextBuilder({
|
|
559
|
+
buildConfig: input => {
|
|
560
|
+
const config = {
|
|
561
|
+
host: input?.host ?? 'localhost',
|
|
562
|
+
port: input?.port ?? 0
|
|
563
|
+
};
|
|
564
|
+
if (!config.port) {
|
|
565
|
+
throw new Error('Port for host is required.');
|
|
566
|
+
}
|
|
567
|
+
return config;
|
|
568
|
+
},
|
|
569
|
+
buildFixture: () => new GoogleCloudTestFirebaseStorageContextFixture(),
|
|
570
|
+
setupInstance: async config => {
|
|
571
|
+
const drivers = test$1.makeTestingFirebaseStorageDrivers(firebaseServer.googleCloudFirebaseStorageDrivers());
|
|
572
|
+
const projectId = `firebase-storage-server-test-${new Date().getTime()}-${COUNTER++}`;
|
|
573
|
+
const firebaseStorage = new storage.Storage({
|
|
574
|
+
projectId,
|
|
575
|
+
// ensure http:// is provided so the library doesn't default to/try https://
|
|
576
|
+
apiEndpoint: `http://${config.host}:${config.port}`
|
|
577
|
+
});
|
|
578
|
+
const defaultBucketId = projectId;
|
|
579
|
+
return new GoogleCloudTestFirebaseStorageInstance(drivers, firebaseStorage, defaultBucketId);
|
|
580
|
+
},
|
|
581
|
+
teardownInstance: async (instance, config) => {
|
|
582
|
+
// nothing to teardown
|
|
583
|
+
}
|
|
584
|
+
});
|
|
585
|
+
|
|
586
|
+
class FirebaseAdminTestContextFixture extends test.AbstractTestContextFixture {
|
|
587
|
+
// MARK: FirebaseAdminTestContext (Forwarded)
|
|
588
|
+
get app() {
|
|
589
|
+
return this.instance.app;
|
|
590
|
+
}
|
|
591
|
+
get auth() {
|
|
592
|
+
return this.instance.auth;
|
|
593
|
+
}
|
|
594
|
+
get firestore() {
|
|
595
|
+
return this.instance.firestore;
|
|
596
|
+
}
|
|
597
|
+
get firestoreInstance() {
|
|
598
|
+
return this.instance.firestoreInstance;
|
|
599
|
+
}
|
|
600
|
+
get firestoreContext() {
|
|
601
|
+
return this.instance.firestoreContext;
|
|
602
|
+
}
|
|
603
|
+
get storage() {
|
|
604
|
+
return this.instance.storage;
|
|
605
|
+
}
|
|
606
|
+
get storageInstance() {
|
|
607
|
+
return this.instance.storageInstance;
|
|
608
|
+
}
|
|
609
|
+
get storageContext() {
|
|
610
|
+
return this.instance.storageContext;
|
|
611
|
+
}
|
|
612
|
+
get fnWrapper() {
|
|
613
|
+
return this.instance.fnWrapper;
|
|
614
|
+
}
|
|
615
|
+
}
|
|
616
|
+
// MARK: FirebaseAdminTestBuilder
|
|
617
|
+
class FirebaseAdminTestContextInstance {
|
|
618
|
+
constructor(app) {
|
|
619
|
+
this.app = void 0;
|
|
620
|
+
this.getTestFirestoreInstance = util.cachedGetter(() => {
|
|
621
|
+
const drivers = test$1.makeTestingFirestoreDrivers(firebaseServer.googleCloudFirestoreDrivers());
|
|
622
|
+
return new GoogleCloudTestFirestoreInstance(drivers, this.firestore);
|
|
623
|
+
});
|
|
624
|
+
this.getTestFirebaseStorageInstance = util.cachedGetter(() => {
|
|
625
|
+
const drivers = test$1.makeTestingFirebaseStorageDrivers(firebaseServer.googleCloudFirebaseStorageDrivers());
|
|
626
|
+
const defaultBucketId = this.app.options.storageBucket;
|
|
627
|
+
return new GoogleCloudTestFirebaseStorageInstance(drivers, this.storage, defaultBucketId);
|
|
628
|
+
});
|
|
629
|
+
this.app = app;
|
|
630
|
+
}
|
|
631
|
+
get auth() {
|
|
632
|
+
return this.app.auth();
|
|
633
|
+
}
|
|
634
|
+
get firestore() {
|
|
635
|
+
return this.app.firestore();
|
|
636
|
+
}
|
|
637
|
+
get firestoreInstance() {
|
|
638
|
+
return this.getTestFirestoreInstance();
|
|
639
|
+
}
|
|
640
|
+
get firestoreContext() {
|
|
641
|
+
return this.firestoreInstance.firestoreContext;
|
|
642
|
+
}
|
|
643
|
+
get storage() {
|
|
644
|
+
return firebaseServer.googleCloudStorageFromFirebaseAdminStorage(this.app.storage());
|
|
645
|
+
}
|
|
646
|
+
get storageInstance() {
|
|
647
|
+
return this.getTestFirebaseStorageInstance();
|
|
648
|
+
}
|
|
649
|
+
get storageContext() {
|
|
650
|
+
return this.storageInstance.storageContext;
|
|
651
|
+
}
|
|
652
|
+
get fnWrapper() {
|
|
653
|
+
throw new Error('wrapCloudFunction is unsupported by this type.');
|
|
654
|
+
}
|
|
655
|
+
}
|
|
656
|
+
class AbstractFirebaseAdminTestContextInstanceChild {
|
|
657
|
+
constructor(parent) {
|
|
658
|
+
this.parent = void 0;
|
|
659
|
+
this.parent = parent;
|
|
660
|
+
}
|
|
661
|
+
// MARK: FirebaseAdminTestContext (Forwarded)
|
|
662
|
+
get app() {
|
|
663
|
+
return this.parent.app;
|
|
664
|
+
}
|
|
665
|
+
get auth() {
|
|
666
|
+
return this.parent.auth;
|
|
667
|
+
}
|
|
668
|
+
get firestore() {
|
|
669
|
+
return this.parent.firestore;
|
|
670
|
+
}
|
|
671
|
+
get firestoreInstance() {
|
|
672
|
+
return this.parent.firestoreInstance;
|
|
673
|
+
}
|
|
674
|
+
get firestoreContext() {
|
|
675
|
+
return this.parent.firestoreContext;
|
|
676
|
+
}
|
|
677
|
+
get storage() {
|
|
678
|
+
return this.parent.storage;
|
|
679
|
+
}
|
|
680
|
+
get storageInstance() {
|
|
681
|
+
return this.parent.storageInstance;
|
|
682
|
+
}
|
|
683
|
+
get storageContext() {
|
|
684
|
+
return this.parent.storageContext;
|
|
685
|
+
}
|
|
686
|
+
get fnWrapper() {
|
|
687
|
+
return this.parent.fnWrapper;
|
|
688
|
+
}
|
|
689
|
+
}
|
|
690
|
+
/**
|
|
691
|
+
* A TestContextBuilderFunction for building firebase test context factories using firebase-admin.
|
|
692
|
+
*
|
|
693
|
+
* This can be used to easily build a testing context that sets up RulesTestEnvironment for tests that sets itself up and tears itself down.
|
|
694
|
+
*/
|
|
695
|
+
const firebaseAdminTestBuilder = test.testContextBuilder({
|
|
696
|
+
buildConfig: input => {
|
|
697
|
+
const config = {
|
|
698
|
+
...input
|
|
699
|
+
};
|
|
700
|
+
return config;
|
|
701
|
+
},
|
|
702
|
+
buildFixture: () => new FirebaseAdminTestContextFixture(),
|
|
703
|
+
setupInstance: async config => {
|
|
704
|
+
if (!isAdminEnvironmentInitialized()) {
|
|
705
|
+
throw new Error('Call initFirebaseAdminTestEnvironment() from @dereekb/firebase-server was not called before using adminFirebaseTestBuilder().');
|
|
706
|
+
}
|
|
707
|
+
const projectId = generateNewProjectId();
|
|
708
|
+
const storageBucket = 'b-' + projectId;
|
|
709
|
+
const app = admin.initializeApp({
|
|
710
|
+
projectId,
|
|
711
|
+
storageBucket
|
|
712
|
+
});
|
|
713
|
+
return new FirebaseAdminTestContextInstance(app);
|
|
714
|
+
},
|
|
715
|
+
teardownInstance: async (instance, config) => {
|
|
716
|
+
await instance.app.delete(); // clean up the instance
|
|
717
|
+
}
|
|
718
|
+
});
|
|
719
|
+
const firebaseAdminTestContextFactory = firebaseAdminTestBuilder({});
|
|
720
|
+
// MARK: Firestore Context
|
|
721
|
+
/**
|
|
722
|
+
* Convenience function to build a TestFirestoreContextFactory from a FirebaseAdminTestContextFactory.
|
|
723
|
+
*
|
|
724
|
+
* This is useful for composing child tests that will benefit from the firestore testing context, but want the full app available.
|
|
725
|
+
*
|
|
726
|
+
* @param factory
|
|
727
|
+
* @returns
|
|
728
|
+
*/
|
|
729
|
+
function firebaseAdminFirestoreContextFixture(factory) {
|
|
730
|
+
return buildTests => {
|
|
731
|
+
factory(f => firebaseAdminFirestoreContextWithFixture(f, buildTests));
|
|
732
|
+
};
|
|
733
|
+
}
|
|
734
|
+
function firebaseAdminFirestoreContextWithFixture(f, buildTests) {
|
|
735
|
+
test.useTestContextFixture({
|
|
736
|
+
fixture: new test$1.TestFirestoreContextFixture(),
|
|
737
|
+
/**
|
|
738
|
+
* Build tests by passing the fixture to the testing functions.
|
|
739
|
+
*
|
|
740
|
+
* This will inject all tests and sub testing lifecycle items.
|
|
741
|
+
*/
|
|
742
|
+
buildTests,
|
|
743
|
+
initInstance: () => f.instance.getTestFirestoreInstance()
|
|
744
|
+
});
|
|
745
|
+
}
|
|
746
|
+
|
|
747
|
+
function firebaseAdminCloudFunctionWrapper(instance) {
|
|
748
|
+
const wrapV1CloudFunction = x => {
|
|
749
|
+
return instance.wrap(x);
|
|
750
|
+
};
|
|
751
|
+
const wrapV2CallableRequest = x => {
|
|
752
|
+
const wrappedCloudFunction = instance.wrap(x);
|
|
753
|
+
// context is marked optional here to better match the gen 1 callable function signature
|
|
754
|
+
return async (data, context) => {
|
|
755
|
+
const request = {
|
|
756
|
+
...context,
|
|
757
|
+
data,
|
|
758
|
+
// NOTE: These will typically not be used/available as they are express.js properties that are not available or useful to the handlers
|
|
759
|
+
rawRequest: context?.rawRequest ?? {},
|
|
760
|
+
acceptsStreaming: false
|
|
761
|
+
};
|
|
762
|
+
const result = await wrappedCloudFunction(request);
|
|
763
|
+
return result;
|
|
764
|
+
};
|
|
765
|
+
};
|
|
766
|
+
const wrapV2CloudFunction = x => {
|
|
767
|
+
return instance.wrap(x);
|
|
768
|
+
};
|
|
769
|
+
const wrapBlockingFunction = blockingFunction => {
|
|
770
|
+
return instance.wrap(blockingFunction);
|
|
771
|
+
};
|
|
772
|
+
const wrapCloudFunction = x => {
|
|
773
|
+
return instance.wrap(x);
|
|
774
|
+
};
|
|
775
|
+
const wrapper = {
|
|
776
|
+
wrapV1CloudFunction,
|
|
777
|
+
wrapV2CloudFunction,
|
|
778
|
+
wrapV2CallableRequest,
|
|
779
|
+
wrapCallableRequest: wrapV2CallableRequest,
|
|
780
|
+
wrapBlockingFunction,
|
|
781
|
+
wrapCloudFunction
|
|
782
|
+
};
|
|
783
|
+
return wrapper;
|
|
784
|
+
}
|
|
785
|
+
function wrapCloudFunctionV1ForTests(wrapper, getter) {
|
|
786
|
+
return () => wrapper.wrapV1CloudFunction(getter());
|
|
787
|
+
}
|
|
788
|
+
function wrapCallableRequestForTests(wrapper, getter) {
|
|
789
|
+
return () => wrapper.wrapCallableRequest(getter());
|
|
790
|
+
}
|
|
791
|
+
|
|
792
|
+
// MARK: FirebaseAdminFunctionTestBuilder
|
|
793
|
+
let functionsInitialized = false;
|
|
794
|
+
/**
|
|
795
|
+
* firebase-functions-test uses a singleton internally, so we must track the reference to properly tear it down too.
|
|
796
|
+
*/
|
|
797
|
+
let firebaseFunctionsTestInstance;
|
|
798
|
+
function setupFirebaseAdminFunctionTestSingleton(reroll = false) {
|
|
799
|
+
if (!isAdminEnvironmentInitialized()) {
|
|
800
|
+
throw new Error('initFirebaseAdminTestEnvironment() was not called.');
|
|
801
|
+
}
|
|
802
|
+
if (firebaseFunctionsTestInstance) {
|
|
803
|
+
firebaseFunctionsTestInstance.cleanup(); // destroy the old instance if it is up.
|
|
804
|
+
}
|
|
805
|
+
firebaseFunctionsTestInstance = functions();
|
|
806
|
+
if (reroll) {
|
|
807
|
+
rollNewGCloudProjectEnvironmentVariable();
|
|
808
|
+
} else {
|
|
809
|
+
applyFirebaseGCloudTestProjectIdToFirebaseConfigEnv();
|
|
810
|
+
}
|
|
811
|
+
functionsInitialized = true;
|
|
812
|
+
return firebaseFunctionsTestInstance;
|
|
813
|
+
}
|
|
814
|
+
function rerollFirebaseAdminFunctionTestSingleton() {
|
|
815
|
+
return setupFirebaseAdminFunctionTestSingleton(true);
|
|
816
|
+
}
|
|
817
|
+
class FirebaseAdminFunctionTestContextFixture extends test.AbstractTestContextFixture {
|
|
818
|
+
// MARK: FirebaseAdminTestContext (Forwarded)
|
|
819
|
+
get app() {
|
|
820
|
+
return this.instance.app;
|
|
821
|
+
}
|
|
822
|
+
get auth() {
|
|
823
|
+
return this.instance.auth;
|
|
824
|
+
}
|
|
825
|
+
get firestore() {
|
|
826
|
+
return this.instance.firestore;
|
|
827
|
+
}
|
|
828
|
+
get firestoreInstance() {
|
|
829
|
+
return this.instance.firestoreInstance;
|
|
830
|
+
}
|
|
831
|
+
get firestoreContext() {
|
|
832
|
+
return this.instance.firestoreContext;
|
|
833
|
+
}
|
|
834
|
+
get storage() {
|
|
835
|
+
return this.instance.storage;
|
|
836
|
+
}
|
|
837
|
+
get storageInstance() {
|
|
838
|
+
return this.instance.storageInstance;
|
|
839
|
+
}
|
|
840
|
+
get storageContext() {
|
|
841
|
+
return this.instance.storageContext;
|
|
842
|
+
}
|
|
843
|
+
get fnWrapper() {
|
|
844
|
+
return this.instance.fnWrapper;
|
|
845
|
+
}
|
|
846
|
+
}
|
|
847
|
+
class FirebaseAdminFunctionTestContextInstance extends FirebaseAdminTestContextInstance {
|
|
848
|
+
constructor(instance, app) {
|
|
849
|
+
super(app);
|
|
850
|
+
this.instance = void 0;
|
|
851
|
+
this._fnWrapper = util.cachedGetter(() => firebaseAdminCloudFunctionWrapper(this.instance));
|
|
852
|
+
this.instance = instance;
|
|
853
|
+
}
|
|
854
|
+
get fnWrapper() {
|
|
855
|
+
return this._fnWrapper();
|
|
856
|
+
}
|
|
857
|
+
}
|
|
858
|
+
exports.DEFAULT_FIREBASE_ADMIN_FUNCTION_TEST_USE_FUNCTION_SINGLETON_CONTEXT = false;
|
|
859
|
+
function setDefaultFirebaseAdminFunctionTestUseFunctionSingleton(use) {
|
|
860
|
+
exports.DEFAULT_FIREBASE_ADMIN_FUNCTION_TEST_USE_FUNCTION_SINGLETON_CONTEXT = use;
|
|
861
|
+
}
|
|
862
|
+
/**
|
|
863
|
+
* A TestContextBuilderFunction for building firebase test context factories using firebase-admin.
|
|
864
|
+
*
|
|
865
|
+
* This can be used to easily build a testing context that sets up RulesTestEnvironment for tests that sets itself up and tears itself down.
|
|
866
|
+
*/
|
|
867
|
+
const firebaseAdminFunctionTestBuilder = test.testContextBuilder({
|
|
868
|
+
buildConfig: input => {
|
|
869
|
+
const config = {
|
|
870
|
+
...input,
|
|
871
|
+
useFunctionSingletonContext: input?.useFunctionSingletonContext ?? exports.DEFAULT_FIREBASE_ADMIN_FUNCTION_TEST_USE_FUNCTION_SINGLETON_CONTEXT
|
|
872
|
+
};
|
|
873
|
+
return config;
|
|
874
|
+
},
|
|
875
|
+
buildFixture: () => new FirebaseAdminFunctionTestContextFixture(),
|
|
876
|
+
setupInstance: async config => {
|
|
877
|
+
if (!isAdminEnvironmentInitialized()) {
|
|
878
|
+
throw new Error('initFirebaseAdminTestEnvironment() (in @dereekb/firebase-server package) was not called before using adminFirebaseTestBuilder().');
|
|
879
|
+
}
|
|
880
|
+
if (config.useFunctionSingletonContext) {
|
|
881
|
+
if (!functionsInitialized) {
|
|
882
|
+
throw new Error('Call setupFirebaseAdminFunctionTestSingleton() (in @dereekb/firebase-server package) if using functions in a singleton context (useFunctionSingletonContext = true/undefined).');
|
|
883
|
+
}
|
|
884
|
+
} else if (config.useFunctionSingletonContext === false) {
|
|
885
|
+
firebaseFunctionsTestInstance = rerollFirebaseAdminFunctionTestSingleton();
|
|
886
|
+
}
|
|
887
|
+
const projectId = getGCloudTestProjectId();
|
|
888
|
+
const storageBucket = 'b-' + projectId;
|
|
889
|
+
const app = admin.initializeApp({
|
|
890
|
+
projectId,
|
|
891
|
+
storageBucket
|
|
892
|
+
});
|
|
893
|
+
return new FirebaseAdminFunctionTestContextInstance(firebaseFunctionsTestInstance, app);
|
|
894
|
+
},
|
|
895
|
+
teardownInstance: async (instance, config) => {
|
|
896
|
+
if (config.useFunctionSingletonContext === false) {
|
|
897
|
+
try {
|
|
898
|
+
await instance.app.delete(); // will be called in cleanup
|
|
899
|
+
firebaseFunctionsTestInstance.cleanup();
|
|
900
|
+
} catch (e) {
|
|
901
|
+
// do nothing
|
|
902
|
+
}
|
|
903
|
+
firebaseFunctionsTestInstance = undefined;
|
|
904
|
+
}
|
|
905
|
+
}
|
|
906
|
+
});
|
|
907
|
+
const firebaseAdminFunctionTestContextFactory = firebaseAdminFunctionTestBuilder({});
|
|
908
|
+
|
|
909
|
+
class FirebaseAdminNestTestContextFixture extends test.AbstractChildTestContextFixture {
|
|
910
|
+
// MARK: Forwarded
|
|
911
|
+
get nest() {
|
|
912
|
+
return this.instance.nest;
|
|
913
|
+
}
|
|
914
|
+
get nestAppPromiseGetter() {
|
|
915
|
+
return this.instance.nestAppPromiseGetter;
|
|
916
|
+
}
|
|
917
|
+
get(typeOrToken, options) {
|
|
918
|
+
return this.instance.get(typeOrToken, options);
|
|
919
|
+
}
|
|
920
|
+
}
|
|
921
|
+
class FirebaseAdminNestTestContextInstance extends AbstractFirebaseAdminTestContextInstanceChild {
|
|
922
|
+
constructor(parent, nest) {
|
|
923
|
+
super(parent);
|
|
924
|
+
this.nest = void 0;
|
|
925
|
+
this.nestAppPromiseGetter = () => Promise.resolve(this.nest);
|
|
926
|
+
this.nest = nest;
|
|
927
|
+
}
|
|
928
|
+
get(typeOrToken, options) {
|
|
929
|
+
return options ? this.nest.get(typeOrToken, options) : this.nest.get(typeOrToken);
|
|
930
|
+
}
|
|
931
|
+
}
|
|
932
|
+
function firebaseAdminNestContextFixture(config, factory) {
|
|
933
|
+
return buildTests => {
|
|
934
|
+
factory(f => firebaseAdminNestContextWithFixture(config, f, buildTests));
|
|
935
|
+
};
|
|
936
|
+
}
|
|
937
|
+
class FirebaseAdminNestRootModule {}
|
|
938
|
+
function firebaseAdminNestContextWithFixture(config, f, buildTests) {
|
|
939
|
+
const {
|
|
940
|
+
nestModules,
|
|
941
|
+
makeProviders = () => [],
|
|
942
|
+
forceStorageBucket = false,
|
|
943
|
+
defaultStorageBucket: inputDefaultStorageBucket,
|
|
944
|
+
envConfig,
|
|
945
|
+
injectFirebaseServerAppTokenProvider,
|
|
946
|
+
injectServerEnvServiceProvider,
|
|
947
|
+
makeFixture = parent => new FirebaseAdminNestTestContextFixture(parent),
|
|
948
|
+
makeInstance = (instance, nest) => new FirebaseAdminNestTestContextInstance(instance, nest),
|
|
949
|
+
initInstance
|
|
950
|
+
} = config;
|
|
951
|
+
test.useTestContextFixture({
|
|
952
|
+
fixture: makeFixture(f),
|
|
953
|
+
/**
|
|
954
|
+
* Build tests by passing the fixture to the testing functions.
|
|
955
|
+
*
|
|
956
|
+
* This will inject all tests and sub Jest lifecycle items.
|
|
957
|
+
*/
|
|
958
|
+
buildTests,
|
|
959
|
+
initInstance: async () => {
|
|
960
|
+
const imports = util.asArray(nestModules);
|
|
961
|
+
const providers = makeProviders(f.instance) ?? [];
|
|
962
|
+
const defaultStorageBucket = inputDefaultStorageBucket ?? f.instance.app.options.storageBucket;
|
|
963
|
+
// Inject the serverEnvTokenProvider and optionally the FirebaseServerEnvService
|
|
964
|
+
if (injectServerEnvServiceProvider !== false || envConfig != null) {
|
|
965
|
+
providers.push(nestjs.serverEnvTokenProvider(envConfig || {
|
|
966
|
+
production: false
|
|
967
|
+
}));
|
|
968
|
+
if (injectServerEnvServiceProvider !== false) {
|
|
969
|
+
providers.push({
|
|
970
|
+
provide: firebaseServer.FirebaseServerEnvService,
|
|
971
|
+
useClass: firebaseServer.DefaultFirebaseServerEnvService
|
|
972
|
+
}, {
|
|
973
|
+
provide: nestjs.ServerEnvironmentService,
|
|
974
|
+
useExisting: firebaseServer.FirebaseServerEnvService
|
|
975
|
+
});
|
|
976
|
+
}
|
|
977
|
+
}
|
|
978
|
+
// Inject the firebaseServerAppTokenProvider
|
|
979
|
+
if (injectFirebaseServerAppTokenProvider) {
|
|
980
|
+
providers.push(firebaseServer.firebaseServerAppTokenProvider(util.asGetter(f.instance.app)));
|
|
981
|
+
}
|
|
982
|
+
if (defaultStorageBucket) {
|
|
983
|
+
providers.push(firebaseServer.firebaseServerStorageDefaultBucketIdTokenProvider({
|
|
984
|
+
defaultBucketId: defaultStorageBucket,
|
|
985
|
+
forceBucket: forceStorageBucket
|
|
986
|
+
}));
|
|
987
|
+
}
|
|
988
|
+
const rootModule = {
|
|
989
|
+
module: FirebaseAdminNestRootModule,
|
|
990
|
+
providers,
|
|
991
|
+
exports: providers,
|
|
992
|
+
global: true
|
|
993
|
+
};
|
|
994
|
+
const builder = testing.Test.createTestingModule({
|
|
995
|
+
imports: [rootModule, ...imports]
|
|
996
|
+
});
|
|
997
|
+
const nest = await builder.compile();
|
|
998
|
+
const instance = makeInstance(f.instance, nest);
|
|
999
|
+
if (initInstance) {
|
|
1000
|
+
await initInstance(instance);
|
|
1001
|
+
}
|
|
1002
|
+
return instance;
|
|
1003
|
+
},
|
|
1004
|
+
destroyInstance: async instance => {
|
|
1005
|
+
await instance.nest.close();
|
|
1006
|
+
}
|
|
1007
|
+
});
|
|
1008
|
+
}
|
|
1009
|
+
function firebaseAdminNestContextFactory(config) {
|
|
1010
|
+
return firebaseAdminNestContextFixture(config, firebaseAdminTestContextFactory);
|
|
1011
|
+
}
|
|
1012
|
+
|
|
1013
|
+
function wrapCloudFunctionForNestTestsGetter(wrapper, fn) {
|
|
1014
|
+
return wrapCloudFunctionV1ForTests(wrapper.fnWrapper, () => fn(wrapper.nestAppPromiseGetter));
|
|
1015
|
+
}
|
|
1016
|
+
function wrapCallableRequestForNestTestsGetter(wrapper, fn) {
|
|
1017
|
+
return wrapCallableRequestForTests(wrapper.fnWrapper, () => fn(wrapper.nestAppPromiseGetter));
|
|
1018
|
+
}
|
|
1019
|
+
class FirebaseAdminFunctionNestTestContextFixture extends FirebaseAdminNestTestContextFixture {
|
|
1020
|
+
// MARK: FirebaseAdminTestContext (Forwarded)
|
|
1021
|
+
wrapCloudFunctionForNestTests(fn) {
|
|
1022
|
+
return this.wrapCloudFunctionForNestTestsGetter(fn)();
|
|
1023
|
+
}
|
|
1024
|
+
wrapCloudFunctionForNestTestsGetter(fn) {
|
|
1025
|
+
return wrapCloudFunctionForNestTestsGetter(this, fn);
|
|
1026
|
+
}
|
|
1027
|
+
wrapCallableRequestForNestTests(fn) {
|
|
1028
|
+
return this.wrapCallableRequestForNestTestsGetter(fn)();
|
|
1029
|
+
}
|
|
1030
|
+
wrapCallableRequestForNestTestsGetter(fn) {
|
|
1031
|
+
return wrapCallableRequestForNestTestsGetter(this, fn);
|
|
1032
|
+
}
|
|
1033
|
+
// MARK: FirebaseAdminCloudFunctionWrapperSource
|
|
1034
|
+
get fnWrapper() {
|
|
1035
|
+
return this.parent.instance.fnWrapper;
|
|
1036
|
+
}
|
|
1037
|
+
}
|
|
1038
|
+
class FirebaseAdminFunctionNestTestContextInstance extends FirebaseAdminNestTestContextInstance {
|
|
1039
|
+
// MARK: FirebaseAdminTestContext (Forwarded)
|
|
1040
|
+
get fnWrapper() {
|
|
1041
|
+
return this.parent.fnWrapper;
|
|
1042
|
+
}
|
|
1043
|
+
}
|
|
1044
|
+
function firebaseAdminFunctionNestContextFixture(config, factory) {
|
|
1045
|
+
return buildTests => {
|
|
1046
|
+
factory(f => firebaseAdminFunctionNestContextWithFixture(config, f, buildTests));
|
|
1047
|
+
};
|
|
1048
|
+
}
|
|
1049
|
+
class FirebaseAdminFunctionNestRootModule {}
|
|
1050
|
+
function firebaseAdminFunctionNestContextWithFixture(config, f, buildTests) {
|
|
1051
|
+
const mergedConfig = {
|
|
1052
|
+
makeFixture: parent => new FirebaseAdminFunctionNestTestContextFixture(parent),
|
|
1053
|
+
makeInstance: (instance, nest) => new FirebaseAdminFunctionNestTestContextInstance(instance, nest),
|
|
1054
|
+
...config
|
|
1055
|
+
};
|
|
1056
|
+
return firebaseAdminNestContextWithFixture(mergedConfig, f, buildTests);
|
|
1057
|
+
}
|
|
1058
|
+
function firebaseAdminFunctionNestContextFactory(config) {
|
|
1059
|
+
return firebaseAdminFunctionNestContextFixture(config, firebaseAdminFunctionTestContextFactory);
|
|
1060
|
+
}
|
|
1061
|
+
|
|
1062
|
+
const CallableRequestTestMultipleFixtureSuffix = 'WrappedFn';
|
|
1063
|
+
function isCallableRequestTestSingleConfig(config) {
|
|
1064
|
+
const isSingle = Boolean(config.fn);
|
|
1065
|
+
return isSingle;
|
|
1066
|
+
}
|
|
1067
|
+
function callableRequestTest(config, buildTests) {
|
|
1068
|
+
if (isCallableRequestTestSingleConfig(config)) {
|
|
1069
|
+
const {
|
|
1070
|
+
f,
|
|
1071
|
+
fn
|
|
1072
|
+
} = config;
|
|
1073
|
+
test.useTestFunctionFixture({
|
|
1074
|
+
fn: () => {
|
|
1075
|
+
const x = wrapCallableRequestForNestTestsGetter(f, fn)();
|
|
1076
|
+
return x;
|
|
1077
|
+
}
|
|
1078
|
+
}, buildTests);
|
|
1079
|
+
} else {
|
|
1080
|
+
const {
|
|
1081
|
+
f,
|
|
1082
|
+
fns: inputFns
|
|
1083
|
+
} = config;
|
|
1084
|
+
const mappedFns = util.mapObjectMap(inputFns, fn => () => wrapCallableRequestForNestTestsGetter(f, fn)());
|
|
1085
|
+
const fns = {};
|
|
1086
|
+
Object.keys(mappedFns).forEach(key => {
|
|
1087
|
+
fns[`${key}${CallableRequestTestMultipleFixtureSuffix}`] = mappedFns[key];
|
|
1088
|
+
});
|
|
1089
|
+
test.useTestFunctionMapFixture({
|
|
1090
|
+
fns
|
|
1091
|
+
}, buildTests);
|
|
1092
|
+
}
|
|
1093
|
+
}
|
|
1094
|
+
function describeCallableRequestTest(label, config, buildTests) {
|
|
1095
|
+
describe(label, () => {
|
|
1096
|
+
callableRequestTest(config, buildTests);
|
|
1097
|
+
});
|
|
1098
|
+
}
|
|
1099
|
+
|
|
1100
|
+
function isCloudFunctionTestSingleConfig(config) {
|
|
1101
|
+
const isSingle = Boolean(config.fn);
|
|
1102
|
+
return isSingle;
|
|
1103
|
+
}
|
|
1104
|
+
function cloudFunctionTest(config, buildTests) {
|
|
1105
|
+
if (isCloudFunctionTestSingleConfig(config)) {
|
|
1106
|
+
const {
|
|
1107
|
+
f,
|
|
1108
|
+
fn
|
|
1109
|
+
} = config;
|
|
1110
|
+
test.useTestFunctionFixture({
|
|
1111
|
+
fn: () => {
|
|
1112
|
+
const x = wrapCloudFunctionForNestTestsGetter(f, fn)();
|
|
1113
|
+
return x;
|
|
1114
|
+
}
|
|
1115
|
+
}, buildTests);
|
|
1116
|
+
} else {
|
|
1117
|
+
const {
|
|
1118
|
+
f,
|
|
1119
|
+
fns: inputFns
|
|
1120
|
+
} = config;
|
|
1121
|
+
const mappedFns = util.mapObjectMap(inputFns, fn => () => wrapCloudFunctionForNestTestsGetter(f, fn)());
|
|
1122
|
+
const fns = {};
|
|
1123
|
+
Object.keys(mappedFns).forEach(key => {
|
|
1124
|
+
fns[`${key}CloudFn`] = mappedFns[key];
|
|
1125
|
+
});
|
|
1126
|
+
test.useTestFunctionMapFixture({
|
|
1127
|
+
fns
|
|
1128
|
+
}, buildTests);
|
|
1129
|
+
}
|
|
1130
|
+
}
|
|
1131
|
+
function describeCloudFunctionTest(label, config, buildTests) {
|
|
1132
|
+
describe(label, () => {
|
|
1133
|
+
cloudFunctionTest(config, buildTests);
|
|
1134
|
+
});
|
|
1135
|
+
}
|
|
1136
|
+
|
|
1137
|
+
function initFirebaseServerAdminTestEnvironment() {
|
|
1138
|
+
initFirebaseAdminTestEnvironment({
|
|
1139
|
+
emulators: {
|
|
1140
|
+
auth: '0.0.0.0:9903',
|
|
1141
|
+
firestore: '0.0.0.0:9904',
|
|
1142
|
+
storage: '0.0.0.0:9906'
|
|
1143
|
+
}
|
|
1144
|
+
});
|
|
1145
|
+
}
|
|
1146
|
+
function describeFirestoreTest(s) {
|
|
1147
|
+
let collection;
|
|
1148
|
+
beforeEach(() => {
|
|
1149
|
+
collection = test$1.mockItemFirestoreCollection(s.firestoreContext);
|
|
1150
|
+
});
|
|
1151
|
+
describe('firestore', () => {
|
|
1152
|
+
it('should interact with the firestore.', async () => {
|
|
1153
|
+
const document = collection.documentAccessor().newDocument();
|
|
1154
|
+
const setData = {
|
|
1155
|
+
value: 'a',
|
|
1156
|
+
test: true
|
|
1157
|
+
};
|
|
1158
|
+
await document.accessor.set(setData);
|
|
1159
|
+
const exists = await document.accessor.exists();
|
|
1160
|
+
expect(exists).toBe(true);
|
|
1161
|
+
const snapshot = await document.accessor.get();
|
|
1162
|
+
const data = snapshot.data();
|
|
1163
|
+
expect(data).toBeDefined();
|
|
1164
|
+
});
|
|
1165
|
+
});
|
|
1166
|
+
}
|
|
1167
|
+
|
|
1168
|
+
/**
|
|
1169
|
+
* Error thrown when the error type was different than the expected type.
|
|
1170
|
+
*/
|
|
1171
|
+
class ExpectedHttpErrorWithSpecificServerErrorCode extends makeError.BaseError {
|
|
1172
|
+
constructor(httpError, expectedErrorCode) {
|
|
1173
|
+
const {
|
|
1174
|
+
code
|
|
1175
|
+
} = httpError.details;
|
|
1176
|
+
super(`Expected HttpError with an error code of "${expectedErrorCode}", but recieved "${code}" instead.`);
|
|
1177
|
+
this.httpError = void 0;
|
|
1178
|
+
this.expectedErrorCode = void 0;
|
|
1179
|
+
this.httpError = httpError;
|
|
1180
|
+
this.expectedErrorCode = expectedErrorCode;
|
|
1181
|
+
}
|
|
1182
|
+
}
|
|
1183
|
+
/**
|
|
1184
|
+
* Creates a ExpectFailAssertionFunction that asserts the encountered error is of the expected type using the instanceof keyword.
|
|
1185
|
+
*
|
|
1186
|
+
* Throws a ExpectedErrorOfSpecificTypeError if the input is not a HttpsError.
|
|
1187
|
+
* Throws a ExpectedHttpErrorWithSpecificServerErrorCode if the input's server error data has a different error code.
|
|
1188
|
+
*
|
|
1189
|
+
* @param expectedType
|
|
1190
|
+
* @returns
|
|
1191
|
+
*/
|
|
1192
|
+
function expectFailAssertHttpErrorServerErrorCode(expectedCode) {
|
|
1193
|
+
return error => {
|
|
1194
|
+
if (error instanceof https.HttpsError) {
|
|
1195
|
+
const {
|
|
1196
|
+
code
|
|
1197
|
+
} = error.details;
|
|
1198
|
+
if (code !== expectedCode) {
|
|
1199
|
+
throw new ExpectedHttpErrorWithSpecificServerErrorCode(error, expectedCode);
|
|
1200
|
+
}
|
|
1201
|
+
} else {
|
|
1202
|
+
throw new test.ExpectedErrorOfSpecificTypeError(error, https.HttpsError);
|
|
1203
|
+
}
|
|
1204
|
+
return true;
|
|
1205
|
+
};
|
|
1206
|
+
}
|
|
1207
|
+
// MARK: Compat
|
|
1208
|
+
/**
|
|
1209
|
+
* @deprecated Use ExpectedHttpErrorWithSpecificServerErrorCode from shared instead. This is kept for backwards compatibility.
|
|
1210
|
+
*/
|
|
1211
|
+
class JestExpectedHttpErrorWithSpecificServerErrorCode extends ExpectedHttpErrorWithSpecificServerErrorCode {}
|
|
1212
|
+
/**
|
|
1213
|
+
* @deprecated Use expectFailAssertHttpErrorServerErrorCode from shared instead. This is kept for backwards compatibility.
|
|
1214
|
+
*/
|
|
1215
|
+
const jestExpectFailAssertHttpErrorServerErrorCode = expectFailAssertHttpErrorServerErrorCode;
|
|
1216
|
+
|
|
1217
|
+
/**
|
|
1218
|
+
* Default firestore admin factory.
|
|
1219
|
+
*
|
|
1220
|
+
* Host of localhost, port 9904
|
|
1221
|
+
*/
|
|
1222
|
+
const adminFirestoreFactory = googleCloudTestFirestoreBuilder({
|
|
1223
|
+
host: 'localhost',
|
|
1224
|
+
port: 9904
|
|
1225
|
+
});
|
|
1226
|
+
/**
|
|
1227
|
+
* Convenience mock instance for tests within an authorized context.
|
|
1228
|
+
*
|
|
1229
|
+
* Uses @google-cloud/firestore
|
|
1230
|
+
*/
|
|
1231
|
+
const dbxComponentsAdminTestWithMockItemCollection = test$1.testWithMockItemCollectionFixture()(adminFirestoreFactory);
|
|
1232
|
+
|
|
1233
|
+
/**
|
|
1234
|
+
* Default firestore admin factory.
|
|
1235
|
+
*
|
|
1236
|
+
* Host of localhost, port 9906
|
|
1237
|
+
*/
|
|
1238
|
+
const adminFirebaseStorageFactory = googleCloudTestFirebaseStorageBuilder({
|
|
1239
|
+
host: '0.0.0.0',
|
|
1240
|
+
port: 9906
|
|
1241
|
+
});
|
|
1242
|
+
/**
|
|
1243
|
+
* Convenience mock instance for tests within an authorized context.
|
|
1244
|
+
*
|
|
1245
|
+
* Uses @google-cloud/firestore
|
|
1246
|
+
*/
|
|
1247
|
+
const dbxComponentsAdminTestWithMockItemStorage = test$1.testWithMockItemStorageFixture()(adminFirebaseStorageFactory);
|
|
1248
|
+
|
|
1249
|
+
exports.AUTHORIZED_USER_RANDOM_EMAIL_FACTORY = AUTHORIZED_USER_RANDOM_EMAIL_FACTORY;
|
|
1250
|
+
exports.AUTHORIZED_USER_RANDOM_PHONE_NUMBER_FACTORY = AUTHORIZED_USER_RANDOM_PHONE_NUMBER_FACTORY;
|
|
1251
|
+
exports.AbstractFirebaseAdminTestContextInstanceChild = AbstractFirebaseAdminTestContextInstanceChild;
|
|
1252
|
+
exports.AuthorizedUserTestContextFixture = AuthorizedUserTestContextFixture;
|
|
1253
|
+
exports.AuthorizedUserTestContextInstance = AuthorizedUserTestContextInstance;
|
|
1254
|
+
exports.CallableRequestTestMultipleFixtureSuffix = CallableRequestTestMultipleFixtureSuffix;
|
|
1255
|
+
exports.ExpectedHttpErrorWithSpecificServerErrorCode = ExpectedHttpErrorWithSpecificServerErrorCode;
|
|
1256
|
+
exports.FirebaseAdminFunctionNestRootModule = FirebaseAdminFunctionNestRootModule;
|
|
1257
|
+
exports.FirebaseAdminFunctionNestTestContextFixture = FirebaseAdminFunctionNestTestContextFixture;
|
|
1258
|
+
exports.FirebaseAdminFunctionNestTestContextInstance = FirebaseAdminFunctionNestTestContextInstance;
|
|
1259
|
+
exports.FirebaseAdminFunctionTestContextFixture = FirebaseAdminFunctionTestContextFixture;
|
|
1260
|
+
exports.FirebaseAdminFunctionTestContextInstance = FirebaseAdminFunctionTestContextInstance;
|
|
1261
|
+
exports.FirebaseAdminNestRootModule = FirebaseAdminNestRootModule;
|
|
1262
|
+
exports.FirebaseAdminNestTestContextFixture = FirebaseAdminNestTestContextFixture;
|
|
1263
|
+
exports.FirebaseAdminNestTestContextInstance = FirebaseAdminNestTestContextInstance;
|
|
1264
|
+
exports.FirebaseAdminTestContextFixture = FirebaseAdminTestContextFixture;
|
|
1265
|
+
exports.FirebaseAdminTestContextInstance = FirebaseAdminTestContextInstance;
|
|
1266
|
+
exports.GoogleCloudTestFirebaseStorageContextFixture = GoogleCloudTestFirebaseStorageContextFixture;
|
|
1267
|
+
exports.GoogleCloudTestFirebaseStorageInstance = GoogleCloudTestFirebaseStorageInstance;
|
|
1268
|
+
exports.GoogleCloudTestFirestoreContextFixture = GoogleCloudTestFirestoreContextFixture;
|
|
1269
|
+
exports.GoogleCloudTestFirestoreInstance = GoogleCloudTestFirestoreInstance;
|
|
1270
|
+
exports.JestExpectedHttpErrorWithSpecificServerErrorCode = JestExpectedHttpErrorWithSpecificServerErrorCode;
|
|
1271
|
+
exports.ModelTestContextFixture = ModelTestContextFixture;
|
|
1272
|
+
exports.ModelTestContextInstance = ModelTestContextInstance;
|
|
1273
|
+
exports.adminFirebaseStorageFactory = adminFirebaseStorageFactory;
|
|
1274
|
+
exports.adminFirestoreFactory = adminFirestoreFactory;
|
|
1275
|
+
exports.applyFirebaseGCloudTestProjectIdToFirebaseConfigEnv = applyFirebaseGCloudTestProjectIdToFirebaseConfigEnv;
|
|
1276
|
+
exports.authorizedUserContext = authorizedUserContext;
|
|
1277
|
+
exports.authorizedUserContextFactory = authorizedUserContextFactory;
|
|
1278
|
+
exports.callableRequestTest = callableRequestTest;
|
|
1279
|
+
exports.cloudFunctionTest = cloudFunctionTest;
|
|
1280
|
+
exports.createEncodedTestFirestoreTokenForUserRecord = createEncodedTestFirestoreTokenForUserRecord;
|
|
1281
|
+
exports.createTestFirestoreTokenForUserRecord = createTestFirestoreTokenForUserRecord;
|
|
1282
|
+
exports.createTestFunctionContextAuthData = createTestFunctionContextAuthData;
|
|
1283
|
+
exports.createTestFunctionContextOptions = createTestFunctionContextOptions;
|
|
1284
|
+
exports.dbxComponentsAdminTestWithMockItemCollection = dbxComponentsAdminTestWithMockItemCollection;
|
|
1285
|
+
exports.dbxComponentsAdminTestWithMockItemStorage = dbxComponentsAdminTestWithMockItemStorage;
|
|
1286
|
+
exports.decodeEncodedCreateCustomTokenResult = decodeEncodedCreateCustomTokenResult;
|
|
1287
|
+
exports.describeCallableRequestTest = describeCallableRequestTest;
|
|
1288
|
+
exports.describeCloudFunctionTest = describeCloudFunctionTest;
|
|
1289
|
+
exports.describeFirestoreTest = describeFirestoreTest;
|
|
1290
|
+
exports.expectFailAssertHttpErrorServerErrorCode = expectFailAssertHttpErrorServerErrorCode;
|
|
1291
|
+
exports.firebaseAdminFirestoreContextFixture = firebaseAdminFirestoreContextFixture;
|
|
1292
|
+
exports.firebaseAdminFirestoreContextWithFixture = firebaseAdminFirestoreContextWithFixture;
|
|
1293
|
+
exports.firebaseAdminFunctionNestContextFactory = firebaseAdminFunctionNestContextFactory;
|
|
1294
|
+
exports.firebaseAdminFunctionNestContextFixture = firebaseAdminFunctionNestContextFixture;
|
|
1295
|
+
exports.firebaseAdminFunctionNestContextWithFixture = firebaseAdminFunctionNestContextWithFixture;
|
|
1296
|
+
exports.firebaseAdminFunctionTestBuilder = firebaseAdminFunctionTestBuilder;
|
|
1297
|
+
exports.firebaseAdminFunctionTestContextFactory = firebaseAdminFunctionTestContextFactory;
|
|
1298
|
+
exports.firebaseAdminNestContextFactory = firebaseAdminNestContextFactory;
|
|
1299
|
+
exports.firebaseAdminNestContextFixture = firebaseAdminNestContextFixture;
|
|
1300
|
+
exports.firebaseAdminNestContextWithFixture = firebaseAdminNestContextWithFixture;
|
|
1301
|
+
exports.firebaseAdminTestBuilder = firebaseAdminTestBuilder;
|
|
1302
|
+
exports.firebaseAdminTestContextFactory = firebaseAdminTestContextFactory;
|
|
1303
|
+
exports.generateNewProjectId = generateNewProjectId;
|
|
1304
|
+
exports.getGCloudProjectId = getGCloudProjectId;
|
|
1305
|
+
exports.getGCloudTestProjectId = getGCloudTestProjectId;
|
|
1306
|
+
exports.googleCloudTestFirebaseStorageBuilder = googleCloudTestFirebaseStorageBuilder;
|
|
1307
|
+
exports.googleCloudTestFirestoreBuilder = googleCloudTestFirestoreBuilder;
|
|
1308
|
+
exports.initFirebaseAdminTestEnvironment = initFirebaseAdminTestEnvironment;
|
|
1309
|
+
exports.initFirebaseServerAdminTestEnvironment = initFirebaseServerAdminTestEnvironment;
|
|
1310
|
+
exports.isAdminEnvironmentInitialized = isAdminEnvironmentInitialized;
|
|
1311
|
+
exports.isCallableRequestTestSingleConfig = isCallableRequestTestSingleConfig;
|
|
1312
|
+
exports.isCloudFunctionTestSingleConfig = isCloudFunctionTestSingleConfig;
|
|
1313
|
+
exports.jestExpectFailAssertHttpErrorServerErrorCode = jestExpectFailAssertHttpErrorServerErrorCode;
|
|
1314
|
+
exports.makeGoogleFirebaseStorageContext = makeGoogleFirebaseStorageContext;
|
|
1315
|
+
exports.makeGoogleFirestoreContext = makeGoogleFirestoreContext;
|
|
1316
|
+
exports.modelTestContextFactory = modelTestContextFactory;
|
|
1317
|
+
exports.rerollFirebaseAdminFunctionTestSingleton = rerollFirebaseAdminFunctionTestSingleton;
|
|
1318
|
+
exports.rollNewGCloudProjectEnvironmentVariable = rollNewGCloudProjectEnvironmentVariable;
|
|
1319
|
+
exports.setDefaultFirebaseAdminFunctionTestUseFunctionSingleton = setDefaultFirebaseAdminFunctionTestUseFunctionSingleton;
|
|
1320
|
+
exports.setupFirebaseAdminFunctionTestSingleton = setupFirebaseAdminFunctionTestSingleton;
|
|
1321
|
+
exports.testFirestoreClaimsFromUserRecord = testFirestoreClaimsFromUserRecord;
|
|
1322
|
+
exports.testUidFactory = testUidFactory;
|
|
1323
|
+
exports.wrapCallableRequestForNestTestsGetter = wrapCallableRequestForNestTestsGetter;
|
|
1324
|
+
exports.wrapCloudFunctionForNestTestsGetter = wrapCloudFunctionForNestTestsGetter;
|