| Index: server/auth/signing/context_test.go
|
| diff --git a/server/auth/signing/context_test.go b/server/auth/signing/context_test.go
|
| index 4a49d16f4d3a738df2cefd762c018b04bb6f72b6..667520014d04995fc54ac572ce8437f76238af1d 100644
|
| --- a/server/auth/signing/context_test.go
|
| +++ b/server/auth/signing/context_test.go
|
| @@ -1,54 +1,51 @@
|
| // Copyright 2015 The LUCI Authors. All rights reserved.
|
| // Use of this source code is governed under the Apache License, Version 2.0
|
| // that can be found in the LICENSE file.
|
|
|
| package signing
|
|
|
| import (
|
| "errors"
|
| - "net/http"
|
| "net/http/httptest"
|
| "testing"
|
|
|
| - "github.com/julienschmidt/httprouter"
|
| "golang.org/x/net/context"
|
|
|
| - "github.com/luci/luci-go/server/middleware"
|
| + "github.com/luci/luci-go/server/router"
|
|
|
| . "github.com/luci/luci-go/common/testing/assertions"
|
| . "github.com/smartystreets/goconvey/convey"
|
| )
|
|
|
| func TestContext(t *testing.T) {
|
| Convey("Works", t, func() {
|
| ctx := context.Background()
|
|
|
| So(GetSigner(ctx), ShouldBeNil)
|
| _, _, err := SignBytes(ctx, nil)
|
| So(err, ShouldErrLike, "no Signer in the context")
|
|
|
| ctx = SetSigner(ctx, phonySigner{})
|
| _, _, err = SignBytes(ctx, nil)
|
| So(err, ShouldBeNil)
|
| })
|
| }
|
|
|
| func TestHandlers(t *testing.T) {
|
| -
|
| call := func(s Signer) (*PublicCertificates, error) {
|
| - r := httprouter.New()
|
| - InstallHandlers(r, func(h middleware.Handler) httprouter.Handle {
|
| - return func(w http.ResponseWriter, r *http.Request, p httprouter.Params) {
|
| - ctx := SetSigner(context.Background(), s)
|
| - h(ctx, w, r, p)
|
| - }
|
| + r := router.New()
|
| + InstallHandlers(r, router.MiddlewareChain{
|
| + func(c *router.Context, next router.Handler) {
|
| + c.Context = SetSigner(context.Background(), s)
|
| + next(c)
|
| + },
|
| })
|
| ts := httptest.NewServer(r)
|
| return FetchCertificates(context.Background(), ts.URL+"/auth/api/v1/server/certificates")
|
| }
|
|
|
| Convey("Works", t, func() {
|
| certs, err := call(phonySigner{})
|
| So(err, ShouldBeNil)
|
| So(len(certs.Certificates), ShouldEqual, 1)
|
| })
|
|
|