Skip to content

Commit c3be6f2

Browse files
Merge dev into master
2 parents 6a28190 + b8f0b13 commit c3be6f2

File tree

13 files changed

+68
-7
lines changed

13 files changed

+68
-7
lines changed
32 Bytes
Binary file not shown.

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ jobs:
88
strategy:
99
fail-fast: false
1010
matrix:
11-
go: ['1.20', '1.21', '1.22']
11+
go: ['1.21', '1.22', '1.23']
1212

1313
steps:
1414
- name: Check out code

.github/workflows/nightly.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ jobs:
3636
- name: Set up Go
3737
uses: actions/setup-go@v5
3838
with:
39-
go-version: '1.20'
39+
go-version: '1.21'
4040

4141
- name: Install golint
4242
run: go install golang.org/x/lint/golint@latest

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ jobs:
4747
- name: Set up Go
4848
uses: actions/setup-go@v5
4949
with:
50-
go-version: '1.20'
50+
go-version: '1.21'
5151

5252
- name: Install golint
5353
run: go install golang.org/x/lint/golint@latest

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@ requests, code review feedback, and also pull requests.
4545
## Supported Go Versions
4646

4747
The Admin Go SDK is compatible with at least the three most recent, major Go releases.
48-
We currently support Go v1.20 and higher.
48+
We currently support Go v1.21 and higher.
4949
[Continuous integration](https://github.com/firebase/firebase-admin-go/actions) system
50-
tests the code on Go v1.20 through v1.22.
50+
tests the code on Go v1.21 through v1.23.
5151

5252
## Documentation
5353

auth/auth.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import (
2121
"errors"
2222
"fmt"
2323
"os"
24+
"runtime"
2425
"strings"
2526
"time"
2627

@@ -133,10 +134,12 @@ func NewClient(ctx context.Context, conf *internal.AuthConfig) (*Client, error)
133134
return nil, err
134135
}
135136

137+
goVersion := strings.TrimPrefix(runtime.Version(), "go")
136138
hc := internal.WithDefaultRetryConfig(transport)
137139
hc.CreateErrFn = handleHTTPError
138140
hc.Opts = []internal.HTTPOption{
139141
internal.WithHeader("X-Client-Version", fmt.Sprintf("Go/Admin/%s", conf.Version)),
142+
internal.WithHeader("x-goog-api-client", fmt.Sprintf("gl-go/%s fire-admin/%s", goVersion, conf.Version)),
140143
}
141144

142145
baseURL := defaultAuthURL

auth/auth_test.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import (
2323
"log"
2424
"net/http"
2525
"os"
26+
"runtime"
2627
"strings"
2728
"syscall"
2829
"testing"
@@ -1451,6 +1452,13 @@ func checkBaseClient(client *Client, wantProjectID string) error {
14511452
return fmt.Errorf("version = %q; want = %q", version, wantVersion)
14521453
}
14531454

1455+
goVersion := strings.TrimPrefix(runtime.Version(), "go")
1456+
xGoogAPIClientHeader := req.Header.Get("x-goog-api-client")
1457+
wantXGoogAPIClientHeader := fmt.Sprintf("gl-go/%s fire-admin/%s", goVersion, testVersion)
1458+
if xGoogAPIClientHeader != wantXGoogAPIClientHeader {
1459+
return fmt.Errorf("x-goog-api-client header = %q; want = %q", xGoogAPIClientHeader, wantXGoogAPIClientHeader)
1460+
}
1461+
14541462
return nil
14551463
}
14561464

auth/user_mgt_test.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import (
2424
"net/http"
2525
"net/http/httptest"
2626
"reflect"
27+
"runtime"
2728
"sort"
2829
"strconv"
2930
"strings"
@@ -2315,6 +2316,12 @@ func echoServer(resp interface{}, t *testing.T) *mockAuthServer {
23152316
t.Errorf("X-Client-Version header = %q; want: %q", gh, wh)
23162317
}
23172318

2319+
gh = r.Header.Get("x-goog-api-client")
2320+
wh = fmt.Sprintf("gl-go/%s fire-admin/%s", strings.TrimPrefix(runtime.Version(), "go"), testVersion)
2321+
if gh != wh {
2322+
t.Errorf("x-goog-api-client header = %q; want: %q", gh, wh)
2323+
}
2324+
23182325
for k, v := range s.Header {
23192326
w.Header().Set(k, v)
23202327
}

firebase.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ import (
3939
var defaultAuthOverrides = make(map[string]interface{})
4040

4141
// Version of the Firebase Go Admin SDK.
42-
const Version = "4.14.1"
42+
const Version = "4.15.0"
4343

4444
// firebaseEnvName is the name of the environment variable with the Config.
4545
const firebaseEnvName = "FIREBASE_CONFIG"

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module firebase.google.com/go/v4
22

3-
go 1.20
3+
go 1.21
44

55
require (
66
cloud.google.com/go/firestore v1.15.0

integration/messaging/messaging_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,7 @@ func TestSendEachForMulticast(t *testing.T) {
230230
}
231231

232232
func TestSendAll(t *testing.T) {
233+
t.Skip("Skipping integration tests for deprecated sendAll() API")
233234
messages := []*messaging.Message{
234235
{
235236
Notification: &messaging.Notification{
@@ -289,6 +290,7 @@ func TestSendAll(t *testing.T) {
289290
}
290291

291292
func TestSendFiveHundred(t *testing.T) {
293+
t.Skip("Skipping integration tests for deprecated sendAll() API")
292294
var messages []*messaging.Message
293295
const limit = 500
294296
for i := 0; i < limit; i++ {
@@ -322,6 +324,7 @@ func TestSendFiveHundred(t *testing.T) {
322324
}
323325

324326
func TestSendMulticast(t *testing.T) {
327+
t.Skip("Skipping integration tests for deprecated SendMulticast() API")
325328
message := &messaging.MulticastMessage{
326329
Notification: &messaging.Notification{
327330
Title: "title",

messaging/messaging.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import (
2323
"fmt"
2424
"net/http"
2525
"regexp"
26+
"runtime"
2627
"strconv"
2728
"strings"
2829
"time"
@@ -121,6 +122,7 @@ type AndroidConfig struct {
121122
Data map[string]string `json:"data,omitempty"` // if specified, overrides the Data field on Message type
122123
Notification *AndroidNotification `json:"notification,omitempty"`
123124
FCMOptions *AndroidFCMOptions `json:"fcm_options,omitempty"`
125+
DirectBootOK bool `json:"direct_boot_ok,omitempty"`
124126
}
125127

126128
// MarshalJSON marshals an AndroidConfig into JSON (for internal use only).
@@ -892,10 +894,12 @@ func newFCMClient(hc *http.Client, conf *internal.MessagingConfig, messagingEndp
892894
client := internal.WithDefaultRetryConfig(hc)
893895
client.CreateErrFn = handleFCMError
894896

897+
goVersion := strings.TrimPrefix(runtime.Version(), "go")
895898
version := fmt.Sprintf("fire-admin-go/%s", conf.Version)
896899
client.Opts = []internal.HTTPOption{
897900
internal.WithHeader(apiFormatVersionHeader, apiFormatVersion),
898901
internal.WithHeader(firebaseClientHeader, version),
902+
internal.WithHeader("x-goog-api-client", fmt.Sprintf("gl-go/%s fire-admin/%s", goVersion, conf.Version)),
899903
}
900904

901905
return &fcmClient{

messaging/messaging_test.go

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ import (
2121
"net/http"
2222
"net/http/httptest"
2323
"reflect"
24+
"runtime"
25+
"strings"
2426
"testing"
2527
"time"
2628

@@ -144,6 +146,35 @@ var validMessages = []struct {
144146
"topic": "test-topic",
145147
},
146148
},
149+
{
150+
name: "AndroidDataMessage",
151+
req: &Message{
152+
Android: &AndroidConfig{
153+
DirectBootOK: true,
154+
CollapseKey: "ck",
155+
Data: map[string]string{
156+
"k1": "v1",
157+
"k2": "v2",
158+
},
159+
Priority: "normal",
160+
TTL: &ttl,
161+
},
162+
Topic: "test-topic",
163+
},
164+
want: map[string]interface{}{
165+
"android": map[string]interface{}{
166+
"direct_boot_ok": true,
167+
"collapse_key": "ck",
168+
"data": map[string]interface{}{
169+
"k1": "v1",
170+
"k2": "v2",
171+
},
172+
"priority": "normal",
173+
"ttl": "10s",
174+
},
175+
"topic": "test-topic",
176+
},
177+
},
147178
{
148179
name: "AndroidNotificationMessage",
149180
req: &Message{
@@ -1365,6 +1396,11 @@ func checkFCMRequest(t *testing.T, b []byte, tr *http.Request, want map[string]i
13651396
if h := tr.Header.Get("X-FIREBASE-CLIENT"); h != clientVersion {
13661397
t.Errorf("X-FIREBASE-CLIENT = %q; want = %q", h, clientVersion)
13671398
}
1399+
goVersion := strings.TrimPrefix(runtime.Version(), "go")
1400+
xGoogAPIClientHeader := "gl-go/" + goVersion + " fire-admin/" + testMessagingConfig.Version
1401+
if h := tr.Header.Get("x-goog-api-client"); h != xGoogAPIClientHeader {
1402+
t.Errorf("x-goog-api-client header = %q; want = %q", h, xGoogAPIClientHeader)
1403+
}
13681404
}
13691405

13701406
var httpErrors = []struct {

0 commit comments

Comments
 (0)