Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 76 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,82 @@ to ensure that exported user records contain the password hashes of the user acc
3. Click **ADD ANOTHER ROLE** and choose **Firebase Authentication Admin**.
4. Click **SAVE**.

9. Setup your project for Firebase Data Connect integration tests:
1. Set up Data Connect in the Firebase Console:
1. Go to the Firebase Console, and select **Data Connect** from the **Build** menu.
2. Click on **Get Started**. Skip any steps related to Gemini generation.
3. Select **Create a new Cloud SQL instance**.
4. When prompted, you must use the following specific configuration values, as the integration tests are hard-coded to expect them:
* Set your **Location** to `us-west2`
* Set your **Cloud SQL instance ID** to `my-instance`
* Set your **Database name** to `my-database`
* Set your **Service ID** to `my-service`
5. Click **Submit**.
> **Note:** This operation may take up to 10 minutes to complete - you may
continue with Step 2 of setup while this completes.
2. Set up your Data Connect schema and operations locally:
1. First, create a separate directory for the test configuration and initialize Data Connect.
(Make sure to replace `<PROJECT_ID>` with your actual Firebase Project ID).
```bash
$ mkdir fdc-integration-test
$ cd fdc-integration-test
$ firebase init dataconnect --project <PROJECT_ID>
```
2. During the interactive init process, follow these prompts:
* When it says "Your project already has existing services," select the service you just created: `us-west2/my-service`.
* When asked to use an app template, select `no`.
3. The set up should be complete.
4. Create your schema and operations:
```bash
$ touch fdc-integration-test/dataconnect/example/operations.gql
```
* Paste the following lines into `fdc-integration-test/dataconnect/example/operations.gql`:
```gql
query ListUsersPublic @auth(level: PUBLIC, insecureReason: "test") { users { id, name, address } }
query ListUsersUserAnon @auth(level: USER_ANON, insecureReason: "test") { users { id, name, address } }
query ListUsersUser @auth(level: USER, insecureReason: "test") { users { id, name, address } }
query ListUsersUserEmailVerified @auth(level: USER_EMAIL_VERIFIED, insecureReason: "test") { users { id, name, address } }
query ListUsersNoAccess @auth(level: NO_ACCESS) { users { id, name, address } }
query ListUsersImpersonationAnon @auth(level: USER_ANON) {users(where: { id: { eq_expr: "auth.uid" } }) { id, name, address } }
query GetUser($id: User_Key!) @auth(level: NO_ACCESS) { user(key: $id) { id name } }

query ListEmails @auth(level: NO_ACCESS) { emails { id subject text date from { name } } }
query GetEmail($id: String!) @auth(level: NO_ACCESS) { email(id: $id) { id, subject, date, text, from { id name address } } }

mutation upsertFredUser @auth(level: NO_ACCESS) { user_upsert(data: { id: "fred_id", address: "32 Elm St.", name: "Fred" }) }
mutation updateFredrickUserImpersonation @auth(level: USER) { user_update( key: { id_expr: "auth.uid" }, data: { address: "64 Elm St. North", name: "Fredrick" } ) }
mutation upsertJeffUser @auth(level: NO_ACCESS) { user_upsert(data: { id: "jeff_id", address: "99 Oak St.", name: "Jeff" }) }

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", }) }

mutation InsertEmailPublic @auth(level: PUBLIC, insecureReason: "test") { email_insert(data: { id_expr: "uuidV4()", subject: "PublicEmail", date: "1999-12-31", text: "PublicEmail", fromId: "jeff_id", }) }
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", }) }
mutation InsertEmailUser @auth(level: USER, insecureReason: "test") { email_insert(data: { id_expr: "uuidV4()", subject: "UserEmail", date: "1999-12-31", text: "UserEmail", fromId: "jeff_id", }) }
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", }) }
mutation InsertEmailNoAccess @auth(level: NO_ACCESS) { email_insert(data: { id_expr: "uuidV4()", subject: "NoAccessEmail", date: "1999-12-31", text: "NoAccessEmail", fromId: "jeff_id", }) }
mutation InsertEmailImpersonation @auth(level: NO_ACCESS) { email_insert(data: { id_expr: "uuidV4()", subject: "ImpersonatedEmail", date: "1999-12-31", text: "ImpersonatedEmail", fromId_expr: "auth.uid" }) }
```
* Paste the following lines into `fdc-integration-test/dataconnect/schema/schema.gql`:
```gql
type User @table(key: ["id"]) {
id: String!
name: String!
address: String!
}

type Email @table {
id: String!
subject: String!
date: Date!
text: String!
from: User!
}
```
5. Finally, deploy your new schema and operations from within the `fdc-integration-test` directory:
```bash
$ firebase deploy --only dataconnect --project <PROJECT_ID>
```
6. When asked if you'd like to execute changes, select `Execute all`.

Finally, to run the integration test suite:

Expand Down
10 changes: 10 additions & 0 deletions firebase-debug.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[debug] [2025-09-12T00:08:18.312Z] ----------------------------------------------------------------------
[debug] [2025-09-12T00:08:18.314Z] Command: /Users/stephenarosaj/.nvm/versions/node/v22.18.0/bin/node /Users/stephenarosaj/.nvm/versions/node/v22.18.0/bin/firebase deploy --only dataconnect --project fdc-permanent-billing-00
[debug] [2025-09-12T00:08:18.315Z] CLI Version: 14.15.2
[debug] [2025-09-12T00:08:18.315Z] Platform: darwin
[debug] [2025-09-12T00:08:18.315Z] Node Version: v22.18.0
[debug] [2025-09-12T00:08:18.315Z] Time: Thu Sep 11 2025 17:08:18 GMT-0700 (Pacific Daylight Time)
[debug] [2025-09-12T00:08:18.315Z] ----------------------------------------------------------------------
[debug]
[error]
[error] Error: Not in a Firebase app directory (could not locate firebase.json)
Loading
Loading