Skip to content

Commit

Permalink
fix: Firebase authentication (#5177)
Browse files Browse the repository at this point in the history
* fix: Firebase authentication

* More places

* Update readme

* Remove logs
  • Loading branch information
SevInf authored Jul 8, 2024
1 parent 6ed3b37 commit ea82a02
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -706,11 +706,11 @@ jobs:
AWS_DEFAULT_REGION: ${{ vars.AWS_DEFAULT_REGION }}
AWS_ACCESS_KEY_ID: ${{ vars.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
FIREBASE_PRIVATE_KEY: ${{ secrets.FIREBASE_PRIVATE_KEY }}
AWS_ROLE: ${{ vars.AWS_ROLE }}
AZURE_SP_TENANT: ${{ vars.AZURE_SP_TENANT }}
AZURE_SP_PASSWORD: ${{ secrets.AZURE_SP_PASSWORD }}
AZURE_SP_NAME: ${{ vars.AZURE_SP_NAME }}
FIREBASE_TOKEN: ${{ secrets.FIREBASE_TOKEN }}

steps:
- uses: actions/checkout@v4
Expand Down
4 changes: 2 additions & 2 deletions platforms-serverless/firebase-functions/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@ For more install methods, follow the [official install docs](https://firebase.go

### Firebase authentication

A [firebase token](https://firebase.google.com/docs/cli#cli-ci-systems) needs to be set with the environment variable `FIREBASE_TOKEN`.
A [firebase private key](https://firebase.google.com/docs/cloud-messaging/auth-server#provide-credentials-manually) needs to be set with the environment variable `FIREBASE_PRIVATE_KEY`.

If you use an interactive login using `firebase login`, you need to temporarily edit `run.sh` and remove the `--token` parameter so the firebase will use your credentials saved by `firebase login`.
If you use an interactive login using `firebase login`, you need to temporarily edit `run.sh` and remove the `GOOGLE_APPLICATION_CREDENTIALS` parameter so the firebase will use your credentials saved by `firebase login`.
4 changes: 2 additions & 2 deletions platforms-serverless/firebase-functions/finally.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ set -eux

func="$(cat func-tmp.txt)"

pnpm firebase functions:log --only "$func"
GOOGLE_APPLICATION_CREDENTIALS="./privateKey.json" pnpm firebase functions:log --only "$func"

echo "full logs: https://console.firebase.google.com/project/prisma-e2e-tests-265911/functions/logs?functionFilter=$func(us-central1)&search=&severity=DEBUG"
echo "project name: prisma-e2e-tests-265 911"

if [ "$TEST_EXIT_CODE" -eq "0" ]; then
# If tests passed

pnpm firebase functions:delete --force "$func"
GOOGLE_APPLICATION_CREDENTIALS="./privateKey.json" pnpm firebase functions:delete --force "$func"

fi
5 changes: 3 additions & 2 deletions platforms-serverless/firebase-functions/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ pnpm install

func="e2e_firebase_test_$(date "+%Y_%m_%d_%H%M%S")" # note weird naming here
echo "$func" > func-tmp.txt
echo "$FIREBASE_PRIVATE_KEY" > "./privateKey.json"

# When PRISMA_CLIENT_ENGINE_TYPE is set to `binary`, overwrite existing schema file with one that sets the engineType to 'binary'
if [ "$PRISMA_CLIENT_ENGINE_TYPE" == "binary" ]; then
Expand All @@ -18,6 +19,6 @@ fi

cd functions/ && sh prepare_in_project.sh "$func" && cd ..

pnpm firebase functions:config:set prisma.db="$DATABASE_URL"
GOOGLE_APPLICATION_CREDENTIALS="./privateKey.json" pnpm firebase functions:config:set prisma.db="$DATABASE_URL"

pnpm firebase deploy --token "$FIREBASE_TOKEN" --only "functions:$func"
GOOGLE_APPLICATION_CREDENTIALS="./privateKey.json" pnpm firebase deploy --only "functions:$func"
3 changes: 0 additions & 3 deletions platforms-serverless/firebase-functions/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@ fi
expected='{"version":"'$prisma_version'","createUser":{"id":"12345","email":"[email protected]","name":"Alice"},"updateUser":{"id":"12345","email":"[email protected]","name":"Bob"},"users":{"id":"12345","email":"[email protected]","name":"Bob"},"deleteManyUsers":{"count":1}'${files}'}'
actual=$(curl "$url")

# TODO Why is this here?
pnpm firebase functions:log --only "$func"

if [ "$expected" != "$actual" ]; then
echo "expected '$expected'"
echo " but got '$actual'"
Expand Down

0 comments on commit ea82a02

Please sign in to comment.