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

Unified Diff: common/auth/internal/luci_ctx_test.go

Issue 2951553002: Extend LUCI_CONTEXT["local_auth"] protocol to understand accounts. (Closed)
Patch Set: few more tests Created 3 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 | « common/auth/internal/luci_ctx.go ('k') | common/auth/localauth/ctx_test.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: common/auth/internal/luci_ctx_test.go
diff --git a/common/auth/internal/luci_ctx_test.go b/common/auth/internal/luci_ctx_test.go
index 050c66aefd78cee61af21a38683d270d57d7ee0b..0ad5c7df33ad69c358ee8e2657b8688f95713c35 100644
--- a/common/auth/internal/luci_ctx_test.go
+++ b/common/auth/internal/luci_ctx_test.go
@@ -31,6 +31,15 @@ func TestLUCIContextProvider(t *testing.T) {
So(err, ShouldErrLike, `no "local_auth" in LUCI_CONTEXT`)
})
+ Convey("Requires default_account_id", t, func() {
+ ctx := context.Background()
+ ctx = lucictx.SetLocalAuth(ctx, &lucictx.LocalAuth{
+ Accounts: []lucictx.LocalAuthAccount{{ID: "zzz"}},
+ })
+ _, err := NewLUCIContextTokenProvider(ctx, []string{"A"}, http.DefaultTransport)
+ So(err, ShouldErrLike, `no "default_account_id"`)
+ })
+
Convey("With mock server", t, func(c C) {
requests := make(chan rpcs.GetOAuthTokenRequest, 10000)
responses := make(chan interface{}, 1)
@@ -65,8 +74,9 @@ func TestLUCIContextProvider(t *testing.T) {
ctx := context.Background()
ctx = lucictx.SetLocalAuth(ctx, &lucictx.LocalAuth{
- RPCPort: uint32(ts.Listener.Addr().(*net.TCPAddr).Port),
- Secret: []byte("zekret"),
+ RPCPort: uint32(ts.Listener.Addr().(*net.TCPAddr).Port),
+ Secret: []byte("zekret"),
+ DefaultAccountID: "acc_id",
})
p, err := NewLUCIContextTokenProvider(ctx, []string{"B", "A"}, http.DefaultTransport)
@@ -87,8 +97,9 @@ func TestLUCIContextProvider(t *testing.T) {
})
So(<-requests, ShouldResemble, rpcs.GetOAuthTokenRequest{
- Scopes: []string{"B", "A"},
- Secret: []byte("zekret"),
+ Scopes: []string{"B", "A"},
+ Secret: []byte("zekret"),
+ AccountID: "acc_id",
})
})
« no previous file with comments | « common/auth/internal/luci_ctx.go ('k') | common/auth/localauth/ctx_test.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698