@@ -163,19 +163,21 @@ pytest --cov=firebase_admin --cov=tests
163
163
### Integration Testing
164
164
165
165
166
- A suite of integration tests are available under the ` integration/ ` directory. These tests
167
- are designed to run against an actual Firebase project. If you do not already have one
168
- suitable for running the tests against, you can create a new project in the
166
+ Integration tests are executed against a real life Firebase project. If you do not already
167
+ have one suitable for running the tests against, you can create a new project in the
169
168
[ Firebase Console] ( https://console.firebase.google.com ) following the setup guide below.
170
- Otherwise you can obtain the following credentials from your current project:
169
+ If you already have a Firebase project, you'll need to obtain credentials to communicate and
170
+ authorize access to your Firebase project:
171
171
172
172
173
- 1 . Service account certificate: This can be downloaded as a JSON file from the
174
- ** 'Settings > Service Accounts'** tab of the Firebase console when you click the
175
- ** 'Generate new private key'** button. Copy the file into the repo so it's available at ` cert.json ` .
173
+ 1 . Service account certificate: This allows access to your Firebase project through a service account
174
+ which is required for all integration tests. This can be downloaded as a JSON file from the
175
+ ** Settings > Service Accounts** tab of the Firebase console when you click the
176
+ ** Generate new private key** button. Copy the file into the repo so it's available at ` cert.json ` .
176
177
177
178
178
- 2 . Web API key: This is displayed in the ** 'Settings > General'** tab of the Firebase console
179
+ 2 . Web API key: This allows for Auth sign-in needed for some Authentication and Tenant Management
180
+ integration tests. This is displayed in the ** Settings > General** tab of the Firebase console
179
181
after enabling Authentication as described in the steps below. Copy it and save to a new text
180
182
file at ` apikey.txt ` .
181
183
@@ -184,65 +186,70 @@ Set up your Firebase project as follows:
184
186
185
187
186
188
1 . Enable Authentication:
187
- 1 . Go to the Firebase Console, and select ** ' Authentication' ** from the ** ' Build' ** menu.
188
- 2 . Click on ** ' Get Started' ** .
189
- 3 . Select ** ' Sign-in method > Add new provider > Email/Password' ** then enable both the
190
- ** ' Email/Password' ** and ** ' Email link (passwordless sign-in)' ** options.
189
+ 1 . Go to the Firebase Console, and select ** Authentication** from the ** Build** menu.
190
+ 2 . Click on ** Get Started** .
191
+ 3 . Select ** Sign-in method > Add new provider > Email/Password** then enable both the
192
+ ** Email/Password** and ** Email link (passwordless sign-in)** options.
191
193
192
194
193
195
2 . Enable Firestore:
194
- 1 . Go to the Firebase Console, and select ** ' Firestore Database' ** from the ** ' Build' ** menu.
195
- 2 . Click on the ** ' Create database' ** button. You can choose to set up Firestore either in
196
+ 1 . Go to the Firebase Console, and select ** Firestore Database** from the ** Build** menu.
197
+ 2 . Click on the ** Create database** button. You can choose to set up Firestore either in
196
198
the production mode or in the test mode.
197
199
198
200
199
201
3 . Enable Realtime Database:
200
- 1 . Go to the Firebase Console, and select ** ' Realtime Database' ** from the ** ' Build' ** menu.
201
- 2 . Click on the ** ' Create database' ** button. You can choose to set up the Realtime database
202
+ 1 . Go to the Firebase Console, and select ** Realtime Database** from the ** Build** menu.
203
+ 2 . Click on the ** Create Database ** button. You can choose to set up the Realtime Database
202
204
either in the locked mode or in the test mode.
203
- 3 . In the ** 'Data'** tab click on the kebab menu (3 dots) and select ** 'Create Database'** .
204
- 4 . Enter your Project ID (Found in the ** 'General'** tab in ** 'Account Settings'** ) as the
205
- ** 'Realtime Database reference'** . Again, you can choose to set up the Realtime database
205
+
206
+ > ** Note:** Integration tests are not run against the default Realtime Database reference and are
207
+ instead run against a database created at ` https://{PROJECT_ID}.firebaseio.com ` .
208
+ This second Realtime Database reference is created in the following steps.
209
+
210
+ 3 . In the ** Data** tab click on the kebab menu (3 dots) and select ** Create Database** .
211
+ 4 . Enter your Project ID (Found in the ** General** tab in ** Account Settings** ) as the
212
+ ** Realtime Database reference** . Again, you can choose to set up the Realtime Database
206
213
either in the locked mode or in the test mode.
207
214
208
215
209
216
4 . Enable Storage:
210
- 1 . Go to the Firebase Console, and select ** ' Storage' ** from the ** ' Build' ** menu.
211
- 2 . Click on the ** ' Get started' ** button. You can choose to set up the Realtime database
217
+ 1 . Go to the Firebase Console, and select ** Storage** from the ** Build** menu.
218
+ 2 . Click on the ** Get started** button. You can choose to set up Cloud Storage
212
219
either in the production mode or in the test mode.
213
220
214
221
215
222
5 . Enable the Firebase ML API:
216
223
1 . Go to the
217
- [ Google Developers Console | Firebase ML API] ( https://console.developers .google.com/apis/api/firebaseml.googleapis.com/overview )
224
+ [ Google Cloud console | Firebase ML API] ( https://console.cloud .google.com/apis/api/firebaseml.googleapis.com/overview )
218
225
and make sure your project is selected.
219
- 2 . If the API is not already enabled, click ** ' Enable' ** .
226
+ 2 . If the API is not already enabled, click ** Enable** .
220
227
221
228
222
229
6 . Enable the IAM API:
223
- 1 . Go to the[ Google Cloud Platform Console ] ( https://console.cloud.google.com )
224
- and make sureyour Firebase project is selected.
225
- 2 . Select ** ' APIs & Services' ** from the main menu, and click the
226
- ** ' ENABLE APIS AND SERVICES' ** button.
227
- 3 . Search for and enable ** ' Identity and Access Management (IAM) API' ** by Google Enterprise API.
230
+ 1 . Go to the [ Google Cloud console ] ( https://console.cloud.google.com )
231
+ and make sure your Firebase project is selected.
232
+ 2 . Select ** APIs & Services** from the main menu, and click the
233
+ ** ENABLE APIS AND SERVICES** button.
234
+ 3 . Search for and enable ** Identity and Access Management (IAM) API** by Google Enterprise API.
228
235
229
236
230
237
7 . Enable Tenant Management:
231
238
1 . Go to
232
- [ Google Developers Console | Identity Platform] ( https://console.cloud.google.com/customer-identity/ )
233
- and if it is not already enabled, click ** ' Enable' ** .
234
- 2 . Then follow
235
- [ this guide ] ( https://cloud.google.com/identity-platform/docs/multi-tenancy-quickstart#enabling_multi-tenancy )
236
- to enable multi-tenancy .
239
+ [ Google Cloud console | Identity Platform] ( https://console.cloud.google.com/customer-identity/ )
240
+ and if it is not already enabled, click ** Enable** .
241
+ 2 . Then
242
+ [ enable multi-tenancy ] ( https://cloud.google.com/identity-platform/docs/multi-tenancy-quickstart#enabling_multi-tenancy )
243
+ for your project .
237
244
238
245
239
- 8 . Ensure your service account has the ** ' Firebase Authentication Admin' ** role. This is required
246
+ 8 . Ensure your service account has the ** Firebase Authentication Admin** role. This is required
240
247
to ensure that exported user records contain the password hashes of the user accounts:
241
- 1 . Go to [ Google Cloud Platform Console / IAM & admin] ( https://console.cloud.google.com/iam-admin ) .
242
- 2 . Find your service account in the list. If not added click the ** ' pencil' ** icon to edit its
248
+ 1 . Go to [ Google Cloud console | IAM & admin] ( https://console.cloud.google.com/iam-admin ) .
249
+ 2 . Find your service account in the list. If not added click the ** pencil** icon to edit its
243
250
permissions.
244
- 3 . Click ** ' ADD ANOTHER ROLE' ** and choose ** ' Firebase Authentication Admin' ** .
245
- 4 . Click ** ' SAVE' ** .
251
+ 3 . Click ** ADD ANOTHER ROLE** and choose ** Firebase Authentication Admin** .
252
+ 4 . Click ** SAVE** .
246
253
247
254
248
255
Now you can invoke the integration test suite as follows:
0 commit comments