@@ -115,35 +115,89 @@ the integration tests, and only execute the unit tests.
115
115
116
116
### Integration Testing
117
117
118
- A suite of integration tests are available in the Admin SDK source code.
119
- These tests are designed to run against an actual Firebase project. Create a new
120
- project in the [ Firebase Console] ( https://console.firebase.google.com ) , if you
121
- do not already have one suitable for running the tests against. Then obtain the
122
- following credentials from the project:
123
-
124
- 1 . * Service account certificate* : This can be downloaded as a JSON file from
125
- the "Settings > Service Accounts" tab of the Firebase console. Click
126
- "GENERATE NEW PRIVATE KEY" and copy the file into your Go workspace as
127
- ` src/firebase.google.com/go/testdata/integration_cert.json ` .
128
- 2 . * Web API key* : This is displayed in the "Settings > General" tab of the
129
- console. Copy it and save to a new text file. Copy this text file into
130
- your Go workspace as
131
- ` src/firebase.google.com/go/testdata/integration_apikey.txt ` .
132
-
133
- You'll also need to grant your service account the 'Firebase Authentication Admin' role. This is
134
- required to ensure that exported user records contain the password hashes of the user accounts:
135
- 1 . Go to [ Google Cloud Platform Console / IAM & admin] ( https://console.cloud.google.com/iam-admin ) .
136
- 2 . Find your service account in the list, and click the 'pencil' icon to edit it's permissions.
137
- 3 . Click 'ADD ANOTHER ROLE' and choose 'Firebase Authentication Admin'.
138
- 4 . Click 'SAVE'.
139
-
140
- Some of the integration tests require an
141
- [ Identity Platform] ( https://cloud.google.com/identity-platform/ ) project with multi-tenancy
142
- [ enabled] ( https://cloud.google.com/identity-platform/docs/multi-tenancy-quickstart#enabling_multi-tenancy ) .
143
- An existing Firebase project can be upgraded to an Identity Platform project without losing any
144
- functionality via the
145
- [ Identity Platform Marketplace Page] ( https://console.cloud.google.com/customer-identity ) . Note that
146
- charges may be incurred for active users beyond the Identity Platform free tier.
118
+ Integration tests are executed against a real life Firebase project. If you do not already
119
+ have one suitable for running the tests against, you can create a new project in the
120
+ [ Firebase Console] ( https://console.firebase.google.com ) following the setup guide below.
121
+ If you already have a Firebase project, you'll need to obtain credentials to communicate and
122
+ authorize access to your Firebase project:
123
+
124
+
125
+ 1 . Service account certificate: This allows access to your Firebase project through a service account
126
+ which is required for all integration tests. This can be downloaded as a JSON file from the
127
+ ** Settings > Service Accounts** tab of the Firebase console when you click the
128
+ ** Generate new private key** button. Copy the file into the repo so it's available at
129
+ ` src/firebase.google.com/go/testdata/integration_cert.json ` .
130
+ > ** Note:** Service accounts should be carefully managed and their keys should never be stored in publicly accessible source code or repositories.
131
+
132
+
133
+ 2 . Web API key: This allows for Auth sign-in needed for some Authentication and Tenant Management
134
+ integration tests. This is displayed in the ** Settings > General** tab of the Firebase console
135
+ after enabling Authentication as described in the steps below. Copy it and save to a new text
136
+ file at ` src/firebase.google.com/go/testdata/integration_apikey.txt ` .
137
+
138
+
139
+ Set up your Firebase project as follows:
140
+
141
+
142
+ 1 . Enable Authentication:
143
+ 1 . Go to the Firebase Console, and select ** Authentication** from the ** Build** menu.
144
+ 2 . Click on ** Get Started** .
145
+ 3 . Select ** Sign-in method > Add new provider > Email/Password** then enable both the
146
+ ** Email/Password** and ** Email link (passwordless sign-in)** options.
147
+
148
+
149
+ 2 . Enable Firestore:
150
+ 1 . Go to the Firebase Console, and select ** Firestore Database** from the ** Build** menu.
151
+ 2 . Click on the ** Create database** button. You can choose to set up Firestore either in
152
+ the production mode or in the test mode.
153
+
154
+
155
+ 3 . Enable Realtime Database:
156
+ 1 . Go to the Firebase Console, and select ** Realtime Database** from the ** Build** menu.
157
+ 2 . Click on the ** Create Database** button. You can choose to set up the Realtime Database
158
+ either in the locked mode or in the test mode.
159
+
160
+ > ** Note:** Integration tests are not run against the default Realtime Database reference and are
161
+ instead run against a database created at ` https://{PROJECT_ID}.firebaseio.com ` .
162
+ This second Realtime Database reference is created in the following steps.
163
+
164
+ 3 . In the ** Data** tab click on the kebab menu (3 dots) and select ** Create Database** .
165
+ 4 . Enter your Project ID (Found in the ** General** tab in ** Account Settings** ) as the
166
+ ** Realtime Database reference** . Again, you can choose to set up the Realtime Database
167
+ either in the locked mode or in the test mode.
168
+
169
+
170
+ 4 . Enable Storage:
171
+ 1 . Go to the Firebase Console, and select ** Storage** from the ** Build** menu.
172
+ 2 . Click on the ** Get started** button. You can choose to set up Cloud Storage
173
+ either in the production mode or in the test mode.
174
+
175
+
176
+ 5 . Enable the IAM API:
177
+ 1 . Go to the [ Google Cloud console] ( https://console.cloud.google.com )
178
+ and make sure your Firebase project is selected.
179
+ 2 . Select ** APIs & Services** from the main menu, and click the
180
+ ** ENABLE APIS AND SERVICES** button.
181
+ 3 . Search for and enable ** Identity and Access Management (IAM) API** by Google Enterprise API.
182
+
183
+
184
+ 6 . Enable Tenant Management:
185
+ 1 . Go to
186
+ [ Google Cloud console | Identity Platform] ( https://console.cloud.google.com/customer-identity/ )
187
+ and if it is not already enabled, click ** Enable** .
188
+ 2 . Then
189
+ [ enable multi-tenancy] ( https://cloud.google.com/identity-platform/docs/multi-tenancy-quickstart#enabling_multi-tenancy )
190
+ for your project.
191
+
192
+
193
+ 7 . Ensure your service account has the ** Firebase Authentication Admin** role. This is required
194
+ to ensure that exported user records contain the password hashes of the user accounts:
195
+ 1 . Go to [ Google Cloud console | IAM & admin] ( https://console.cloud.google.com/iam-admin ) .
196
+ 2 . Find your service account in the list. If not added click the pencil icon to edit its
197
+ permissions.
198
+ 3 . Click ** ADD ANOTHER ROLE** and choose ** Firebase Authentication Admin** .
199
+ 4 . Click ** SAVE** .
200
+
147
201
148
202
Now you can invoke the test suite as follows:
149
203
0 commit comments