| Index: appengine/gaeauth/server/internal/authdb/handlers_test.go
|
| diff --git a/appengine/gaeauth/server/internal/authdb/handlers_test.go b/appengine/gaeauth/server/internal/authdb/handlers_test.go
|
| index 9584d0c42fa361aa60f019b65a7190a9fcfcfb1b..e2893afb6cadb9a082d41740afcfa67ffd3f5414 100644
|
| --- a/appengine/gaeauth/server/internal/authdb/handlers_test.go
|
| +++ b/appengine/gaeauth/server/internal/authdb/handlers_test.go
|
| @@ -7,56 +7,73 @@ package authdb
|
| import (
|
| "bytes"
|
| "net/http"
|
| "net/http/httptest"
|
| "testing"
|
|
|
| "golang.org/x/net/context"
|
|
|
| "github.com/luci/luci-go/appengine/gaetesting"
|
| "github.com/luci/luci-go/server/auth/service"
|
| + "github.com/luci/luci-go/server/router"
|
|
|
| . "github.com/smartystreets/goconvey/convey"
|
| )
|
|
|
| func TestPubSubHandlers(t *testing.T) {
|
| Convey("pubSubPush skips when not configured", t, func() {
|
| c := gaetesting.TestingContext()
|
| rec := httptest.NewRecorder()
|
| - pubSubPush(c, rec, makePostRequest(), nil)
|
| + pubSubPush(&router.Context{
|
| + Context: c,
|
| + Writer: rec,
|
| + Request: makePostRequest(),
|
| + })
|
| So(rec.Code, ShouldEqual, 200)
|
| So(rec.Body.String(), ShouldEqual, "Auth Service URL is not configured, skipping the message")
|
| })
|
|
|
| Convey("pubSubPush works when no notification", t, func() {
|
| c, _ := setupCtx()
|
| rec := httptest.NewRecorder()
|
| - pubSubPush(c, rec, makePostRequest(), nil)
|
| + pubSubPush(&router.Context{
|
| + Context: c,
|
| + Writer: rec,
|
| + Request: makePostRequest(),
|
| + })
|
| So(rec.Code, ShouldEqual, 200)
|
| So(rec.Body.String(), ShouldEqual, "No new valid AuthDB change notifications")
|
| })
|
|
|
| Convey("pubSubPush old notification", t, func() {
|
| c, srv := setupCtx()
|
| srv.Notification = &service.Notification{Revision: 122} // older than 123
|
| rec := httptest.NewRecorder()
|
| - pubSubPush(c, rec, makePostRequest(), nil)
|
| + pubSubPush(&router.Context{
|
| + Context: c,
|
| + Writer: rec,
|
| + Request: makePostRequest(),
|
| + })
|
| So(rec.Code, ShouldEqual, 200)
|
| So(rec.Body.String(), ShouldEqual, "Processed PubSub notification for rev 122: 123 -> 123")
|
| })
|
|
|
| Convey("pubSubPush fresh notification", t, func() {
|
| c, srv := setupCtx()
|
| srv.LatestRev = 130
|
| srv.Notification = &service.Notification{Revision: 124}
|
| rec := httptest.NewRecorder()
|
| - pubSubPush(c, rec, makePostRequest(), nil)
|
| + pubSubPush(&router.Context{
|
| + Context: c,
|
| + Writer: rec,
|
| + Request: makePostRequest(),
|
| + })
|
| So(rec.Code, ShouldEqual, 200)
|
| So(rec.Body.String(), ShouldEqual, "Processed PubSub notification for rev 124: 123 -> 130")
|
| })
|
| }
|
|
|
| func setupCtx() (context.Context, *fakeAuthService) {
|
| srv := &fakeAuthService{LatestRev: 123}
|
| c := setAuthService(gaetesting.TestingContext(), srv)
|
| So(ConfigureAuthService(c, "http://base_url", "http://auth-service"), ShouldBeNil)
|
| return c, srv
|
|
|