forked from googlearchive/go-gcm
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfcm_test.go
35 lines (28 loc) · 996 Bytes
/
fcm_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package googlemessaging
import (
"fmt"
"os"
"testing"
)
const (
ServiceAccountFilePath = "fixtures/service_account.json"
)
func readFixture(path string) string {
data, err := os.ReadFile(path)
if err != nil {
panic(fmt.Sprintf("error while reading %v", path))
}
return string(data)
}
func TestGetValidServiceAccount(t *testing.T) {
serviceAccountFileContent := readFixture(ServiceAccountFilePath)
acc, err := getServiceAccountFromContent(serviceAccountFileContent)
assertEqual(t, err, nil)
assertEqual(t, acc.ProjectId, "pusher-project-id")
assertEqual(t, acc.PrivateKeyId, "12345")
assertEqual(t, acc.PrivateKey, "-----BEGIN PRIVATE KEY-----\nprivate_key\n-----END PRIVATE KEY-----\n")
assertEqual(t, acc.ClientEmail, "firebase-adminsdk-g680q@pusher-project-id.iam.gserviceaccount.com")
assertEqual(t, acc.ClientId, "12345")
assertEqual(t, acc.AuthUri, "https://accounts.google.com/o/oauth2/auth")
assertEqual(t, acc.TokenUri, "https://oauth2.googleapis.com/token")
}