Skip to content

Commit

Permalink
Release 2.6.1 (#122)
Browse files Browse the repository at this point in the history
* 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)
  • Loading branch information
avishalom authored and hiranya911 committed Mar 15, 2018
1 parent 357ed71 commit c5db67b
Show file tree
Hide file tree
Showing 36 changed files with 161 additions and 120 deletions.
6 changes: 6 additions & 0 deletions .travis.gofmt.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash
if [[ ! -z "$(gofmt -l -s .)" ]]; then
echo "Go code is not formatted:"
gofmt -d -s .
exit 1
fi
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
language: go

go:
- 1.6.x
- 1.7.x
- 1.8.x
- 1.9.x
Expand All @@ -26,5 +27,6 @@ install:

script:
- golint -set_exit_status $(go list ./...)
- ./.travis.gofmt.sh
- go test -v -race -test.short ./... # Run tests with the race detector.
- go vet -v ./... # Run Go static analyzer.
10 changes: 9 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
# Unreleased

-
# v2.6.1

- [added] Added support for Go 1.6.
- [changed] Fixed a bug in the
[`UnsubscribeFromTopic()`](https://godoc.org/firebase.google.com/go/messaging#Client.UnsubscribeFromTopic)
function.
- [changed] Improved the error message returned by `GetUser()`,
`GetUserByEmail()` and `GetUserByPhoneNumber()` APIs in
[`auth`](https://godoc.org/firebase.google.com/go/auth) package.

# v2.6.0

Expand Down
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,13 @@ go get firebase.google.com/go

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

## Supported Go Versions

We support Go v1.6 and higher.
[Continuous integration](https://travis-ci.org/firebase/firebase-admin-go) system
tests the code on Go v1.6 through v1.10.

## Documentation

Expand Down
5 changes: 2 additions & 3 deletions auth/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
package auth

import (
"context"
"crypto/rsa"
"crypto/x509"
"encoding/json"
Expand All @@ -25,6 +24,8 @@ import (
"fmt"
"strings"

"golang.org/x/net/context"

"firebase.google.com/go/internal"
"google.golang.org/api/identitytoolkit/v3"
"google.golang.org/api/transport"
Expand Down Expand Up @@ -62,7 +63,6 @@ type Token struct {
// Client facilitates generating custom JWT tokens for Firebase clients, and verifying ID tokens issued
// by Firebase backend services.
type Client struct {
hc *internal.HTTPClient
is *identitytoolkit.Service
ks keySource
projectID string
Expand Down Expand Up @@ -123,7 +123,6 @@ func NewClient(ctx context.Context, c *internal.AuthConfig) (*Client, error) {
}

return &Client{
hc: &internal.HTTPClient{Client: hc},
is: is,
ks: newHTTPKeySource(googleCertURL, hc),
projectID: c.ProjectID,
Expand Down
2 changes: 1 addition & 1 deletion auth/auth_appengine.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
package auth

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

"google.golang.org/appengine"
)
Expand Down
2 changes: 1 addition & 1 deletion auth/auth_std.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

package auth

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

func newSigner(ctx context.Context) (signer, error) {
return serviceAcctSigner{}, nil
Expand Down
3 changes: 2 additions & 1 deletion auth/auth_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
package auth

import (
"context"
"encoding/json"
"errors"
"fmt"
Expand All @@ -26,6 +25,8 @@ import (
"testing"
"time"

"golang.org/x/net/context"

"golang.org/x/oauth2/google"

"google.golang.org/api/option"
Expand Down
5 changes: 3 additions & 2 deletions auth/user_mgt.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
package auth

import (
"context"
"encoding/json"
"fmt"
"net/http"
Expand All @@ -24,6 +23,8 @@ import (
"strings"
"time"

"golang.org/x/net/context"

"google.golang.org/api/identitytoolkit/v3"
"google.golang.org/api/iterator"
)
Expand Down Expand Up @@ -567,7 +568,7 @@ func (c *Client) getUser(ctx context.Context, request *identitytoolkit.Identityt
return nil, err
}
if len(resp.Users) == 0 {
return nil, fmt.Errorf("cannot find user from params: %v", request)
return nil, fmt.Errorf("cannot find user given params: id:%v, phone:%v, email: %v", request.LocalId, request.PhoneNumber, request.Email)
}

eu, err := makeExportedUser(resp.Users[0])
Expand Down
28 changes: 18 additions & 10 deletions auth/user_mgt_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ package auth

import (
"bytes"
"context"
"encoding/json"
"fmt"
"io/ioutil"
Expand All @@ -27,6 +26,8 @@ import (
"testing"
"time"

"golang.org/x/net/context"

"firebase.google.com/go/internal"

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

user, err := s.Client.GetUser(context.Background(), "ignored_id")
if user != nil || err == nil {
t.Errorf("GetUser(non-existing) = (%v, %v); want = (nil, error)", user, err)
want := "cannot find user given params: id:[%s], phone:[%s], email: [%s]"

we := fmt.Sprintf(want, "id-nonexisting", "", "")
user, err := s.Client.GetUser(context.Background(), "id-nonexisting")
if user != nil || err == nil || err.Error() != we {
t.Errorf("GetUser(non-existing) = (%v, %q); want = (nil, %q)", user, err, we)
}
user, err = s.Client.GetUserByEmail(context.Background(), "test@email.com")
if user != nil || err == nil {
t.Errorf("GetUserByEmail(non-existing) = (%v, %v); want = (nil, error)", user, err)

we = fmt.Sprintf(want, "", "", "foo@bar.nonexisting")
user, err = s.Client.GetUserByEmail(context.Background(), "foo@bar.nonexisting")
if user != nil || err == nil || err.Error() != we {
t.Errorf("GetUserByEmail(non-existing) = (%v, %q); want = (nil, %q)", user, err, we)
}
user, err = s.Client.GetUserByPhoneNumber(context.Background(), "+1234567890")
if user != nil || err == nil {
t.Errorf("GetUserPhoneNumber(non-existing) = (%v, %v); want = (nil, error)", user, err)

we = fmt.Sprintf(want, "", "+12345678901", "")
user, err = s.Client.GetUserByPhoneNumber(context.Background(), "+12345678901")
if user != nil || err == nil || err.Error() != we {
t.Errorf("GetUserPhoneNumber(non-existing) = (%v, %q); want = (nil, %q)", user, err, we)
}
}

Expand Down
2 changes: 1 addition & 1 deletion db/db_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ func TestNewClient(t *testing.T) {
func TestNewClientAuthOverrides(t *testing.T) {
cases := []map[string]interface{}{
nil,
map[string]interface{}{"uid": "user1"},
{"uid": "user1"},
}
for _, tc := range cases {
c, err := NewClient(context.Background(), &internal.DatabaseConfig{
Expand Down
2 changes: 1 addition & 1 deletion db/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ func (q *queryNodeImpl) Key() string {
if q.CompKey.Str != nil {
return *q.CompKey.Str
}
// Numeric keys in queryNodeImpl are always array indices, and can be safely coverted into int.
// Numeric keys in queryNodeImpl are always array indices, and can be safely converted into int.
return strconv.Itoa(int(*q.CompKey.Num))
}

Expand Down
22 changes: 11 additions & 11 deletions db/ref_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -265,12 +265,12 @@ func TestGetIfChanged(t *testing.T) {
}

checkAllRequests(t, mock.Reqs, []*testReq{
&testReq{
{
Method: "GET",
Path: "/peter.json",
Header: http.Header{"If-None-Match": []string{"old-etag"}},
},
&testReq{
{
Method: "GET",
Path: "/peter.json",
Header: http.Header{"If-None-Match": []string{"new-etag"}},
Expand Down Expand Up @@ -513,7 +513,7 @@ func TestInvalidUpdate(t *testing.T) {
cases := []map[string]interface{}{
nil,
make(map[string]interface{}),
map[string]interface{}{"foo": func() {}},
{"foo": func() {}},
}
for _, tc := range cases {
if err := testref.Update(context.Background(), tc); err == nil {
Expand Down Expand Up @@ -542,12 +542,12 @@ func TestTransaction(t *testing.T) {
t.Fatal(err)
}
checkAllRequests(t, mock.Reqs, []*testReq{
&testReq{
{
Method: "GET",
Path: "/peter.json",
Header: http.Header{"X-Firebase-ETag": []string{"true"}},
},
&testReq{
{
Method: "PUT",
Path: "/peter.json",
Body: serialize(map[string]interface{}{
Expand Down Expand Up @@ -591,12 +591,12 @@ func TestTransactionRetry(t *testing.T) {
t.Errorf("Transaction() retries = %d; want = %d", cnt, 2)
}
checkAllRequests(t, mock.Reqs, []*testReq{
&testReq{
{
Method: "GET",
Path: "/peter.json",
Header: http.Header{"X-Firebase-ETag": []string{"true"}},
},
&testReq{
{
Method: "PUT",
Path: "/peter.json",
Body: serialize(map[string]interface{}{
Expand All @@ -605,7 +605,7 @@ func TestTransactionRetry(t *testing.T) {
}),
Header: http.Header{"If-Match": []string{"mock-etag1"}},
},
&testReq{
{
Method: "PUT",
Path: "/peter.json",
Body: serialize(map[string]interface{}{
Expand Down Expand Up @@ -650,12 +650,12 @@ func TestTransactionError(t *testing.T) {
t.Errorf("Transaction() retries = %d; want = %d", cnt, 1)
}
checkAllRequests(t, mock.Reqs, []*testReq{
&testReq{
{
Method: "GET",
Path: "/peter.json",
Header: http.Header{"X-Firebase-ETag": []string{"true"}},
},
&testReq{
{
Method: "PUT",
Path: "/peter.json",
Body: serialize(map[string]interface{}{
Expand Down Expand Up @@ -694,7 +694,7 @@ func TestTransactionAbort(t *testing.T) {
t.Errorf("Transaction() = nil; want error")
}
wanted := []*testReq{
&testReq{
{
Method: "GET",
Path: "/peter.json",
Header: http.Header{"X-Firebase-ETag": []string{"true"}},
Expand Down
5 changes: 3 additions & 2 deletions firebase.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,13 @@
package firebase

import (
"context"
"encoding/json"
"errors"
"io/ioutil"
"os"

"golang.org/x/net/context"

"cloud.google.com/go/firestore"

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

// Version of the Firebase Go Admin SDK.
const Version = "2.6.0"
const Version = "2.6.1"

// firebaseEnvName is the name of the environment variable with the Config.
const firebaseEnvName = "FIREBASE_CONFIG"
Expand Down
36 changes: 16 additions & 20 deletions firebase_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
package firebase

import (
"context"
"fmt"
"io/ioutil"
"log"
"net/http"
Expand All @@ -28,6 +26,8 @@ import (
"testing"
"time"

"golang.org/x/net/context"

"golang.org/x/oauth2/google"

"google.golang.org/api/transport"
Expand Down Expand Up @@ -247,8 +247,8 @@ func TestDatabase(t *testing.T) {
func TestDatabaseAuthOverrides(t *testing.T) {
cases := []map[string]interface{}{
nil,
map[string]interface{}{},
map[string]interface{}{"uid": "user1"},
{},
{"uid": "user1"},
}
for _, tc := range cases {
ctx := context.Background()
Expand Down Expand Up @@ -539,15 +539,13 @@ func TestAutoInit(t *testing.T) {
defer reinstateEnv(credEnvVar, credOld)

for _, test := range tests {
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)
}
})
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)
}
}
}

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

for _, test := range tests {
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("got error = %s; want = %s", err, test.wantError)
}
})
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

0 comments on commit c5db67b

Please sign in to comment.