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

Unified Diff: milo/appengine/frontend/main_test.go

Issue 2830443003: auth: Refactor how authentication methods are passed to server/auth library. (Closed)
Patch Set: fix test Created 3 years, 8 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
Index: milo/appengine/frontend/main_test.go
diff --git a/milo/appengine/frontend/main_test.go b/milo/appengine/frontend/main_test.go
index 7a492893cfd7366c99d3eff03e20a51a02b68c6a..066f93fe5f09c4bee0cc489836bd5e890d4bb4b6 100644
--- a/milo/appengine/frontend/main_test.go
+++ b/milo/appengine/frontend/main_test.go
@@ -24,6 +24,7 @@ import (
"github.com/luci/luci-go/milo/appengine/common"
"github.com/luci/luci-go/milo/appengine/swarming"
"github.com/luci/luci-go/server/auth"
+ "github.com/luci/luci-go/server/auth/authtest"
"github.com/luci/luci-go/server/auth/identity"
"github.com/luci/luci-go/server/settings"
"github.com/luci/luci-go/server/templates"
@@ -73,27 +74,6 @@ func mustWrite(name string, buf []byte) {
}
}
-// fakeOAuthMethod implements Method.
-type fakeOAuthMethod struct {
- clientID string
-}
-
-func (m fakeOAuthMethod) Authenticate(context.Context, *http.Request) (*auth.User, error) {
- return &auth.User{
- Identity: identity.Identity("user:abc@example.com"),
- Email: "abc@example.com",
- ClientID: m.clientID,
- }, nil
-}
-
-func (m fakeOAuthMethod) LoginURL(c context.Context, target string) (string, error) {
- return "https://login.url/?target=" + target, nil
-}
-
-func (m fakeOAuthMethod) LogoutURL(c context.Context, target string) (string, error) {
- return "https://logout.url/?target=" + target, nil
-}
-
type analyticsSettings struct {
AnalyticsID string `json:"analytics_id"`
}
@@ -109,8 +89,7 @@ func TestPages(t *testing.T) {
c = memory.Use(c)
c = common.WithRequest(c, &http.Request{URL: &url.URL{Path: "/foobar"}})
c, _ = testclock.UseTime(c, testclock.TestTimeUTC)
- a := auth.Authenticator{fakeOAuthMethod{"some_client_id"}}
- c = auth.SetAuthenticator(c, a)
+ c = auth.WithState(c, &authtest.FakeState{Identity: identity.AnonymousIdentity})
c = settings.Use(c, settings.New(&settings.MemoryStorage{Expiration: time.Second}))
err := settings.Set(c, "analytics", &analyticsSettings{"UA-12345-01"}, "", "")
So(err, ShouldBeNil)
« no previous file with comments | « milo/appengine/frontend/expectations/swarming.log-Basic_log.html ('k') | scheduler/appengine/frontend/handler.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698