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

Unified Diff: common/auth/localauth/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_test.go ('k') | common/auth/localauth/rpcs/getoauthtoken.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: common/auth/localauth/ctx_test.go
diff --git a/common/auth/localauth/ctx_test.go b/common/auth/localauth/ctx_test.go
index 2b0b77a9f73db28dd86c1d3553ab1a136453ff65..139da9fda74a0405f1f6925b78f740263d69f5e3 100644
--- a/common/auth/localauth/ctx_test.go
+++ b/common/auth/localauth/ctx_test.go
@@ -24,13 +24,15 @@ func TestWithLocalAuth(t *testing.T) {
ctx := context.Background()
ctx, _ = testclock.UseTime(ctx, testclock.TestRecentTimeLocal)
+ gen := func(ctx context.Context, scopes []string, lifetime time.Duration) (*oauth2.Token, error) {
+ return &oauth2.Token{
+ AccessToken: "tok",
+ Expiry: clock.Now(ctx).Add(30 * time.Minute),
+ }, nil
+ }
+
srv := Server{
- TokenGenerator: func(ctx context.Context, scopes []string, lifetime time.Duration) (*oauth2.Token, error) {
- return &oauth2.Token{
- AccessToken: "tok",
- Expiry: clock.Now(ctx).Add(30 * time.Minute),
- }, nil
- },
+ TokenGenerators: map[string]TokenGenerator{"acc_id": gen},
}
Convey("Works", t, func() {
@@ -38,8 +40,9 @@ func TestWithLocalAuth(t *testing.T) {
p := lucictx.GetLocalAuth(ctx)
So(p, ShouldNotBeNil)
req := prepReq(p, "/rpc/LuciLocalAuthService.GetOAuthToken", map[string]interface{}{
- "scopes": []string{"B", "A"},
- "secret": p.Secret,
+ "scopes": []string{"B", "A"},
+ "secret": p.Secret,
+ "account_id": "acc_id",
})
So(call(req), ShouldEqual, `HTTP 200 (json): {"access_token":"tok","expiry":1454502906}`)
return nil
« no previous file with comments | « common/auth/internal/luci_ctx_test.go ('k') | common/auth/localauth/rpcs/getoauthtoken.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698