Skip to content

Commit 357ed71

Browse files
authored
Release 2.6.0 (#106)
* 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)
1 parent 47a0557 commit 357ed71

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+4732
-96
lines changed

.travis.yml

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,30 @@
11
language: go
2+
3+
go:
4+
- 1.7.x
5+
- 1.8.x
6+
- 1.9.x
7+
- "1.10.x"
8+
- master
9+
10+
matrix:
11+
# Build OK if fails on unstable development versions of Go.
12+
allow_failures:
13+
- go: master
14+
# Don't wait for tests to finish on allow_failures.
15+
# Mark the build finished if tests pass on other versions of Go.
16+
fast_finish: true
17+
218
go_import_path: firebase.google.com/go
19+
320
before_install:
4-
- go get github.com/golang/lint/golint
21+
- go get github.com/golang/lint/golint # Golint requires Go 1.6 or later.
22+
23+
install:
24+
# Prior to golang 1.8, this can trigger an error for packages containing only tests.
25+
- go get -t -v $(go list ./... | grep -v integration)
26+
527
script:
628
- golint -set_exit_status $(go list ./...)
7-
- go test -v -test.short ./...
8-
29+
- go test -v -race -test.short ./... # Run tests with the race detector.
30+
- go vet -v ./... # Run Go static analyzer.

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

33
-
44

5+
# v2.6.0
6+
7+
- [changed] Improved error handling in FCM by mapping more server-side
8+
errors to client-side error codes.
9+
- [added] Added the `db` package for interacting with the Firebase database.
10+
511
# v2.5.0
612

