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

Side by Side Diff: server/auth/delegation_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/context_test.go ('k') | server/auth/handlers_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 "fmt" 8 "fmt"
9 "math/rand" 9 "math/rand"
10 "net/http" 10 "net/http"
11 "testing" 11 "testing"
12 "time" 12 "time"
13 13
14 "golang.org/x/net/context" 14 "golang.org/x/net/context"
15 15
16 "github.com/luci/luci-go/common/clock" 16 "github.com/luci/luci-go/common/clock"
17 "github.com/luci/luci-go/common/clock/testclock" 17 "github.com/luci/luci-go/common/clock/testclock"
18 "github.com/luci/luci-go/common/data/rand/mathrand" 18 "github.com/luci/luci-go/common/data/rand/mathrand"
19 "github.com/luci/luci-go/server/auth/delegation" 19 "github.com/luci/luci-go/server/auth/delegation"
20 "github.com/luci/luci-go/server/auth/signing" 20 "github.com/luci/luci-go/server/auth/signing"
21 "github.com/luci/luci-go/server/auth/signing/signingtest" 21 "github.com/luci/luci-go/server/auth/signing/signingtest"
22 . "github.com/smartystreets/goconvey/convey" 22 . "github.com/smartystreets/goconvey/convey"
23 ) 23 )
24 24
25 func TestMintDelegationToken(t *testing.T) { 25 func TestMintDelegationToken(t *testing.T) {
26 t.Parallel()
27
26 Convey("MintDelegationToken works", t, func() { 28 Convey("MintDelegationToken works", t, func() {
27 ctx := context.Background() 29 ctx := context.Background()
28 ctx, _ = testclock.UseTime(ctx, testclock.TestRecentTimeUTC) 30 ctx, _ = testclock.UseTime(ctx, testclock.TestRecentTimeUTC)
29 ctx = mathrand.Set(ctx, rand.New(rand.NewSource(12345))) 31 ctx = mathrand.Set(ctx, rand.New(rand.NewSource(12345)))
30 32
31 tokenCache := &mockedCache{} 33 tokenCache := &mockedCache{}
32 34
33 subtokenID := "123" 35 subtokenID := "123"
34 mintingReq := "" 36 mintingReq := ""
35 transport := &clientRPCTransportMock{ 37 transport := &clientRPCTransportMock{
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 `"impersonate":"user:abc@example.com","i ntent":"intent"}`) 127 `"impersonate":"user:abc@example.com","i ntent":"intent"}`)
126 128
127 // Cached now. 129 // Cached now.
128 So(len(tokenCache.data), ShouldEqual, 1) 130 So(len(tokenCache.data), ShouldEqual, 1)
129 for k := range tokenCache.data { 131 for k := range tokenCache.data {
130 So(k, ShouldEqual, "delegation/2/tjYIGNrwFvKa0FT 5juu7ThjpxBo") 132 So(k, ShouldEqual, "delegation/2/tjYIGNrwFvKa0FT 5juu7ThjpxBo")
131 } 133 }
132 }) 134 })
133 }) 135 })
134 } 136 }
OLDNEW
« no previous file with comments | « server/auth/context_test.go ('k') | server/auth/handlers_test.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698