Skip to content

Commit

Permalink
Release 2.6.0 (#106)
Browse files Browse the repository at this point in the history
* 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)
  • Loading branch information
hiranya911 authored Feb 28, 2018
1 parent 47a0557 commit 357ed71
Show file tree
Hide file tree
Showing 43 changed files with 4,732 additions and 96 deletions.
28 changes: 25 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,30 @@
language: go

go:
- 1.7.x
- 1.8.x
- 1.9.x
- "1.10.x"
- master

matrix:
# Build OK if fails on unstable development versions of Go.
allow_failures:
- go: master
# Don't wait for tests to finish on allow_failures.
# Mark the build finished if tests pass on other versions of Go.
fast_finish: true

go_import_path: firebase.google.com/go

before_install:
- go get github.com/golang/lint/golint
- go get github.com/golang/lint/golint # Golint requires Go 1.6 or later.

install:
# Prior to golang 1.8, this can trigger an error for packages containing only tests.
- go get -t -v $(go list ./... | grep -v integration)

script:
- golint -set_exit_status $(go list ./...)
- go test -v -test.short ./...

- go test -v -race -test.short ./... # Run tests with the race detector.
- go vet -v ./... # Run Go static analyzer.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

-

# v2.6.0

- [changed] Improved error handling in FCM by mapping more server-side
errors to client-side error codes.
- [added] Added the `db` package for interacting with the Firebase database.

# v2.5.0

