Skip to content

Commit c5db67b

Browse files
avishalomhiranya911
authored andcommitted
Release 2.6.1 (#122)
* Renamed some tests and test parameters for clarity, and adhere to Go conventions (#74) * clean unused types (#76) * Create CHANGELOG.md (#75) (#79) * Create CHANGELOG.md Initial changelog based on https://firebase.google.com/support/release-notes/admin/go * change instance ID format (#82) Changing the format of the "non-existing" instance ID in the integration tests to comply with the expected iid format. * Import context from golang.org/x/net/ for 1.6 compatibility (#87) * import golang.org/x/net/context instead of context for 1.6 compatibility * Document non existing name in integration tests for iid (#85) * Revoke Tokens (#77) Adding TokensValidAfterMillis property, RevokeRefreshTokens(), and VerifyIDTokenAndCheckRevoked(). * Firebase Cloud Messaging API (#81) * Adding Firebase Cloud Messaging (#62) * initial commit for adding Firebase Cloud Messaging * add validator * use http const in messaging test * add client version header for stats * init integration test * add integration test (validated on IOS today) * add comment with URL to enable Firebase Cloud Messaging API * fix broken test * add integration tests * accept a Message instead of RequestMessage + and rename method + send / sendDryRun * update fcm url * rollback url endpoint * fix http constants, change responseMessage visibility, change map[string]interface{} as map[string]string * fix http constants * fix integration tests * fix APNS naming * add validators * Added APNS types; Updated tests * Added more tests; Fixed APNS serialization * Updated documentation * Improved error handling inFCM * Added utils file * Updated integration tests * Implemented topic management operations * Added integration tests * Updated CHANGELOG * Addressing code review comments * Supporting 0 valued Aps.Badge * Addressing some review comments * Removed some unused vars * Accepting prefixed topic names (#84) * Accepting prefixed topic named * Added a comment * Using new FCM error codes (#89) * Bumped version to 2.5.0 (#90) * Lint (#96) * fix misspelling * add check error * missing copyright * Doc (#97) * update readme with Authentication Guide & Release Notes * fix a misspelling : separately * fix missing newline before package * add Go Report Card + update doc * add travis build for go versions 1.7.x -> 1.10.x (#98) * add build for go version 1.6.x -> 1.10.x * fix 1.10 version * fix context to golang.org/x/net/context for go 1.6 compatibility * add race detector + go vet on build + build without failure on go unstable * add go16 et go17 file due to req.withcontext which is only go 1.7 * fix context package * update go16.go to remove WithContext * update bad import * remove unused func * finally use ctxhttp.Do with multiple build version * ignore integration package for install * fix go get command * put go 1.6.X in allow_failures dur to test failure * fix inversion of code * remove go 1.6 support * revert initial version with req.WithContext * fix travis to support go 1.10.x * nits * Import context from standard package (#101) * Import context from standard package. * Firebase Database API (#92) * Experimental RTDB code * Added ref.Set() * Added Push(), Update(), Remove() and tests * Adding Transaction() support * Fixed Transaction() API * Code cleanup * Implemented Query() API * Added GetIfChanged() and integration tests * More integration tests * Updated unit test * More integration tests * Integration tests for queries * Auth override support and more tests * More test cases; AuthOverride support in App * Implemented AuthOverride support; Added tests * Implementing the new API * More code cleanup * Code clean up * Refactored the http client code * More tests * Boosted test coverage to 97% * Better error messages in tests; Added license headers * Added documentatioon and cleaned up tests * Fixing a build break * Finishing up documentation * More test cases * Implemented a reusable HTTP client API * Added test cases * Comment clean up * Using the shared http client API * Simplified the usage by adding HTTPClient * using the new client API * Using the old ctx import * Using the old context import * Refactored db code * More refactoring * Support for arbitrary entity types in the request * Renamed fields; Added documentation * Removing a redundant else case * Code readability improvements * Cleaned up the RTDB HTTP client code * Added shallow reads support; Added the new txn API * Implementing GetOrdered() for queries * Adding more sorting tests * Added Query ordering tests * Fixing some lint errors and compilation errors * Removing unused function * Cleaned up unit tests for db * Updated query impl and tests * Added integration tests for ordered queries * Removed With*() from query functions * Updated change log; Added more tests * Support for database url in auto init * Support for loading auth overrides from env * Removed db.AuthOverride type * Renamed ao to authOverride everywhere; Other code review nits * Introducing the QueryNode interface to handle ordered query results (#100) * Database Sample Snippets (#102) * Adding database snippets * Adding query snippets * Added complex query samples * Updated variable name * Fixing a typo * Fixing query example * Updated DB snippets to use GetOrdered() * Removing unnecessary placeholders in Fatalln() calls * Removing unnecessary placeholders in Fatalln() calls * Handling FCM canonical error codes (#103) * Formatting test file with gofmt (#104) * Bumped version to 2.6.0 (#105) * Formatting (simplification) changes (#107) * Checking for unformatted files in CI (#108) * Checking for unformatted files in CI * Adding newline at eof * Document Minimum Go Version (#111) * Fix invalid endpoint URL for topic unsubscribe (#114) * Fix error message for missing user (#113) * Update CHANGELOG.md (#117) * Removing unused member from auth.Client (#118) * Support Go 1.6 (#120) * all: use golang.org/x/net/context * internal: use ctxhttp to use /x/ context The 1.6 Request type doesn't have WithContext. * all: don't use subtests to keep 1.6 compatibility * integration: use float64 for fields with exp value Values like -7e+07 cannot be parsed into ints in Go 1.6. So, use floats instead. * integration/messaging: use t.Fatal not log.Fatal * travis: add 1.6.x * changelog: mention addition of 1.6 support * readme: mention go version support * Bumped version to 2.6.1 (#121) * Changlog updates (#123)
1 parent 357ed71 commit c5db67b

36 files changed

+161
-120
lines changed

.travis.gofmt.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/bash
2+
if [[ ! -z "$(gofmt -l -s .)" ]]; then
3+
echo "Go code is not formatted:"
4+
gofmt -d -s .
5+
exit 1
6+
fi

.travis.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
language: go
22

33
go:
4+
- 1.6.x
45
- 1.7.x
56
- 1.8.x
67
- 1.9.x
@@ -26,5 +27,6 @@ install:
2627

2728
script:
2829
- golint -set_exit_status $(go list ./...)
30+
- ./.travis.gofmt.sh
2931
- go test -v -race -test.short ./... # Run tests with the race detector.
3032
- go vet -v ./... # Run Go static analyzer.

CHANGELOG.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
# Unreleased
22

3-
-
3+
# v2.6.1
4+
5+
- [added] Added support for Go 1.6.
6+
- [changed] Fixed a bug in the
7+
[`UnsubscribeFromTopic()`](https://godoc.org/firebase.google.com/go/messaging#Client.UnsubscribeFromTopic)
8+
function.
9+
- [changed] Improved the error message returned by `GetUser()`,
10+
`GetUserByEmail()` and `GetUserByPhoneNumber()` APIs in
11+
[`auth`](https://godoc.org/firebase.google.com/go/auth) package.
412

513
# v2.6.0
614

README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,13 @@ go get firebase.google.com/go
3737

3838
Please refer to the [CONTRIBUTING page](./CONTRIBUTING.md) for more information
3939
about how you can contribute to this project. We welcome bug reports, feature
40-
requests, code review feedback, and also pull requests.
40+
requests, code review feedback, and also pull requests.
4141

42+
## Supported Go Versions
43+
44+
We support Go v1.6 and higher.
45+
[Continuous integration](https://travis-ci.org/firebase/firebase-admin-go) system
46+
tests the code on Go v1.6 through v1.10.
4247

4348
## Documentation
4449

auth/auth.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
package auth
1717

1818
import (
19-
"context"
2019
"crypto/rsa"
2120
"crypto/x509"
2221
"encoding/json"
@@ -25,6 +24,8 @@ import (
2524
"fmt"
2625
"strings"
2726

27+
"golang.org/x/net/context"
28+
2829
"firebase.google.com/go/internal"
2930
"google.golang.org/api/identitytoolkit/v3"
3031
"google.golang.org/api/transport"
@@ -62,7 +63,6 @@ type Token struct {
6263
// Client facilitates generating custom JWT tokens for Firebase clients, and verifying ID tokens issued
6364
// by Firebase backend services.
6465
type Client struct {
65-
hc *internal.HTTPClient
6666
is *identitytoolkit.Service
6767
ks keySource
6868
projectID string
@@ -123,7 +123,6 @@ func NewClient(ctx context.Context, c *internal.AuthConfig) (*Client, error) {
123123
}
124124

125125
return &Client{
126-
hc: &internal.HTTPClient{Client: hc},
127126
is: is,
128127
ks: newHTTPKeySource(googleCertURL, hc),
129128
projectID: c.ProjectID,

auth/auth_appengine.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
package auth
1818

1919
import (
20-
"context"
20+
"golang.org/x/net/context"
2121

2222
"google.golang.org/appengine"
2323
)

auth/auth_std.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
package auth
1818

19-
import "context"
19+
import "golang.org/x/net/context"
2020

2121
func newSigner(ctx context.Context) (signer, error) {
2222
return serviceAcctSigner{}, nil

auth/auth_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
package auth
1616

1717
import (
18-
"context"
1918
"encoding/json"
2019
"errors"
2120
"fmt"
@@ -26,6 +25,8 @@ import (
2625
"testing"
2726
"time"
2827

28+
"golang.org/x/net/context"
29+
2930
"golang.org/x/oauth2/google"
3031

3132
"google.golang.org/api/option"

auth/user_mgt.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
package auth
1616

1717
import (
18-
"context"
1918
"encoding/json"
2019
"fmt"
2120
"net/http"
@@ -24,6 +23,8 @@ import (
2423
"strings"
2524
"time"
2625

26+
"golang.org/x/net/context"
27+
2728
"google.golang.org/api/identitytoolkit/v3"
2829
"google.golang.org/api/iterator"
2930
)
@@ -567,7 +568,7 @@ func (c *Client) getUser(ctx context.Context, request *identitytoolkit.Identityt
567568
return nil, err
568569
}
569570
if len(resp.Users) == 0 {
570-
return nil, fmt.Errorf("cannot find user from params: %v", request)
571+
return nil, fmt.Errorf("cannot find user given params: id:%v, phone:%v, email: %v", request.LocalId, request.PhoneNumber, request.Email)
571572
}
572573

573574
eu, err := makeExportedUser(resp.Users[0])

auth/user_mgt_test.go

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ package auth
1616

1717
import (
1818
"bytes"
19-
"context"
2019
"encoding/json"
2120
"fmt"
2221
"io/ioutil"
@@ -27,6 +26,8 @@ import (
2726
"testing"
2827
"time"
2928

29+
"golang.org/x/net/context"
30+
3031
"firebase.google.com/go/internal"
3132

3233
"golang.org/x/oauth2"
@@ -148,17 +149,24 @@ func TestGetNonExistingUser(t *testing.T) {
148149
s := echoServer([]byte(resp), t)
149150
defer s.Close()
150151

151-
user, err := s.Client.GetUser(context.Background(), "ignored_id")
152-
if user != nil || err == nil {
153-
t.Errorf("GetUser(non-existing) = (%v, %v); want = (nil, error)", user, err)
152+
want := "cannot find user given params: id:[%s], phone:[%s], email: [%s]"
153+
154+
we := fmt.Sprintf(want, "id-nonexisting", "", "")
155+
user, err := s.Client.GetUser(context.Background(), "id-nonexisting")
156+
if user != nil || err == nil || err.Error() != we {
157+
t.Errorf("GetUser(non-existing) = (%v, %q); want = (nil, %q)", user, err, we)
154158
}
155-
user, err = s.Client.GetUserByEmail(context.Background(), "test@email.com")
156-
if user != nil || err == nil {
157-
t.Errorf("GetUserByEmail(non-existing) = (%v, %v); want = (nil, error)", user, err)
159+
160+
we = fmt.Sprintf(want, "", "", "foo@bar.nonexisting")
161+
user, err = s.Client.GetUserByEmail(context.Background(), "foo@bar.nonexisting")
162+
if user != nil || err == nil || err.Error() != we {
163+
t.Errorf("GetUserByEmail(non-existing) = (%v, %q); want = (nil, %q)", user, err, we)
158164
}
159-
user, err = s.Client.GetUserByPhoneNumber(context.Background(), "+1234567890")
160-
if user != nil || err == nil {
161-
t.Errorf("GetUserPhoneNumber(non-existing) = (%v, %v); want = (nil, error)", user, err)
165+
166+
we = fmt.Sprintf(want, "", "+12345678901", "")
167+
user, err = s.Client.GetUserByPhoneNumber(context.Background(), "+12345678901")
168+
if user != nil || err == nil || err.Error() != we {
169+
t.Errorf("GetUserPhoneNumber(non-existing) = (%v, %q); want = (nil, %q)", user, err, we)
162170
}
163171
}
164172

db/db_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ func TestNewClient(t *testing.T) {
107107
func TestNewClientAuthOverrides(t *testing.T) {
108108
cases := []map[string]interface{}{
109109
nil,
110-
map[string]interface{}{"uid": "user1"},
110+
{"uid": "user1"},
111111
}
112112
for _, tc := range cases {
113113
c, err := NewClient(context.Background(), &internal.DatabaseConfig{

db/query.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ func (q *queryNodeImpl) Key() string {
306306
if q.CompKey.Str != nil {
307307
return *q.CompKey.Str
308308
}
309-
// Numeric keys in queryNodeImpl are always array indices, and can be safely coverted into int.
309+
// Numeric keys in queryNodeImpl are always array indices, and can be safely converted into int.
310310
return strconv.Itoa(int(*q.CompKey.Num))
311311
}
312312

db/ref_test.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -265,12 +265,12 @@ func TestGetIfChanged(t *testing.T) {
265265
}
266266

267267
checkAllRequests(t, mock.Reqs, []*testReq{
268-
&testReq{
268+
{
269269
Method: "GET",
270270
Path: "/peter.json",
271271
Header: http.Header{"If-None-Match": []string{"old-etag"}},
272272
},
273-
&testReq{
273+
{
274274
Method: "GET",
275275
Path: "/peter.json",
276276
Header: http.Header{"If-None-Match": []string{"new-etag"}},
@@ -513,7 +513,7 @@ func TestInvalidUpdate(t *testing.T) {
513513
cases := []map[string]interface{}{
514514
nil,
515515
make(map[string]interface{}),
516-
map[string]interface{}{"foo": func() {}},
516+
{"foo": func() {}},
517517
}
518518
for _, tc := range cases {
519519
if err := testref.Update(context.Background(), tc); err == nil {
@@ -542,12 +542,12 @@ func TestTransaction(t *testing.T) {
542542
t.Fatal(err)
543543
}
544544
checkAllRequests(t, mock.Reqs, []*testReq{
545-
&testReq{
545+
{
546546
Method: "GET",
547547
Path: "/peter.json",
548548
Header: http.Header{"X-Firebase-ETag": []string{"true"}},
549549
},
550-
&testReq{
550+
{
551551
Method: "PUT",
552552
Path: "/peter.json",
553553
Body: serialize(map[string]interface{}{
@@ -591,12 +591,12 @@ func TestTransactionRetry(t *testing.T) {
591591
t.Errorf("Transaction() retries = %d; want = %d", cnt, 2)
592592
}
593593
checkAllRequests(t, mock.Reqs, []*testReq{
594-
&testReq{
594+
{
595595
Method: "GET",
596596
Path: "/peter.json",
597597
Header: http.Header{"X-Firebase-ETag": []string{"true"}},
598598
},
599-
&testReq{
599+
{
600600
Method: "PUT",
601601
Path: "/peter.json",
602602
Body: serialize(map[string]interface{}{
@@ -605,7 +605,7 @@ func TestTransactionRetry(t *testing.T) {
605605
}),
606606
Header: http.Header{"If-Match": []string{"mock-etag1"}},
607607
},
608-
&testReq{
608+
{
609609
Method: "PUT",
610610
Path: "/peter.json",
611611
Body: serialize(map[string]interface{}{
@@ -650,12 +650,12 @@ func TestTransactionError(t *testing.T) {
650650
t.Errorf("Transaction() retries = %d; want = %d", cnt, 1)
651651
}
652652
checkAllRequests(t, mock.Reqs, []*testReq{
653-
&testReq{
653+
{
654654
Method: "GET",
655655
Path: "/peter.json",
656656
Header: http.Header{"X-Firebase-ETag": []string{"true"}},
657657
},
658-
&testReq{
658+
{
659659
Method: "PUT",
660660
Path: "/peter.json",
661661
Body: serialize(map[string]interface{}{
@@ -694,7 +694,7 @@ func TestTransactionAbort(t *testing.T) {
694694
t.Errorf("Transaction() = nil; want error")
695695
}
696696
wanted := []*testReq{
697-
&testReq{
697+
{
698698
Method: "GET",
699699
Path: "/peter.json",
700700
Header: http.Header{"X-Firebase-ETag": []string{"true"}},

firebase.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,13 @@
1818
package firebase
1919

2020
import (
21-
"context"
2221
"encoding/json"
2322
"errors"
2423
"io/ioutil"
2524
"os"
2625

26+
"golang.org/x/net/context"
27+
2728
"cloud.google.com/go/firestore"
2829

2930
"firebase.google.com/go/auth"
@@ -41,7 +42,7 @@ import (
4142
var defaultAuthOverrides = make(map[string]interface{})
4243

4344
// Version of the Firebase Go Admin SDK.
44-
const Version = "2.6.0"
45+
const Version = "2.6.1"
4546

4647
// firebaseEnvName is the name of the environment variable with the Config.
4748
const firebaseEnvName = "FIREBASE_CONFIG"

firebase_test.go

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@
1515
package firebase
1616

1717
import (
18-
"context"
19-
"fmt"
2018
"io/ioutil"
2119
"log"
2220
"net/http"
@@ -28,6 +26,8 @@ import (
2826
"testing"
2927
"time"
3028

29+
"golang.org/x/net/context"
30+
3131
"golang.org/x/oauth2/google"
3232

3333
"google.golang.org/api/transport"
@@ -247,8 +247,8 @@ func TestDatabase(t *testing.T) {
247247
func TestDatabaseAuthOverrides(t *testing.T) {
248248
cases := []map[string]interface{}{
249249
nil,
250-
map[string]interface{}{},
251-
map[string]interface{}{"uid": "user1"},
250+
{},
251+
{"uid": "user1"},
252252
}
253253
for _, tc := range cases {
254254
ctx := context.Background()
@@ -539,15 +539,13 @@ func TestAutoInit(t *testing.T) {
539539
defer reinstateEnv(credEnvVar, credOld)
540540

541541
for _, test := range tests {
542-
t.Run(fmt.Sprintf("NewApp(%s)", test.name), func(t *testing.T) {
543-
overwriteEnv(firebaseEnvName, test.optionsConfig)
544-
app, err := NewApp(context.Background(), test.initOptions)
545-
if err != nil {
546-
t.Error(err)
547-
} else {
548-
compareConfig(app, test.wantOptions, t)
549-
}
550-
})
542+
overwriteEnv(firebaseEnvName, test.optionsConfig)
543+
app, err := NewApp(context.Background(), test.initOptions)
544+
if err != nil {
545+
t.Errorf("NewApp(%s): %v", test.name, err)
546+
} else {
547+
compareConfig(app, test.wantOptions, t)
548+
}
551549
}
552550
}
553551

@@ -577,13 +575,11 @@ func TestAutoInitInvalidFiles(t *testing.T) {
577575
defer reinstateEnv(credEnvVar, credOld)
578576

579577
for _, test := range tests {
580-
t.Run(test.name, func(t *testing.T) {
581-
overwriteEnv(firebaseEnvName, test.filename)
582-
_, err := NewApp(context.Background(), nil)
583-
if err == nil || err.Error() != test.wantError {
584-
t.Errorf("got error = %s; want = %s", err, test.wantError)
585-
}
586-
})
578+
overwriteEnv(firebaseEnvName, test.filename)
579+
_, err := NewApp(context.Background(), nil)
580+
if err == nil || err.Error() != test.wantError {
581+
t.Errorf("%s got error = %s; want = %s", test.name, err, test.wantError)
582+
}
587583
}
588584
}
589585

0 commit comments

Comments
 (0)