Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Unreleased

- [dropped] Dropped support for Go 1.8 and earlier.
- [fixed] Fixing error handling in FCM. The SDK now checks the key
`type.googleapis.com/google.firebase.fcm.v1.FcmError` to set error code.
- [added] `messaging.ApsAlert` type now supports subtitle in its payload.
Expand Down
2 changes: 1 addition & 1 deletion auth/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (

"google.golang.org/api/option"

"golang.org/x/net/context"
"context"

"firebase.google.com/go/internal"
"google.golang.org/api/identitytoolkit/v3"
Expand Down
3 changes: 2 additions & 1 deletion auth/auth_appengine.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@
package auth

import (
"context"

"firebase.google.com/go/internal"
"golang.org/x/net/context"

"google.golang.org/appengine"
)
Expand Down
3 changes: 2 additions & 1 deletion auth/auth_std.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@
package auth // import "firebase.google.com/go/auth"

import (
"context"

"firebase.google.com/go/internal"
"golang.org/x/net/context"
)

func newCryptoSigner(ctx context.Context, conf *internal.AuthConfig) (cryptoSigner, error) {
Expand Down
20 changes: 12 additions & 8 deletions auth/auth_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
"testing"
"time"

"golang.org/x/net/context"
"context"

"golang.org/x/oauth2/google"

Expand Down Expand Up @@ -205,10 +205,12 @@ func TestCustomTokenError(t *testing.T) {
}

for _, tc := range cases {
token, err := client.CustomTokenWithClaims(ctx, tc.uid, tc.claims)
if token != "" || err == nil {
t.Errorf("CustomTokenWithClaims(%q) = (%q, %v); want = (\"\", error)", tc.name, token, err)
}
t.Run(tc.name, func(t *testing.T) {
token, err := client.CustomTokenWithClaims(ctx, tc.uid, tc.claims)
if token != "" || err == nil {
t.Errorf("CustomTokenWithClaims(%q) = (%q, %v); want = (\"\", error)", tc.name, token, err)
}
})
}
}

Expand Down Expand Up @@ -321,9 +323,11 @@ func TestVerifyIDTokenError(t *testing.T) {
}

for _, tc := range cases {
if _, err := client.VerifyIDToken(ctx, tc.token); err == nil {
t.Errorf("VerifyIDToken(%q) = nil; want error", tc.name)
}
t.Run(tc.name, func(t *testing.T) {
if _, err := client.VerifyIDToken(ctx, tc.token); err == nil {
t.Errorf("VerifyIDToken(%q) = nil; want error", tc.name)
}
})
}
}

Expand Down
2 changes: 1 addition & 1 deletion auth/token_generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import (
"firebase.google.com/go/internal"
"google.golang.org/api/transport"

"golang.org/x/net/context"
"context"
)

