Documentation ¶
Overview ¶
Description: This package provides a set of functions to interact with the Firebase API and the Firebase Admin SDK.
Index ¶
- func CleanupMock(ctx context.Context, app *firebase.App, user *auth.UserRecord) error
- func CreateFirebaseUser(ctx context.Context, app *firebase.App, httpClient *http.Client, ...) (*auth.UserRecord, error)
- func GenerateMockFirebaseUID(length int) string
- func GetFirebaseIDToken(email, password, firebaseAPIKey string) (string, error)
- func InitFirebaseApp(ctx context.Context, FS embed.FS, accountCredentialsPath string) (*firebase.App, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CleanupMock ¶
CleanupMock deletes the Firebase user.
Typically utilized in integration tests to clean up the user after the test is complete.
Use "defer" to call this function after the test is complete to delete the mock user from Firebase.
func CreateFirebaseUser ¶
func CreateFirebaseUser(ctx context.Context, app *firebase.App, httpClient *http.Client, user *auth.UserToCreate, email string) (*auth.UserRecord, error)
CreateFirebaseUser creates a Firebase user and returns the user record.
An embedded filesystem and the path to the credentials file are required.
User is created with the specified email and password only.
The user to be passed to the function must be a pointer to a struct of type auth.UserToCreate.
- user := auth.UserToCreate{}
- user.Email(mockEmail)
user.Password(mockPwd)
func GenerateMockFirebaseUID ¶
GenerateMockFirebaseUID generates a random Firebase UID of the specified length.
Typically utilized in integration tests to create a mock user.
func GetFirebaseIDToken ¶
GetFirebaseIDToken exchanges an email and password of an active Firebase user for its Firebase UID.
The email and password are used to authenticate with Firebase and represent the user's credentials.
A valid Firebase API key is required to authenticate with the Firebase API.
The Firebase ID token is returned.
If the request fails, an error is returned.
Types ¶
This section is empty.