Skip to content

Commit 5e99ed8

Browse files
AchoArnoldCopilot
andcommitted
refactor(tests): generate firebase credentials on-the-fly instead of committing
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent aa99a96 commit 5e99ed8

4 files changed

Lines changed: 35 additions & 13 deletions

File tree

.github/workflows/integration-test.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,9 @@ jobs:
2323
with:
2424
go-version: "1.22"
2525

26-
- name: Load Firebase credentials
26+
- name: Generate Firebase credentials
2727
run: |
28+
bash tests/generate-firebase-credentials.sh tests/firebase-credentials.json
2829
echo "FIREBASE_CREDENTIALS=$(jq -c . tests/firebase-credentials.json)" >> $GITHUB_ENV
2930
3031
- name: Start services 🐳

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,5 @@
66
android/app/debug/
77
*main.exe*
88
android/app/release/
9+
10+
tests/firebase-credentials.json

tests/firebase-credentials.json

Lines changed: 0 additions & 12 deletions
This file was deleted.
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/bin/bash
2+
# Generates a fake Firebase service account JSON for integration tests.
3+
# The RSA key is throwaway — it only needs to be valid so the Firebase SDK can sign JWTs.
4+
# The emulator does not validate these tokens.
5+
6+
set -e
7+
8+
OUTFILE="${1:-firebase-credentials.json}"
9+
10+
# Generate a 2048-bit RSA key
11+
PRIVATE_KEY=$(openssl genrsa 2048 2>/dev/null)
12+
13+
# Escape newlines for JSON embedding
14+
PRIVATE_KEY_ESCAPED=$(echo "$PRIVATE_KEY" | awk '{printf "%s\\n", $0}')
15+
16+
cat > "$OUTFILE" <<EOF
17+
{
18+
"type": "service_account",
19+
"project_id": "httpsms-test",
20+
"private_key_id": "test-key-id",
21+
"private_key": "${PRIVATE_KEY_ESCAPED}",
22+
"client_email": "test@httpsms-test.iam.gserviceaccount.com",
23+
"client_id": "123456789",
24+
"auth_uri": "http://emulator:9090/auth",
25+
"token_uri": "http://emulator:9090/token",
26+
"auth_provider_x509_cert_url": "http://emulator:9090/certs",
27+
"client_x509_cert_url": "http://emulator:9090/certs/test"
28+
}
29+
EOF
30+
31+
echo "Generated $OUTFILE"

0 commit comments

Comments
 (0)