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

Unified Diff: server/auth/auth_test.go

Issue 2830443003: auth: Refactor how authentication methods are passed to server/auth library. (Closed)
Patch Set: 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: server/auth/auth_test.go
diff --git a/server/auth/auth_test.go b/server/auth/auth_test.go
index 1bdcd7de9d12dda5f01cad8b2f5a8fbf77f19876..70f71dc0703d83bf3c29792e2d4c0938cd99346e 100644
--- a/server/auth/auth_test.go
+++ b/server/auth/auth_test.go
@@ -28,7 +28,9 @@ func TestAuthenticate(t *testing.T) {
Convey("IsAllowedOAuthClientID on default DB", t, func() {
c := context.Background()
- auth := Authenticator{fakeOAuthMethod{clientID: "some_client_id"}}
+ auth := Authenticator{
+ Methods: []Method{fakeOAuthMethod{clientID: "some_client_id"}},
+ }
_, err := auth.Authenticate(c, makeRequest())
So(err, ShouldErrLike, "the library is not properly configured")
})
@@ -37,7 +39,9 @@ func TestAuthenticate(t *testing.T) {
c := injectTestDB(context.Background(), &fakeDB{
allowedClientID: "some_client_id",
})
- auth := Authenticator{fakeOAuthMethod{clientID: "some_client_id"}}
+ auth := Authenticator{
+ Methods: []Method{fakeOAuthMethod{clientID: "some_client_id"}},
+ }
_, err := auth.Authenticate(c, makeRequest())
So(err, ShouldBeNil)
})
@@ -46,7 +50,9 @@ func TestAuthenticate(t *testing.T) {
c := injectTestDB(context.Background(), &fakeDB{
allowedClientID: "some_client_id",
})
- auth := Authenticator{fakeOAuthMethod{clientID: "another_client_id"}}
+ auth := Authenticator{
+ Methods: []Method{fakeOAuthMethod{clientID: "another_client_id"}},
+ }
_, err := auth.Authenticate(c, makeRequest())
So(err, ShouldEqual, ErrBadClientID)
})
@@ -73,7 +79,9 @@ func TestAuthenticate(t *testing.T) {
c := injectTestDB(context.Background(), db)
Convey("User is using IP whitelist and IP is in the whitelist.", func() {
- auth := Authenticator{fakeOAuthMethod{email: "abc@example.com"}}
+ auth := Authenticator{
+ Methods: []Method{fakeOAuthMethod{email: "abc@example.com"}},
+ }
req := makeRequest()
req.RemoteAddr = "1.2.3.4"
c, err := auth.Authenticate(c, req)
@@ -82,7 +90,9 @@ func TestAuthenticate(t *testing.T) {
})
Convey("User is using IP whitelist and IP is NOT in the whitelist.", func() {
- auth := Authenticator{fakeOAuthMethod{email: "abc@example.com"}}
+ auth := Authenticator{
+ Methods: []Method{fakeOAuthMethod{email: "abc@example.com"}},
+ }
req := makeRequest()
req.RemoteAddr = "1.2.3.5"
_, err := auth.Authenticate(c, req)
@@ -90,7 +100,9 @@ func TestAuthenticate(t *testing.T) {
})
Convey("User is not using IP whitelist.", func() {
- auth := Authenticator{fakeOAuthMethod{email: "def@example.com"}}
+ auth := Authenticator{
+ Methods: []Method{fakeOAuthMethod{email: "def@example.com"}},
+ }
req := makeRequest()
req.RemoteAddr = "1.2.3.5"
c, err := auth.Authenticate(c, req)

Powered by Google App Engine
This is Rietveld 408576698