diff --git a/.github/resources/integ-service-account.json.gpg b/.github/resources/integ-service-account.json.gpg index 145389e0..7740dccd 100644 Binary files a/.github/resources/integ-service-account.json.gpg and b/.github/resources/integ-service-account.json.gpg differ 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/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/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" 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 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", diff --git a/messaging/messaging.go b/messaging/messaging.go index 858e75ff..525cccb6 100644 --- a/messaging/messaging.go +++ b/messaging/messaging.go @@ -23,6 +23,7 @@ import ( "fmt" "net/http" "regexp" + "runtime" "strconv" "strings" "time" @@ -121,6 +122,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). @@ -892,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 388154b0..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" @@ -144,6 +146,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{ @@ -1365,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 {