fix(security rules): adding missing authentication test utilities file

Pushing a missing file which includes test utilities related to authentication
This commit is contained in:
ctrlc03
2023-01-29 19:40:35 +00:00
committed by Giacomo
parent 7fb1c4abac
commit fca06a497f

View File

@@ -8,6 +8,7 @@ import { google } from "googleapis"
import { createOAuthDeviceAuth } from "@octokit/auth-oauth-device"
import { createUserWithEmailAndPassword, getAuth, GithubAuthProvider, UserCredential } from "firebase/auth"
import { FirebaseApp } from "firebase/app"
import { Auth } from "firebase-admin/lib/auth/auth"
import { signInToFirebaseWithCredentials } from "../../src"
import { getAuthenticationConfiguration, sleep } from "./configs"
@@ -497,3 +498,12 @@ export const authenticateUserWithGithub = async (userApp: FirebaseApp, clientId:
const userFirebaseCredentials = GithubAuthProvider.credential(token)
return signInToFirebaseWithCredentials(userApp, userFirebaseCredentials)
}
/**
* Test function to add coordinator privileges to a user.
* @param adminAuth <Auth> - the admin auth instance.
* @param userId <string> - the uid of the user to add the privileges to.
*/
export const addCoordinatorPrivileges = async (adminAuth: Auth, userId: string): Promise<void> => {
await adminAuth.setCustomUserClaims(userId, { coordinator: true })
}