713
- [changed] Import context from `golang.org/x/net` for 1.6 compatibility

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
[![Build Status](https://travis-ci.org/firebase/firebase-admin-go.svg?branch=master)](https://travis-ci.org/firebase/firebase-admin-go)
22
[![GoDoc](https://godoc.org/firebase.google.com/go?status.svg)](https://godoc.org/firebase.google.com/go)
3+
[![Go Report Card](https://goreportcard.com/badge/github.com/firebase/firebase-admin-go)](https://goreportcard.com/report/github.com/firebase/firebase-admin-go)
34

45
# Firebase Admin Go SDK
56

@@ -43,6 +44,9 @@ requests, code review feedback, and also pull requests.
4344

4445
* [Setup Guide](https://firebase.google.com/docs/admin/setup/)
4546
* [Authentication Guide](https://firebase.google.com/docs/auth/admin/)
47+
* [Cloud Firestore](https://firebase.google.com/docs/firestore/)
48+
* [Cloud Messaging Guide](https://firebase.google.com/docs/cloud-messaging/admin/)
49+
* [Storage Guide](https://firebase.google.com/docs/storage/admin/start)
4650
* [API Reference](https://godoc.org/firebase.google.com/go)
4751
* [Release Notes](https://firebase.google.com/support/release-notes/admin/go)
4852

auth/auth.go

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

1818
import (
19+
"context"
1920
"crypto/rsa"
2021
"crypto/x509"
2122
"encoding/json"
@@ -25,7 +26,6 @@ import (
2526
"strings"
2627

2728
"firebase.google.com/go/internal"
28-
"golang.org/x/net/context"
2929
"google.golang.org/api/identitytoolkit/v3"
3030
"google.golang.org/api/transport"
3131
)
@@ -78,7 +78,7 @@ type signer interface {
7878
// NewClient creates a new instance of the Firebase Auth Client.
7979
//
8080
// This function can only be invoked from within the SDK. Client applications should access the
81-
// the Auth service through firebase.App.
81+
// Auth service through firebase.App.
8282
func NewClient(ctx context.Context, c *internal.AuthConfig) (*Client, error) {
8383
var (
8484
err error

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-
"golang.org/x/net/context"
20+
"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 "golang.org/x/net/context"
19+
import "context"
2020

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

auth/auth_test.go

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

1717
import (
18+
"context"
1819
"encoding/json"
1920
"errors"
2021
"fmt"
@@ -25,7 +26,6 @@ import (
2526
"testing"
2627
"time"
2728

28-
"golang.org/x/net/context"
2929
"golang.org/x/oauth2/google"
3030

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

auth/jwt_test.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
// Copyright 2017 Google Inc. All Rights Reserved.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
115
package auth
216

317
import (

auth/user_mgt.go

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

1717
import (
18+
"context"
1819
"encoding/json"
1920
"fmt"
2021
"net/http"
@@ -23,7 +24,6 @@ import (
2324
"strings"
2425
"time"
2526

26-
"golang.org/x/net/context"
2727
"google.golang.org/api/identitytoolkit/v3"
2828
"google.golang.org/api/iterator"
2929
)

auth/user_mgt_test.go

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

1717
import (
1818
"bytes"
19+
"context"
1920
"encoding/json"
2021
"fmt"
2122
"io/ioutil"
@@ -28,7 +29,6 @@ import (
2829

2930
"firebase.google.com/go/internal"
3031

31-
"golang.org/x/net/context"
3232
"golang.org/x/oauth2"
3333
"google.golang.org/api/identitytoolkit/v3"
3434
"google.golang.org/api/iterator"
@@ -167,9 +167,9 @@ func TestListUsers(t *testing.T) {
167167
defer s.Close()
168168

169169
want := []*ExportedUserRecord{
170-
&ExportedUserRecord{UserRecord: testUser, PasswordHash: "passwordhash1", PasswordSalt: "salt1"},
171-
&ExportedUserRecord{UserRecord: testUser, PasswordHash: "passwordhash2", PasswordSalt: "salt2"},
172-
&ExportedUserRecord{UserRecord: testUser, PasswordHash: "passwordhash3", PasswordSalt: "salt3"},
170+
{UserRecord: testUser, PasswordHash: "passwordhash1", PasswordSalt: "salt1"},
171+
{UserRecord: testUser, PasswordHash: "passwordhash2", PasswordSalt: "salt2"},
172+
{UserRecord: testUser, PasswordHash: "passwordhash3", PasswordSalt: "salt3"},
173173
}
174174

175175
testIterator := func(iter *UserIterator, token string, req map[string]interface{}) {
@@ -574,9 +574,9 @@ func TestInvalidSetCustomClaims(t *testing.T) {
574574
func TestSetCustomClaims(t *testing.T) {
575575
cases := []map[string]interface{}{
576576
nil,
577-
map[string]interface{}{},
578-
map[string]interface{}{"admin": true},
579-
map[string]interface{}{"admin": true, "package": "gold"},
577+
{},
578+
{"admin": true},
579+
{"admin": true, "package": "gold"},
580580
}
581581

582582
resp := `{

db/auth_override_test.go

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
// Copyright 2018 Google Inc. All Rights Reserved.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
package db
16+
17+
import (
18+
"testing"
19+
20+
"golang.org/x/net/context"
21+
)
22+
23+
func TestAuthOverrideGet(t *testing.T) {
24+
mock := &mockServer{Resp: "data"}
25+
srv := mock.Start(aoClient)
26+
defer srv.Close()
27+
28+
ref := aoClient.NewRef("peter")
29+
var got string
30+
if err := ref.Get(context.Background(), &got); err != nil {
31+
t.Fatal(err)
32+
}
33+
if got != "data" {
34+
t.Errorf("Ref(AuthOverride).Get() = %q; want = %q", got, "data")
35+
}
36+
checkOnlyRequest(t, mock.Reqs, &testReq{
37+
Method: "GET",
38+
Path: "/peter.json",
39+
Query: map[string]string{"auth_variable_override": testAuthOverrides},
40+
})
41+
}
42+
43+
func TestAuthOverrideSet(t *testing.T) {
44+
mock := &mockServer{}
45+
srv := mock.Start(aoClient)
46+
defer srv.Close()
47+
48+
ref := aoClient.NewRef("peter")
49+
want := map[string]interface{}{"name": "Peter Parker", "age": float64(17)}
50+
if err := ref.Set(context.Background(), want); err != nil {
51+
t.Fatal(err)
52+
}
53+
checkOnlyRequest(t, mock.Reqs, &testReq{
54+
Method: "PUT",
55+
Body: serialize(want),
56+
Path: "/peter.json",
57+
Query: map[string]string{"auth_variable_override": testAuthOverrides, "print": "silent"},
58+
})
59+
}
60+
61+
func TestAuthOverrideQuery(t *testing.T) {
62+
mock := &mockServer{Resp: "data"}
63+
srv := mock.Start(aoClient)
64+
defer srv.Close()
65+
66+
ref := aoClient.NewRef("peter")
67+
var got string
68+
if err := ref.OrderByChild("foo").Get(context.Background(), &got); err != nil {
69+
t.Fatal(err)
70+
}
71+
if got != "data" {
72+
t.Errorf("Ref(AuthOverride).OrderByChild() = %q; want = %q", got, "data")
73+
}
74+
checkOnlyRequest(t, mock.Reqs, &testReq{
75+
Method: "GET",
76+
Path: "/peter.json",
77+
Query: map[string]string{
78+
"auth_variable_override": testAuthOverrides,
79+
"orderBy": "\"foo\"",
80+
},
81+
})
82+
}
83+
84+
func TestAuthOverrideRangeQuery(t *testing.T) {
85+
mock := &mockServer{Resp: "data"}
86+
srv := mock.Start(aoClient)
87+
defer srv.Close()
88+
89+
ref := aoClient.NewRef("peter")
90+
var got string
91+
if err := ref.OrderByChild("foo").StartAt(1).EndAt(10).Get(context.Background(), &got); err != nil {
92+
t.Fatal(err)
93+
}
94+
if got != "data" {
95+
t.Errorf("Ref(AuthOverride).OrderByChild() = %q; want = %q", got, "data")
96+
}
97+
checkOnlyRequest(t, mock.Reqs, &testReq{
98+
Method: "GET",
99+
Path: "/peter.json",
100+
Query: map[string]string{
101+
"auth_variable_override": testAuthOverrides,
102+
"orderBy": "\"foo\"",
103+
"startAt": "1",
104+
"endAt": "10",
105+
},
106+
})
107+
}

0 commit comments

Comments
 (0)