Skip to content

Commit

Permalink
Merge branch 'dev' into dev-add-sign_in_attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
SpringMT authored Oct 25, 2024
2 parents d2f7c4b + b8f0b13 commit 151d72d
Show file tree
Hide file tree
Showing 12 changed files with 40 additions and 9 deletions.
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 @@ -1452,6 +1453,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
5 changes: 4 additions & 1 deletion 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,7 +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"`
DirectBootOK bool `json:"direct_boot_ok,omitempty"`
}

// MarshalJSON marshals an AndroidConfig into JSON (for internal use only).
Expand Down Expand Up @@ -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{
Expand Down
9 changes: 8 additions & 1 deletion 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 @@ -148,7 +150,7 @@ var validMessages = []struct {
name: "AndroidDataMessage",
req: &Message{
Android: &AndroidConfig{
DirectBootOk: true,
DirectBootOK: true,
CollapseKey: "ck",
Data: map[string]string{
"k1": "v1",
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 151d72d

Please sign in to comment.