From 911c7e8d79197f9d3811342addfa544e3335d7fc Mon Sep 17 00:00:00 2001 From: Lahiru Maramba Date: Wed, 26 Jun 2024 20:36:54 +0000 Subject: [PATCH 1/7] chore: update integration test resources (#633) --- .../resources/integ-service-account.json.gpg | Bin 1730 -> 1762 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/.github/resources/integ-service-account.json.gpg b/.github/resources/integ-service-account.json.gpg index 145389e0e839675ef92e2712638f3d39dc030fb0..7740dccd8bdada2eecc181f75c552c00e912e5c2 100644 GIT binary patch literal 1762 zcmV<81|9i~4Fm}T0)n*iur~xoxnP%@af)-$RhZ&7)3w(?>+$-b1cw>C)uo%^A>P*=<*0iel03 za}Fsg1`ruYzno_!>aY;)OsTkc%h&&pe{$nZw5?@UjcH^%VjHu)VgwEnKQUK4HJk0= zyZ5gIrQ>xo>l)_!-wlcQad@p8gshGgv1xcg_Yjj!nW#U|n*LMBm3Wlbk?i_CZ5Ume zal+1184AaJ?*V#JRCa=MTz1K6B-nEb*&W)}8_{YN|7UTh+U!ds%WR1v?9Hbxk@ z+EogP!glp>+*yB=n_Y5O!Q;p67Vmj%K0Z&IQHoSQT$5HK`B~z1yiX&eY#WwU=~;7S z*R}F3&c9V&rDM=B?(>!Z9}?HjEfYzeD!pR<0+x@F>TU9zk7}`hv#*;%+wZyrU0HEofh5VjbOiejUW3pY z12D!+Wf#4>(VKPmD}rZ71T zja(Co^VJ`de?Q=DM7vMvigtGHs?54vGS7;%Hh%Kgpcm|%^7?KEi%S69Cr3HH;P{#2 zQKW(H3{(*{l=~Bf7Rl-tT)anXQbTFgdpURPL%zy_*wvVIb#5uC(O*IiG}XiMGUA%y z{hDOjK*5$4CjH6|s5_9ya=cleH7`i?@E_&%aD!Azwfl->_ z*G%8=hHUxvc;-w-8SZhmd?W7x5Q>Gdn&TWCqCer@&YB71xG=dZ z)$Q#4CnyByk9+}lQNhr0X%Yl^Z@x^E{?CS9l0qFDy5|%MRx3RMp&FRUbXi#z!svt^ z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14 -0700 Subject: [PATCH 2/7] feat(fcm): enable direct_boot_ok as bool in Android config (#638) * enable direct boot ok in Android config * remove .idea --- messaging/messaging.go | 1 + messaging/messaging_test.go | 29 +++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/messaging/messaging.go b/messaging/messaging.go index 858e75ff..2b362db8 100644 --- a/messaging/messaging.go +++ b/messaging/messaging.go @@ -121,6 +121,7 @@ type AndroidConfig struct { Data map[string]string `json:"data,omitempty"` // if specified, overrides the Data field on Message type Notification *AndroidNotification `json:"notification,omitempty"` FCMOptions *AndroidFCMOptions `json:"fcm_options,omitempty"` + DirectBootOk bool `json:"direct_boot_ok,omitempty"` } // MarshalJSON marshals an AndroidConfig into JSON (for internal use only). diff --git a/messaging/messaging_test.go b/messaging/messaging_test.go index 388154b0..0603b6c0 100644 --- a/messaging/messaging_test.go +++ b/messaging/messaging_test.go @@ -144,6 +144,35 @@ var validMessages = []struct { "topic": "test-topic", }, }, + { + name: "AndroidDataMessage", + req: &Message{ + Android: &AndroidConfig{ + DirectBootOk: true, + CollapseKey: "ck", + Data: map[string]string{ + "k1": "v1", + "k2": "v2", + }, + Priority: "normal", + TTL: &ttl, + }, + Topic: "test-topic", + }, + want: map[string]interface{}{ + "android": map[string]interface{}{ + "direct_boot_ok": true, + "collapse_key": "ck", + "data": map[string]interface{}{ + "k1": "v1", + "k2": "v2", + }, + "priority": "normal", + "ttl": "10s", + }, + "topic": "test-topic", + }, + }, { name: "AndroidNotificationMessage", req: &Message{ From bbd5162a15dc99f210a5a64831728b42f6943291 Mon Sep 17 00:00:00 2001 From: Lahiru Maramba Date: Tue, 22 Oct 2024 16:46:27 -0400 Subject: [PATCH 3/7] chore: Skip integration tests for deprecated FCM APIs (#646) --- integration/messaging/messaging_test.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/integration/messaging/messaging_test.go b/integration/messaging/messaging_test.go index 85b475ae..e32aac9d 100644 --- a/integration/messaging/messaging_test.go +++ b/integration/messaging/messaging_test.go @@ -230,6 +230,7 @@ func TestSendEachForMulticast(t *testing.T) { } func TestSendAll(t *testing.T) { + t.Skip("Skipping integration tests for deprecated sendAll() API") messages := []*messaging.Message{ { Notification: &messaging.Notification{ @@ -289,6 +290,7 @@ func TestSendAll(t *testing.T) { } func TestSendFiveHundred(t *testing.T) { + t.Skip("Skipping integration tests for deprecated sendAll() API") var messages []*messaging.Message const limit = 500 for i := 0; i < limit; i++ { @@ -322,6 +324,7 @@ func TestSendFiveHundred(t *testing.T) { } func TestSendMulticast(t *testing.T) { + t.Skip("Skipping integration tests for deprecated SendMulticast() API") message := &messaging.MulticastMessage{ Notification: &messaging.Notification{ Title: "title", From 05e575d186270fa765f8da55f91775d239862eef Mon Sep 17 00:00:00 2001 From: Lahiru Maramba Date: Tue, 22 Oct 2024 17:41:23 -0400 Subject: [PATCH 4/7] fix(fcm): Change DirectBootOK per Go initialisms (#645) --- messaging/messaging.go | 2 +- messaging/messaging_test.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/messaging/messaging.go b/messaging/messaging.go index 2b362db8..2a846166 100644 --- a/messaging/messaging.go +++ b/messaging/messaging.go @@ -121,7 +121,7 @@ type AndroidConfig struct { Data map[string]string `json:"data,omitempty"` // if specified, overrides the Data field on Message type Notification *AndroidNotification `json:"notification,omitempty"` FCMOptions *AndroidFCMOptions `json:"fcm_options,omitempty"` - DirectBootOk bool `json:"direct_boot_ok,omitempty"` + DirectBootOK bool `json:"direct_boot_ok,omitempty"` } // MarshalJSON marshals an AndroidConfig into JSON (for internal use only). diff --git a/messaging/messaging_test.go b/messaging/messaging_test.go index 0603b6c0..7421fb7e 100644 --- a/messaging/messaging_test.go +++ b/messaging/messaging_test.go @@ -148,7 +148,7 @@ var validMessages = []struct { name: "AndroidDataMessage", req: &Message{ Android: &AndroidConfig{ - DirectBootOk: true, + DirectBootOK: true, CollapseKey: "ck", Data: map[string]string{ "k1": "v1", From 4093df9aeaf2d1560ad6ac847b78e9706dc7d8fb Mon Sep 17 00:00:00 2001 From: Lahiru Maramba Date: Wed, 23 Oct 2024 15:49:55 -0400 Subject: [PATCH 5/7] chore: Upgrade Go version support (#647) --- .github/workflows/ci.yml | 2 +- .github/workflows/nightly.yml | 2 +- .github/workflows/release.yml | 2 +- README.md | 4 ++-- go.mod | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 42991681..43c8cdc2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,7 +8,7 @@ jobs: strategy: fail-fast: false matrix: - go: ['1.20', '1.21', '1.22'] + go: ['1.21', '1.22', '1.23'] steps: - name: Check out code diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 6e89ee5a..fbee4368 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -36,7 +36,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v5 with: - go-version: '1.20' + go-version: '1.21' - name: Install golint run: go install golang.org/x/lint/golint@latest diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 5026fd0c..a164bdca 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -47,7 +47,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v5 with: - go-version: '1.20' + go-version: '1.21' - name: Install golint run: go install golang.org/x/lint/golint@latest diff --git a/README.md b/README.md index 6a042cc5..34a1e610 100644 --- a/README.md +++ b/README.md @@ -45,9 +45,9 @@ requests, code review feedback, and also pull requests. ## Supported Go Versions The Admin Go SDK is compatible with at least the three most recent, major Go releases. -We currently support Go v1.20 and higher. +We currently support Go v1.21 and higher. [Continuous integration](https://github.com/firebase/firebase-admin-go/actions) system -tests the code on Go v1.20 through v1.22. +tests the code on Go v1.21 through v1.23. ## Documentation diff --git a/go.mod b/go.mod index 945b981e..b9a1c22c 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module firebase.google.com/go/v4 -go 1.20 +go 1.21 require ( cloud.google.com/go/firestore v1.15.0 From 04a9ea6d9771b43c70350497d9d65ab3870fb371 Mon Sep 17 00:00:00 2001 From: Lahiru Maramba Date: Thu, 24 Oct 2024 11:18:17 -0400 Subject: [PATCH 6/7] chore: Add X-Goog-Api-Client header to Auth and FCM requests (#648) * chore: Add X-Goog-Api-Client header to Auth and FCM requests * fix lint errors * remove the prefix from version tag --- auth/auth.go | 3 +++ auth/auth_test.go | 8 ++++++++ auth/user_mgt_test.go | 7 +++++++ messaging/messaging.go | 3 +++ messaging/messaging_test.go | 7 +++++++ 5 files changed, 28 insertions(+) diff --git a/auth/auth.go b/auth/auth.go index d6299611..0bda04a0 100644 --- a/auth/auth.go +++ b/auth/auth.go @@ -21,6 +21,7 @@ import ( "errors" "fmt" "os" + "runtime" "strings" "time" @@ -133,10 +134,12 @@ func NewClient(ctx context.Context, conf *internal.AuthConfig) (*Client, error) return nil, err } + goVersion := strings.TrimPrefix(runtime.Version(), "go") hc := internal.WithDefaultRetryConfig(transport) hc.CreateErrFn = handleHTTPError hc.Opts = []internal.HTTPOption{ internal.WithHeader("X-Client-Version", fmt.Sprintf("Go/Admin/%s", conf.Version)), + internal.WithHeader("x-goog-api-client", fmt.Sprintf("gl-go/%s fire-admin/%s", goVersion, conf.Version)), } baseURL := defaultAuthURL diff --git a/auth/auth_test.go b/auth/auth_test.go index 30fbde88..2a00220b 100644 --- a/auth/auth_test.go +++ b/auth/auth_test.go @@ -23,6 +23,7 @@ import ( "log" "net/http" "os" + "runtime" "strings" "syscall" "testing" @@ -1451,6 +1452,13 @@ func checkBaseClient(client *Client, wantProjectID string) error { return fmt.Errorf("version = %q; want = %q", version, wantVersion) } + goVersion := strings.TrimPrefix(runtime.Version(), "go") + xGoogAPIClientHeader := req.Header.Get("x-goog-api-client") + wantXGoogAPIClientHeader := fmt.Sprintf("gl-go/%s fire-admin/%s", goVersion, testVersion) + if xGoogAPIClientHeader != wantXGoogAPIClientHeader { + return fmt.Errorf("x-goog-api-client header = %q; want = %q", xGoogAPIClientHeader, wantXGoogAPIClientHeader) + } + return nil } diff --git a/auth/user_mgt_test.go b/auth/user_mgt_test.go index ffa48655..902ed280 100644 --- a/auth/user_mgt_test.go +++ b/auth/user_mgt_test.go @@ -24,6 +24,7 @@ import ( "net/http" "net/http/httptest" "reflect" + "runtime" "sort" "strconv" "strings" @@ -2315,6 +2316,12 @@ func echoServer(resp interface{}, t *testing.T) *mockAuthServer { t.Errorf("X-Client-Version header = %q; want: %q", gh, wh) } + gh = r.Header.Get("x-goog-api-client") + wh = fmt.Sprintf("gl-go/%s fire-admin/%s", strings.TrimPrefix(runtime.Version(), "go"), testVersion) + if gh != wh { + t.Errorf("x-goog-api-client header = %q; want: %q", gh, wh) + } + for k, v := range s.Header { w.Header().Set(k, v) } diff --git a/messaging/messaging.go b/messaging/messaging.go index 2a846166..525cccb6 100644 --- a/messaging/messaging.go +++ b/messaging/messaging.go @@ -23,6 +23,7 @@ import ( "fmt" "net/http" "regexp" + "runtime" "strconv" "strings" "time" @@ -893,10 +894,12 @@ func newFCMClient(hc *http.Client, conf *internal.MessagingConfig, messagingEndp client := internal.WithDefaultRetryConfig(hc) client.CreateErrFn = handleFCMError + goVersion := strings.TrimPrefix(runtime.Version(), "go") version := fmt.Sprintf("fire-admin-go/%s", conf.Version) client.Opts = []internal.HTTPOption{ internal.WithHeader(apiFormatVersionHeader, apiFormatVersion), internal.WithHeader(firebaseClientHeader, version), + internal.WithHeader("x-goog-api-client", fmt.Sprintf("gl-go/%s fire-admin/%s", goVersion, conf.Version)), } return &fcmClient{ diff --git a/messaging/messaging_test.go b/messaging/messaging_test.go index 7421fb7e..8b31fc46 100644 --- a/messaging/messaging_test.go +++ b/messaging/messaging_test.go @@ -21,6 +21,8 @@ import ( "net/http" "net/http/httptest" "reflect" + "runtime" + "strings" "testing" "time" @@ -1394,6 +1396,11 @@ func checkFCMRequest(t *testing.T, b []byte, tr *http.Request, want map[string]i if h := tr.Header.Get("X-FIREBASE-CLIENT"); h != clientVersion { t.Errorf("X-FIREBASE-CLIENT = %q; want = %q", h, clientVersion) } + goVersion := strings.TrimPrefix(runtime.Version(), "go") + xGoogAPIClientHeader := "gl-go/" + goVersion + " fire-admin/" + testMessagingConfig.Version + if h := tr.Header.Get("x-goog-api-client"); h != xGoogAPIClientHeader { + t.Errorf("x-goog-api-client header = %q; want = %q", h, xGoogAPIClientHeader) + } } var httpErrors = []struct { From b8f0b139801c007be2a3922a3300ca48da6e19bb Mon Sep 17 00:00:00 2001 From: Lahiru Maramba Date: Thu, 24 Oct 2024 11:22:58 -0400 Subject: [PATCH 7/7] [chore] Release 4.15.0 (#649) --- firebase.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/firebase.go b/firebase.go index 47a1006e..8b1facd4 100644 --- a/firebase.go +++ b/firebase.go @@ -39,7 +39,7 @@ import ( var defaultAuthOverrides = make(map[string]interface{}) // Version of the Firebase Go Admin SDK. -const Version = "4.14.1" +const Version = "4.15.0" // firebaseEnvName is the name of the environment variable with the Config. const firebaseEnvName = "FIREBASE_CONFIG"