Skip to content

Commit b5f03ab

Browse files
committed
add impersonateMutation integration tests, update test data
1 parent 79caaee commit b5f03ab

File tree

3 files changed

+233
-70
lines changed

3 files changed

+233
-70
lines changed

CONTRIBUTING.md

Lines changed: 18 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -276,40 +276,29 @@ to ensure that exported user records contain the password hashes of the user acc
276276
```
277277
* Paste the following lines into `fdc-integration-test/dataconnect/example/operations.gql`:
278278
```gql
279-
query ListUsers @auth(level: PUBLIC, insecureReason: "test") { users { id, name, address } }
280-
281-
query ListEmails @auth(level: NO_ACCESS) { emails { id subject text date from { name } } }
282-
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 } }
283285
query GetUser($id: User_Key!) @auth(level: NO_ACCESS) { user(key: $id) { id name } }
284286
285-
query ListUsersImpersonation @auth(level: USER) {
286-
users(where: { id: { eq_expr: "auth.uid" } }) { id, name, address }
287-
}
288-
289-
mutation upsertFredUser @auth(level: NO_ACCESS) {
290-
user_upsert(data: { id: "fred_id", address: "32 Elm St.", name: "Fred" })
291-
}
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 } } }
292289
293-
mutation updateFredrickUserImpersonation @auth(level: USER) {
294-
user_update(
295-
key: { id_expr: "auth.uid" },
296-
data: { address: "64 Elm St. North", name: "Fredrick" }
297-
)
298-
}
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" }) }
299293
300-
mutation upsertJeffUser @auth(level: NO_ACCESS) {
301-
user_upsert(data: { id: "jeff_id", address: "99 Oak St.", name: "Jeff" })
302-
}
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", }) }
303295
304-
mutation upsertFredEmail @auth(level: NO_ACCESS) {
305-
email_upsert(data: {
306-
id: "email_id",
307-
subject: "free bitcoin inside",
308-
date: "1999-12-31",
309-
text: "get pranked! LOL!",
310-
fromId: "fred_id",
311-
})
312-
}
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" }) }
313302
```
314303
* Paste the following lines into `fdc-integration-test/dataconnect/schema/schema.gql`:
315304
```gql

src/data-connect/data-connect-api-client-internal.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,6 @@ export class DataConnectApiClient {
220220
return resp;
221221
})
222222
.catch((err) => {
223-
// console.log(err)
224223
throw this.toFirebaseError(err);
225224
});
226225
}

0 commit comments

Comments
 (0)