-
Notifications
You must be signed in to change notification settings - Fork 248
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* 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
1 parent
47a0557
commit 357ed71
Showing
43 changed files
with
4,732 additions
and
96 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,7 +17,7 @@ | |
package auth | ||
|
||
import ( | ||
"golang.org/x/net/context" | ||
"context" | ||
|
||
"google.golang.org/appengine" | ||
) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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", | ||
}, | ||
}) | ||
} |
Oops, something went wrong.