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