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

Side by Side Diff: server/auth/handlers_test.go

Issue 2646543003: server/auth: Add TokenSource call. (Closed)
Patch Set: Created 3 years, 11 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 unified diff | Download patch
« no previous file with comments | « server/auth/delegation_test.go ('k') | server/auth/state_test.go » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The LUCI Authors. All rights reserved. 1 // Copyright 2016 The LUCI Authors. All rights reserved.
2 // Use of this source code is governed under the Apache License, Version 2.0 2 // Use of this source code is governed under the Apache License, Version 2.0
3 // that can be found in the LICENSE file. 3 // that can be found in the LICENSE file.
4 4
5 package auth 5 package auth
6 6
7 import ( 7 import (
8 "errors" 8 "errors"
9 "net/http" 9 "net/http"
10 "net/http/httptest" 10 "net/http/httptest"
11 "testing" 11 "testing"
12 12
13 "golang.org/x/net/context" 13 "golang.org/x/net/context"
14 14
15 "github.com/luci/luci-go/server/auth/signing" 15 "github.com/luci/luci-go/server/auth/signing"
16 "github.com/luci/luci-go/server/router" 16 "github.com/luci/luci-go/server/router"
17 17
18 . "github.com/luci/luci-go/common/testing/assertions" 18 . "github.com/luci/luci-go/common/testing/assertions"
19 . "github.com/smartystreets/goconvey/convey" 19 . "github.com/smartystreets/goconvey/convey"
20 ) 20 )
21 21
22 func TestCertificatesHandler(t *testing.T) { 22 func TestCertificatesHandler(t *testing.T) {
23 t.Parallel()
24
23 call := func(s signing.Signer) (*signing.PublicCertificates, error) { 25 call := func(s signing.Signer) (*signing.PublicCertificates, error) {
24 r := router.New() 26 r := router.New()
25 InstallHandlers(r, router.NewMiddlewareChain( 27 InstallHandlers(r, router.NewMiddlewareChain(
26 func(c *router.Context, next router.Handler) { 28 func(c *router.Context, next router.Handler) {
27 c.Context = SetConfig(context.Background(), Conf ig{Signer: s}) 29 c.Context = SetConfig(context.Background(), Conf ig{Signer: s})
28 next(c) 30 next(c)
29 }, 31 },
30 )) 32 ))
31 ts := httptest.NewServer(r) 33 ts := httptest.NewServer(r)
32 ctx := SetConfig(context.Background(), Config{ 34 ctx := SetConfig(context.Background(), Config{
(...skipping 15 matching lines...) Expand all
48 So(err, ShouldErrLike, "HTTP code (404)") 50 So(err, ShouldErrLike, "HTTP code (404)")
49 }) 51 })
50 52
51 Convey("Error getting certs", t, func() { 53 Convey("Error getting certs", t, func() {
52 _, err := call(&phonySigner{errors.New("fail")}) 54 _, err := call(&phonySigner{errors.New("fail")})
53 So(err, ShouldErrLike, "HTTP code (500)") 55 So(err, ShouldErrLike, "HTTP code (500)")
54 }) 56 })
55 } 57 }
56 58
57 func TestServiceInfoHandler(t *testing.T) { 59 func TestServiceInfoHandler(t *testing.T) {
60 t.Parallel()
61
58 Convey("Works", t, func() { 62 Convey("Works", t, func() {
59 r := router.New() 63 r := router.New()
60 signer := &phonySigner{} 64 signer := &phonySigner{}
61 65
62 InstallHandlers(r, router.NewMiddlewareChain( 66 InstallHandlers(r, router.NewMiddlewareChain(
63 func(ctx *router.Context, next router.Handler) { 67 func(ctx *router.Context, next router.Handler) {
64 ctx.Context = SetConfig(context.Background(), Co nfig{Signer: signer}) 68 ctx.Context = SetConfig(context.Background(), Co nfig{Signer: signer})
65 next(ctx) 69 next(ctx)
66 }, 70 },
67 )) 71 ))
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 return nil, s.err 122 return nil, s.err
119 } 123 }
120 return &signing.ServiceInfo{ 124 return &signing.ServiceInfo{
121 AppID: "phony-app", 125 AppID: "phony-app",
122 AppRuntime: "go", 126 AppRuntime: "go",
123 AppRuntimeVersion: "go1.5.1", 127 AppRuntimeVersion: "go1.5.1",
124 AppVersion: "1234-abcdef", 128 AppVersion: "1234-abcdef",
125 ServiceAccountName: "phony-app-account@example.com", 129 ServiceAccountName: "phony-app-account@example.com",
126 }, nil 130 }, nil
127 } 131 }
OLDNEW
« no previous file with comments | « server/auth/delegation_test.go ('k') | server/auth/state_test.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698