type jwtHeader struct {
Expand Down
2 changes: 1 addition & 1 deletion auth/token_generator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import (
"firebase.google.com/go/internal"
"google.golang.org/api/option"

"golang.org/x/net/context"
"context"
)

func TestEncodeToken(t *testing.T) {
Expand Down
5 changes: 2 additions & 3 deletions auth/token_verifier.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ import (
"sync"
"time"

"golang.org/x/net/context"
"golang.org/x/net/context/ctxhttp"
"context"
)

// keySource is used to obtain a set of public keys, which can be used to verify cryptographic
Expand Down Expand Up @@ -89,7 +88,7 @@ func (k *httpKeySource) refreshKeys(ctx context.Context) error {
return err
}

resp, err := ctxhttp.Do(ctx, k.HTTPClient, req)
resp, err := k.HTTPClient.Do(req.WithContext(ctx))
if err != nil {
return err
}
Expand Down
3 changes: 2 additions & 1 deletion auth/user_mgt.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@ import (
"strings"
"time"

"context"

"firebase.google.com/go/internal"
"golang.org/x/net/context"

"google.golang.org/api/googleapi"
"google.golang.org/api/identitytoolkit/v3"
Expand Down
2 changes: 1 addition & 1 deletion auth/user_mgt_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (
"testing"
"time"

"golang.org/x/net/context"
"context"

"firebase.google.com/go/internal"

Expand Down
2 changes: 1 addition & 1 deletion db/auth_override_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ package db
import (
"testing"

"golang.org/x/net/context"
"context"
)

func TestAuthOverrideGet(t *testing.T) {
Expand Down
3 changes: 2 additions & 1 deletion db/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ import (

"net/url"

"golang.org/x/net/context"
"context"

"google.golang.org/api/option"
"google.golang.org/api/transport"
)
Expand Down
3 changes: 2 additions & 1 deletion db/db_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ import (
"runtime"
"testing"

"golang.org/x/net/context"
"context"

"golang.org/x/oauth2"

"encoding/json"
Expand Down
2 changes: 1 addition & 1 deletion db/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (

"firebase.google.com/go/internal"

"golang.org/x/net/context"
"context"
)

// QueryNode represents a data node retrieved from an ordered query.
Expand Down
34 changes: 19 additions & 15 deletions db/query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
"reflect"
"testing"

"golang.org/x/net/context"
"context"
)

var sortableKeysResp = map[string]interface{}{
Expand Down Expand Up @@ -297,13 +297,15 @@ func TestInvalidLimitQuery(t *testing.T) {
{"NegativeLast", q.LimitToLast(-10)},
}
for _, tc := range cases {
var got map[string]interface{}
if err := tc.q.Get(context.Background(), &got); got != nil || err == nil {
t.Errorf("OrderByChild(%q) = (%v, %v); want = (nil, error)", tc.name, got, err)
}
if len(mock.Reqs) != 0 {
t.Errorf("OrderByChild(%q): %v; want: empty", tc.name, mock.Reqs)
}
t.Run(tc.name, func(t *testing.T) {
var got map[string]interface{}
if err := tc.q.Get(context.Background(), &got); got != nil || err == nil {
t.Errorf("OrderByChild(%q) = (%v, %v); want = (nil, error)", tc.name, got, err)
}
if len(mock.Reqs) != 0 {
t.Errorf("OrderByChild(%q): %v; want: empty", tc.name, mock.Reqs)
}
})
}
}

Expand Down Expand Up @@ -383,13 +385,15 @@ func TestInvalidFilterQuery(t *testing.T) {
{"InvalidEqualTo", q.EqualTo(func() {})},
}
for _, tc := range cases {
var got map[string]interface{}
if err := tc.q.Get(context.Background(), &got); got != nil || err == nil {
t.Errorf("OrderByChild(%q) = (%v, %v); want = (nil, error)", tc.name, got, err)
}
if len(mock.Reqs) != 0 {
t.Errorf("OrdderByChild(%q) = %v; want = empty", tc.name, mock.Reqs)
}
t.Run(tc.name, func(t *testing.T) {
var got map[string]interface{}
if err := tc.q.Get(context.Background(), &got); got != nil || err == nil {
t.Errorf("OrderByChild(%q) = (%v, %v); want = (nil, error)", tc.name, got, err)
}
if len(mock.Reqs) != 0 {
t.Errorf("OrdderByChild(%q) = %v; want = empty", tc.name, mock.Reqs)
}
})
}
}

Expand Down
2 changes: 1 addition & 1 deletion db/ref.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (

"firebase.google.com/go/internal"

"golang.org/x/net/context"
"context"
)

// txnRetires is the maximum number of times a transaction is retried before giving up. Transaction
Expand Down
22 changes: 13 additions & 9 deletions db/ref_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
"reflect"
"testing"

"golang.org/x/net/context"
"context"
)

type refOp func(r *Ref) error
Expand Down Expand Up @@ -285,10 +285,12 @@ func TestWelformedHttpError(t *testing.T) {

want := "http error status: 500; reason: test error"
for _, tc := range testOps {
err := tc.op(testref)
if err == nil || err.Error() != want {
t.Errorf("%s = %v; want = %v", tc.name, err, want)
}
t.Run(tc.name, func(t *testing.T) {
err := tc.op(testref)
if err == nil || err.Error() != want {
t.Errorf("%s = %v; want = %v", tc.name, err, want)
}
})
}

if len(mock.Reqs) != len(testOps) {
Expand All @@ -303,10 +305,12 @@ func TestUnexpectedHttpError(t *testing.T) {

want := "http error status: 500; reason: \"unexpected error\""
for _, tc := range testOps {
err := tc.op(testref)
if err == nil || err.Error() != want {
t.Errorf("%s = %v; want = %v", tc.name, err, want)
}
t.Run(tc.name, func(t *testing.T) {
err := tc.op(testref)
if err == nil || err.Error() != want {
t.Errorf("%s = %v; want = %v", tc.name, err, want)
}
})
}

if len(mock.Reqs) != len(testOps) {
Expand Down
2 changes: 1 addition & 1 deletion firebase.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
"io/ioutil"
"os"

"golang.org/x/net/context"
"context"

"cloud.google.com/go/firestore"

Expand Down
31 changes: 18 additions & 13 deletions firebase_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
package firebase

import (
"fmt"
"io/ioutil"
"log"
"net/http"
Expand All @@ -26,7 +27,7 @@ import (
"testing"
"time"

"golang.org/x/net/context"
"context"

"golang.org/x/oauth2/google"

Expand Down Expand Up @@ -561,13 +562,15 @@ func TestAutoInit(t *testing.T) {
defer reinstateEnv(credEnvVar, credOld)

for _, test := range tests {
overwriteEnv(firebaseEnvName, test.optionsConfig)
app, err := NewApp(context.Background(), test.initOptions)
if err != nil {
t.Errorf("NewApp(%s): %v", test.name, err)
} else {
compareConfig(app, test.wantOptions, t)
}
t.Run(fmt.Sprintf("NewApp(%s)", test.name), func(t *testing.T) {
overwriteEnv(firebaseEnvName, test.optionsConfig)
app, err := NewApp(context.Background(), test.initOptions)
if err != nil {
t.Error(err)
} else {
compareConfig(app, test.wantOptions, t)
}
})
}
}

Expand Down Expand Up @@ -597,11 +600,13 @@ func TestAutoInitInvalidFiles(t *testing.T) {
defer reinstateEnv(credEnvVar, credOld)

for _, test := range tests {
overwriteEnv(firebaseEnvName, test.filename)
_, err := NewApp(context.Background(), nil)
if err == nil || err.Error() != test.wantError {
t.Errorf("%s got error = %s; want = %s", test.name, err, test.wantError)
}
t.Run(test.name, func(t *testing.T) {
overwriteEnv(firebaseEnvName, test.filename)
_, err := NewApp(context.Background(), nil)
if err == nil || err.Error() != test.wantError {
t.Errorf("%s got error = %s; want = %s", test.name, err, test.wantError)
}
})
}
}

Expand Down
2 changes: 1 addition & 1 deletion iid/iid.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
"fmt"
"net/http"

"golang.org/x/net/context"
"context"

"google.golang.org/api/transport"

Expand Down
2 changes: 1 addition & 1 deletion iid/iid_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
"net/http/httptest"
"testing"

"golang.org/x/net/context"
"context"

"google.golang.org/api/option"

Expand Down
2 changes: 1 addition & 1 deletion integration/auth/auth_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import (

"golang.org/x/oauth2/google"

"golang.org/x/net/context"
"context"

firebase "firebase.google.com/go"
"firebase.google.com/go/auth"
Expand Down
Loading