@@ -248,47 +248,79 @@ to ensure that exported user records contain the password hashes of the user acc
248
248
9 . Setup your project for Firebase Data Connect integration tests:
249
249
1 . Set up Data Connect in the Firebase Console:
250
250
1 . Go to the Firebase Console, and select ** Data Connect** from the ** Build** menu.
251
- 2 . Click on ** Get Started** . You can skip any Gemini generation of your schema
252
- or operations - you must create these manually.
251
+ 2 . Click on ** Get Started** . Skip any steps related to Gemini generation.
253
252
3 . Select ** Create a new Cloud SQL instance** .
254
- 4 . Set your ** Location** to ` us-west2 `
255
- 5 . Set your ** Cloud SQL instance ID** to ` my-instance `
256
- 6 . Set your ** Database name** to ` my-database `
257
- 7 . Set your ** Service ID** to ` my-service `
258
- 8 . Click ** Submit** . This operation may take up to 10 minutes to complete - you may
259
- continue setting up while this completes.
260
- 2 . Set up your Data Connect schema locally:
261
- 1 . Run the following commands from the command line to setup your data connect app:
253
+ 4 . When prompted, you must use the following specific configuration values, as the integration tests are hard-coded to expect them:
254
+ * Set your ** Location** to ` us-west2 `
255
+ * Set your ** Cloud SQL instance ID** to ` my-instance `
256
+ * Set your ** Database name** to ` my-database `
257
+ * Set your ** Service ID** to ` my-service `
258
+ 5 . Click ** Submit** .
259
+ > ** Note:** This operation may take up to 10 minutes to complete - you may
260
+ continue with Step 2 of setup while this completes.
261
+ 2 . Set up your Data Connect schema and operations locally:
262
+ 1 . First, create a separate directory for the test configuration and initialize Data Connect.
263
+ (Make sure to replace ` <PROJECT_ID> ` with your actual Firebase Project ID).
262
264
``` bash
263
265
$ mkdir fdc-integration-test
264
266
$ cd fdc-integration-test
265
267
$ firebase init dataconnect --project < PROJECT_ID>
266
268
```
267
- 2. The setup script should say ** " Your project already has existing services." **
268
- Select the service you just created, ` us-west2/my-service` .
269
- 3. When asked to use an app template, select `no`.
270
- 4. The set up should complete, and should have created a file ` fdc-integration-test/dataconnect/schema/schema.gql` .
271
- 5. Paste the following lines into ` schema.gql` :
272
- ` ` ` gql
273
- type User @table(key: [" id" ]) {
274
- id: String!
275
- name: String!
276
- address: String!
277
- }
278
-
279
- type Email @table {
280
- id: String!
281
- subject: String!
282
- date: Date!
283
- text: String!
284
- from: User!
285
- }
269
+ 2. During the interactive init process, follow these prompts:
270
+ * When it says " Your project already has existing services," select the service you just created: ` us-west2/my-service` .
271
+ * When asked to use an app template, select `no`.
272
+ 3. The set up should be complete.
273
+ 4. Create your schema and operations:
274
+ ` ` ` bash
275
+ $ touch fdc-integration-test/dataconnect/example/operations.gql
286
276
` ` `
287
- 6. Run the following commands from ` fdc-integration-test/` to deploy your schema:
277
+ * Paste the following lines into ` fdc-integration-test/dataconnect/example/operations.gql` :
278
+ ` ` ` gql
279
+ query ListUsersPublic @auth(level: PUBLIC, insecureReason: " test" ) { users { id, name, address } }
280
+ query ListUsersUserAnon @auth(level: USER_ANON, insecureReason: " test" ) { users { id, name, address } }
281
+ query ListUsersUser @auth(level: USER, insecureReason: " test" ) { users { id, name, address } }
282
+ query ListUsersUserEmailVerified @auth(level: USER_EMAIL_VERIFIED, insecureReason: " test" ) { users { id, name, address } }
283
+ query ListUsersNoAccess @auth(level: NO_ACCESS) { users { id, name, address } }
284
+ query ListUsersImpersonationAnon @auth(level: USER_ANON) {users(where: { id: { eq_expr: " auth.uid" } }) { id, name, address } }
285
+ query GetUser($id : User_Key! ) @auth(level: NO_ACCESS) { user(key: $id ) { id name } }
286
+
287
+ query ListEmails @auth(level: NO_ACCESS) { emails { id subject text date from { name } } }
288
+ query GetEmail($id : String! ) @auth(level: NO_ACCESS) { email(id: $id ) { id, subject, date, text, from { id name address } } }
289
+
290
+ mutation upsertFredUser @auth(level: NO_ACCESS) { user_upsert(data: { id: " fred_id" , address: " 32 Elm St." , name: " Fred" }) }
291
+ mutation updateFredrickUserImpersonation @auth(level: USER) { user_update( key: { id_expr: " auth.uid" }, data: { address: " 64 Elm St. North" , name: " Fredrick" } ) }
292
+ mutation upsertJeffUser @auth(level: NO_ACCESS) { user_upsert(data: { id: " jeff_id" , address: " 99 Oak St." , name: " Jeff" }) }
293
+
294
+ mutation upsertJeffEmail @auth(level: NO_ACCESS) { email_upsert(data: { id: " jeff_email+id" , subject: " free bitcoin inside" , date: " 1999-12-31" , text: " get pranked! LOL!" , fromId: " jeff_id" , }) }
295
+
296
+ mutation InsertEmailPublic @auth(level: PUBLIC, insecureReason: " test" ) { email_insert(data: { id_expr: " uuidV4()" , subject: " PublicEmail" , date: " 1999-12-31" , text: " PublicEmail" , fromId: " jeff_id" , }) }
297
+ mutation InsertEmailUserAnon @auth(level: USER_ANON, insecureReason: " test" ) { email_insert(data: { id_expr: " uuidV4()" , subject: " UserAnonEmail" , date: " 1999-12-31" , text: " UserAnonEmail" , fromId: " jeff_id" , }) }
298
+ mutation InsertEmailUser @auth(level: USER, insecureReason: " test" ) { email_insert(data: { id_expr: " uuidV4()" , subject: " UserEmail" , date: " 1999-12-31" , text: " UserEmail" , fromId: " jeff_id" , }) }
299
+ mutation InsertEmailUserEmailVerified @auth(level: USER_EMAIL_VERIFIED, insecureReason: " test" ) { email_insert(data: { id_expr: " uuidV4()" , subject: " UserEmailVerifiedEmail" , date: " 1999-12-31" , text: " UserEmailVerifiedEmail" , fromId: " jeff_id" , }) }
300
+ mutation InsertEmailNoAccess @auth(level: NO_ACCESS) { email_insert(data: { id_expr: " uuidV4()" , subject: " NoAccessEmail" , date: " 1999-12-31" , text: " NoAccessEmail" , fromId: " jeff_id" , }) }
301
+ mutation InsertEmailImpersonation @auth(level: NO_ACCESS) { email_insert(data: { id_expr: " uuidV4()" , subject: " ImpersonatedEmail" , date: " 1999-12-31" , text: " ImpersonatedEmail" , fromId_expr: " auth.uid" }) }
302
+ ` ` `
303
+ * Paste the following lines into ` fdc-integration-test/dataconnect/schema/schema.gql` :
304
+ ` ` ` gql
305
+ type User @table(key: [" id" ]) {
306
+ id: String!
307
+ name: String!
308
+ address: String!
309
+ }
310
+
311
+ type Email @table {
312
+ id: String!
313
+ subject: String!
314
+ date: Date!
315
+ text: String!
316
+ from: User!
317
+ }
318
+ ` ` `
319
+ 5. Finally, deploy your new schema and operations from within the ` fdc-integration-test` directory:
288
320
` ` ` bash
289
- $ firebase deploy --only dataconnect
321
+ $ firebase deploy --only dataconnect --project < PROJECT_ID >
290
322
` ` `
291
- 7 . When asked if you' d like to execute changes, select `Execute all`.
323
+ 6 . When asked if you' d like to execute changes, select `Execute all`.
292
324
293
325
Finally, to run the integration test suite:
294
326
0 commit comments