Skip to content

Commit

Permalink
Merge dev into master
Browse files Browse the repository at this point in the history
  • Loading branch information
google-oss-bot authored Oct 24, 2024
2 parents 6a28190 + b8f0b13 commit c3be6f2
Show file tree
Hide file tree
Showing 13 changed files with 68 additions and 7 deletions.
Binary file modified .github/resources/integ-service-account.json.gpg
Binary file not shown.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 3 additions & 0 deletions auth/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"errors"
"fmt"
"os"
"runtime"
"strings"
"time"

Expand Down Expand Up @@ -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
Expand Down
8 changes: 8 additions & 0 deletions auth/auth_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"log"
"net/http"
"os"
"runtime"
"strings"
"syscall"
"testing"
Expand Down Expand Up @@ -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
}

Expand Down
7 changes: 7 additions & 0 deletions auth/user_mgt_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"net/http"
"net/http/httptest"
"reflect"
"runtime"
"sort"
"strconv"
"strings"
Expand Down Expand Up @@ -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)
}
Expand Down
2 changes: 1 addition & 1 deletion firebase.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -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
Expand Down
3 changes: 3 additions & 0 deletions integration/messaging/messaging_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down Expand Up @@ -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++ {
Expand Down Expand Up @@ -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",
Expand Down
4 changes: 4 additions & 0 deletions messaging/messaging.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"fmt"
"net/http"
"regexp"
"runtime"
"strconv"
"strings"
"time"
Expand Down Expand Up @@ -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).
Expand Down Expand Up @@ -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{
Expand Down
36 changes: 36 additions & 0 deletions messaging/messaging_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ import (
"net/http"
"net/http/httptest"
"reflect"
"runtime"
"strings"
"testing"
"time"

Expand Down Expand Up @@ -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{
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit c3be6f2

Please sign in to comment.