Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(140)

Unified Diff: appengine/gaeauth/server/internal/authdb/handlers_test.go

Issue 2043423004: Make HTTP middleware easier to use (Closed) Base URL: https://github.com/luci/luci-go@master
Patch Set: gaemiddleware: add middleware func for WithProd Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « appengine/gaeauth/server/internal/authdb/handlers.go ('k') | appengine/gaemiddleware/appengine.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « appengine/gaeauth/server/internal/authdb/handlers.go ('k') | appengine/gaemiddleware/appengine.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698