From bbd5162a15dc99f210a5a64831728b42f6943291 Mon Sep 17 00:00:00 2001 From: Lahiru Maramba Date: Tue, 22 Oct 2024 16:46:27 -0400 Subject: [PATCH 1/5] 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 2/5] 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 3/5] 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 4/5] 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 5/5] [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"