- [changed] Import context from `golang.org/x/net` for 1.6 compatibility
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
[![Build Status](https://travis-ci.org/firebase/firebase-admin-go.svg?branch=master)](https://travis-ci.org/firebase/firebase-admin-go)
[![GoDoc](https://godoc.org/firebase.google.com/go?status.svg)](https://godoc.org/firebase.google.com/go)
[![Go Report Card](https://goreportcard.com/badge/github.com/firebase/firebase-admin-go)](https://goreportcard.com/report/github.com/firebase/firebase-admin-go)

# Firebase Admin Go SDK

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

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

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

import (
"context"
"crypto/rsa"
"crypto/x509"
"encoding/json"
Expand All @@ -25,7 +26,6 @@ import (
"strings"

"firebase.google.com/go/internal"
"golang.org/x/net/context"
"google.golang.org/api/identitytoolkit/v3"
"google.golang.org/api/transport"
)
Expand Down Expand Up @@ -78,7 +78,7 @@ type signer interface {
// NewClient creates a new instance of the Firebase Auth Client.
//
// This function can only be invoked from within the SDK. Client applications should access the
// the Auth service through firebase.App.
// Auth service through firebase.App.
func NewClient(ctx context.Context, c *internal.AuthConfig) (*Client, error) {
var (
err error
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 (
"golang.org/x/net/context"
"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 "golang.org/x/net/context"
import "context"

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

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

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

"google.golang.org/api/option"
Expand Down
14 changes: 14 additions & 0 deletions auth/jwt_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
// Copyright 2017 Google Inc. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package auth

import (
Expand Down
2 changes: 1 addition & 1 deletion auth/user_mgt.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
package auth

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

"golang.org/x/net/context"
"google.golang.org/api/identitytoolkit/v3"
"google.golang.org/api/iterator"
)
Expand Down
14 changes: 7 additions & 7 deletions auth/user_mgt_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package auth

import (
"bytes"
"context"
"encoding/json"
"fmt"
"io/ioutil"
Expand All @@ -28,7 +29,6 @@ import (

"firebase.google.com/go/internal"

"golang.org/x/net/context"
"golang.org/x/oauth2"
"google.golang.org/api/identitytoolkit/v3"
"google.golang.org/api/iterator"
Expand Down Expand Up @@ -167,9 +167,9 @@ func TestListUsers(t *testing.T) {
defer s.Close()

want := []*ExportedUserRecord{
&ExportedUserRecord{UserRecord: testUser, PasswordHash: "passwordhash1", PasswordSalt: "salt1"},
&ExportedUserRecord{UserRecord: testUser, PasswordHash: "passwordhash2", PasswordSalt: "salt2"},
&ExportedUserRecord{UserRecord: testUser, PasswordHash: "passwordhash3", PasswordSalt: "salt3"},
{UserRecord: testUser, PasswordHash: "passwordhash1", PasswordSalt: "salt1"},
{UserRecord: testUser, PasswordHash: "passwordhash2", PasswordSalt: "salt2"},
{UserRecord: testUser, PasswordHash: "passwordhash3", PasswordSalt: "salt3"},
}

testIterator := func(iter *UserIterator, token string, req map[string]interface{}) {
Expand Down Expand Up @@ -574,9 +574,9 @@ func TestInvalidSetCustomClaims(t *testing.T) {
func TestSetCustomClaims(t *testing.T) {
cases := []map[string]interface{}{
nil,
map[string]interface{}{},
map[string]interface{}{"admin": true},
map[string]interface{}{"admin": true, "package": "gold"},
{},
{"admin": true},
{"admin": true, "package": "gold"},
}

resp := `{
Expand Down
107 changes: 107 additions & 0 deletions db/auth_override_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
// Copyright 2018 Google Inc. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package db

import (
"testing"

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

func TestAuthOverrideGet(t *testing.T) {
mock := &mockServer{Resp: "data"}
srv := mock.Start(aoClient)
defer srv.Close()

ref := aoClient.NewRef("peter")
var got string
if err := ref.Get(context.Background(), &got); err != nil {
t.Fatal(err)
}
if got != "data" {
t.Errorf("Ref(AuthOverride).Get() = %q; want = %q", got, "data")
}
checkOnlyRequest(t, mock.Reqs, &testReq{
Method: "GET",
Path: "/peter.json",
Query: map[string]string{"auth_variable_override": testAuthOverrides},
})
}

func TestAuthOverrideSet(t *testing.T) {
mock := &mockServer{}
srv := mock.Start(aoClient)
defer srv.Close()

ref := aoClient.NewRef("peter")
want := map[string]interface{}{"name": "Peter Parker", "age": float64(17)}
if err := ref.Set(context.Background(), want); err != nil {
t.Fatal(err)
}
checkOnlyRequest(t, mock.Reqs, &testReq{
Method: "PUT",
Body: serialize(want),
Path: "/peter.json",
Query: map[string]string{"auth_variable_override": testAuthOverrides, "print": "silent"},
})
}

func TestAuthOverrideQuery(t *testing.T) {
mock := &mockServer{Resp: "data"}
srv := mock.Start(aoClient)
defer srv.Close()

ref := aoClient.NewRef("peter")
var got string
if err := ref.OrderByChild("foo").Get(context.Background(), &got); err != nil {
t.Fatal(err)
}
if got != "data" {
t.Errorf("Ref(AuthOverride).OrderByChild() = %q; want = %q", got, "data")
}
checkOnlyRequest(t, mock.Reqs, &testReq{
Method: "GET",
Path: "/peter.json",
Query: map[string]string{
"auth_variable_override": testAuthOverrides,
"orderBy": "\"foo\"",
},
})
}

func TestAuthOverrideRangeQuery(t *testing.T) {
mock := &mockServer{Resp: "data"}
srv := mock.Start(aoClient)
defer srv.Close()

ref := aoClient.NewRef("peter")
var got string
if err := ref.OrderByChild("foo").StartAt(1).EndAt(10).Get(context.Background(), &got); err != nil {
t.Fatal(err)
}
if got != "data" {
t.Errorf("Ref(AuthOverride).OrderByChild() = %q; want = %q", got, "data")
}
checkOnlyRequest(t, mock.Reqs, &testReq{
Method: "GET",
Path: "/peter.json",
Query: map[string]string{
"auth_variable_override": testAuthOverrides,
"orderBy": "\"foo\"",
"startAt": "1",
"endAt": "10",
},
})
}
Loading

0 comments on commit 357ed71

Please sign in to comment.