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

Side by Side Diff: lucictx/types_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 unified diff | Download patch
« no previous file with comments | « lucictx/local_auth.go ('k') | no next file » | 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 lucictx 5 package lucictx
6 6
7 import ( 7 import (
8 "encoding/json" 8 "encoding/json"
9 "testing" 9 "testing"
10 10
11 "golang.org/x/net/context" 11 "golang.org/x/net/context"
12 12
13 . "github.com/smartystreets/goconvey/convey" 13 . "github.com/smartystreets/goconvey/convey"
14 ) 14 )
15 15
16 func TestPredefinedTypes(t *testing.T) { 16 func TestPredefinedTypes(t *testing.T) {
17 t.Parallel() 17 t.Parallel()
18 18
19 Convey("Test predefined types", t, func() { 19 Convey("Test predefined types", t, func() {
20 c := context.Background() 20 c := context.Background()
21 Convey("local_auth", func() { 21 Convey("local_auth", func() {
22 So(GetLocalAuth(c), ShouldBeNil) 22 So(GetLocalAuth(c), ShouldBeNil)
23 23
24 » » » c = SetLocalAuth(c, &LocalAuth{100, []byte("foo")}) 24 » » » localAuth := LocalAuth{
25 » » » » RPCPort: 100,
26 » » » » Secret: []byte("foo"),
27 » » » » Accounts: []LocalAuthAccount{
28 » » » » » {"test"},
29 » » » » },
30 » » » » DefaultAccountID: "test",
31 » » » }
32
33 » » » c = SetLocalAuth(c, &localAuth)
25 rawJSON := json.RawMessage{} 34 rawJSON := json.RawMessage{}
26 Get(c, "local_auth", &rawJSON) 35 Get(c, "local_auth", &rawJSON)
27 » » » So(string(rawJSON), ShouldEqual, `{"rpc_port":100,"secre t":"Zm9v"}`) 36 » » » So(string(rawJSON), ShouldEqual, `{"rpc_port":100,"secre t":"Zm9v",`+
37 » » » » `"accounts":[{"id":"test"}],"default_account_id" :"test"}`)
28 38
29 » » » So(GetLocalAuth(c), ShouldResemble, &LocalAuth{100, []by te("foo")}) 39 » » » So(GetLocalAuth(c), ShouldResemble, &localAuth)
30 }) 40 })
31 41
32 Convey("swarming", func() { 42 Convey("swarming", func() {
33 So(GetSwarming(c), ShouldBeNil) 43 So(GetSwarming(c), ShouldBeNil)
34 44
35 c = SetSwarming(c, &Swarming{[]byte("foo")}) 45 c = SetSwarming(c, &Swarming{[]byte("foo")})
36 rawJSON := json.RawMessage{} 46 rawJSON := json.RawMessage{}
37 Get(c, "swarming", &rawJSON) 47 Get(c, "swarming", &rawJSON)
38 So(string(rawJSON), ShouldEqual, `{"secret_bytes":"Zm9v" }`) 48 So(string(rawJSON), ShouldEqual, `{"secret_bytes":"Zm9v" }`)
39 49
40 So(GetSwarming(c), ShouldResemble, &Swarming{[]byte("foo ")}) 50 So(GetSwarming(c), ShouldResemble, &Swarming{[]byte("foo ")})
41 }) 51 })
42 }) 52 })
43 } 53 }
OLDNEW
« no previous file with comments | « lucictx/local_auth.go ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698