OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 package memory | 5 package memory |
6 | 6 |
7 import ( | 7 import ( |
8 "testing" | 8 "testing" |
9 | 9 |
10 userS "github.com/luci/gae/service/user" | 10 userS "github.com/luci/gae/service/user" |
(...skipping 14 matching lines...) Expand all Loading... |
25 | 25 |
26 usr, err := user.CurrentOAuth("something") | 26 usr, err := user.CurrentOAuth("something") |
27 So(err, ShouldBeNil) | 27 So(err, ShouldBeNil) |
28 So(usr, ShouldBeNil) | 28 So(usr, ShouldBeNil) |
29 | 29 |
30 So(user.IsAdmin(), ShouldBeFalse) | 30 So(user.IsAdmin(), ShouldBeFalse) |
31 }) | 31 }) |
32 | 32 |
33 Convey("can login (normal)", func() { | 33 Convey("can login (normal)", func() { |
34 user.Testable().Login("hello@world.com", "", false) | 34 user.Testable().Login("hello@world.com", "", false) |
35 » » » So(user.Current(), ShouldResembleV, &userS.User{ | 35 » » » So(user.Current(), ShouldResemble, &userS.User{ |
36 Email: "hello@world.com", | 36 Email: "hello@world.com", |
37 AuthDomain: "world.com", | 37 AuthDomain: "world.com", |
38 ID: "14628837901535854097", | 38 ID: "14628837901535854097", |
39 }) | 39 }) |
40 | 40 |
41 usr, err := user.CurrentOAuth("scope") | 41 usr, err := user.CurrentOAuth("scope") |
42 So(usr, ShouldBeNil) | 42 So(usr, ShouldBeNil) |
43 So(err, ShouldBeNil) | 43 So(err, ShouldBeNil) |
44 | 44 |
45 Convey("and logout", func() { | 45 Convey("and logout", func() { |
46 user.Testable().Logout() | 46 user.Testable().Logout() |
47 So(user.Current(), ShouldBeNil) | 47 So(user.Current(), ShouldBeNil) |
48 | 48 |
49 usr, err := user.CurrentOAuth("scope") | 49 usr, err := user.CurrentOAuth("scope") |
50 So(usr, ShouldBeNil) | 50 So(usr, ShouldBeNil) |
51 So(err, ShouldBeNil) | 51 So(err, ShouldBeNil) |
52 }) | 52 }) |
53 }) | 53 }) |
54 | 54 |
55 Convey("can be admin", func() { | 55 Convey("can be admin", func() { |
56 user.Testable().Login("hello@world.com", "", true) | 56 user.Testable().Login("hello@world.com", "", true) |
57 » » » So(user.Current(), ShouldResembleV, &userS.User{ | 57 » » » So(user.Current(), ShouldResemble, &userS.User{ |
58 Email: "hello@world.com", | 58 Email: "hello@world.com", |
59 AuthDomain: "world.com", | 59 AuthDomain: "world.com", |
60 ID: "14628837901535854097", | 60 ID: "14628837901535854097", |
61 Admin: true, | 61 Admin: true, |
62 }) | 62 }) |
63 So(user.IsAdmin(), ShouldBeTrue) | 63 So(user.IsAdmin(), ShouldBeTrue) |
64 }) | 64 }) |
65 | 65 |
66 Convey("can login (oauth)", func() { | 66 Convey("can login (oauth)", func() { |
67 user.Testable().Login("hello@world.com", "clientID", fal
se) | 67 user.Testable().Login("hello@world.com", "clientID", fal
se) |
68 usr, err := user.CurrentOAuth("scope") | 68 usr, err := user.CurrentOAuth("scope") |
69 So(err, ShouldBeNil) | 69 So(err, ShouldBeNil) |
70 » » » So(usr, ShouldResembleV, &userS.User{ | 70 » » » So(usr, ShouldResemble, &userS.User{ |
71 Email: "hello@world.com", | 71 Email: "hello@world.com", |
72 AuthDomain: "world.com", | 72 AuthDomain: "world.com", |
73 ID: "14628837901535854097", | 73 ID: "14628837901535854097", |
74 ClientID: "clientID", | 74 ClientID: "clientID", |
75 }) | 75 }) |
76 | 76 |
77 So(user.Current(), ShouldBeNil) | 77 So(user.Current(), ShouldBeNil) |
78 | 78 |
79 Convey("and logout", func() { | 79 Convey("and logout", func() { |
80 user.Testable().Logout() | 80 user.Testable().Logout() |
(...skipping 26 matching lines...) Expand all Loading... |
107 So(err, ShouldErrLike, "LoginURLFederated is deprecated"
) | 107 So(err, ShouldErrLike, "LoginURLFederated is deprecated"
) |
108 So(url, ShouldEqual, "") | 108 So(url, ShouldEqual, "") |
109 | 109 |
110 key, err := user.OAuthConsumerKey() | 110 key, err := user.OAuthConsumerKey() |
111 So(err, ShouldErrLike, "OAuthConsumerKey is deprecated") | 111 So(err, ShouldErrLike, "OAuthConsumerKey is deprecated") |
112 So(key, ShouldEqual, "") | 112 So(key, ShouldEqual, "") |
113 }) | 113 }) |
114 | 114 |
115 }) | 115 }) |
116 } | 116 } |
OLD | NEW |