From 2c5f6145aa8d8d677b80461ea982bf49c81c8c36 Mon Sep 17 00:00:00 2001 From: Pavel Sorokin Date: Tue, 27 Jun 2017 23:26:38 +0800 Subject: [PATCH 1/2] Fix for google_test validation --- providers/google_test.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/providers/google_test.go b/providers/google_test.go index 3b700bac..dcd7e836 100644 --- a/providers/google_test.go +++ b/providers/google_test.go @@ -110,16 +110,16 @@ func TestGoogleProviderValidateGroup(t *testing.T) { p.GroupValidator = func(email string) bool { return email == "michael.bland@gsa.gov" } - assert.Equal(t, true, p.ValidateGroup(&SessionState{Email:"michael.bland@gsa.gov"})) + assert.Equal(t, true, p.ValidateGroup(&SessionState{Email: "michael.bland@gsa.gov"})) p.GroupValidator = func(email string) bool { return email != "michael.bland@gsa.gov" } - assert.Equal(t, false, p.ValidateGroup(&SessionState{Email:"michael.bland@gsa.gov"})) + assert.Equal(t, false, p.ValidateGroup(&SessionState{Email: "michael.bland@gsa.gov"})) } func TestGoogleProviderWithoutValidateGroup(t *testing.T) { p := newGoogleProvider() - assert.Equal(t, true, p.ValidateGroup(&SessionState{Email:"michael.bland@gsa.gov"})) + assert.Equal(t, true, p.ValidateGroup(&SessionState{Email: "michael.bland@gsa.gov"})) } // From d181279917117ae266b8bcff5ad087fff29f8456 Mon Sep 17 00:00:00 2001 From: Pavel Sorokin Date: Wed, 28 Jun 2017 11:34:25 +0800 Subject: [PATCH 2/2] Test fixes --- README.md | 2 -- oauthproxy_test.go | 6 ------ options.go | 1 + options_test.go | 4 +--- providers/providers.go | 5 +---- 5 files changed, 3 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index a11312f5..e9138d60 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,6 @@ oauth2_proxy ================= -(This project was renamed from Google Auth Proxy - May 2015) - A reverse proxy and static file server that provides authentication using Providers (Google, GitHub, and others) to validate accounts by email, domain or group. diff --git a/oauthproxy_test.go b/oauthproxy_test.go index ccb820f2..a0bcc5c1 100644 --- a/oauthproxy_test.go +++ b/oauthproxy_test.go @@ -78,7 +78,6 @@ func TestEncodedSlashes(t *testing.T) { func TestRobotsTxt(t *testing.T) { opts := NewOptions() - opts.Provider = "google" opts.ClientID = "bazquux" opts.ClientSecret = "foobar" opts.CookieSecret = "xyzzyplugh" @@ -152,7 +151,6 @@ func TestBasicAuthPassword(t *testing.T) { opts.Upstreams = append(opts.Upstreams, provider_server.URL) // The CookieSecret must be 32 bytes in order to create the AES // cipher. - opts.Provider = "google" opts.CookieSecret = "xyzzyplughxyzzyplughxyzzyplughxp" opts.ClientID = "bazquux" opts.ClientSecret = "foobar" @@ -247,7 +245,6 @@ func NewPassAccessTokenTest(opts PassAccessTokenTestOptions) *PassAccessTokenTes t.opts.Upstreams = append(t.opts.Upstreams, t.provider_server.URL) // The CookieSecret must be 32 bytes in order to create the AES // cipher. - t.opts.Provider = "google" t.opts.CookieSecret = "xyzzyplughxyzzyplughxyzzyplughxp" t.opts.ClientID = "bazquux" t.opts.ClientSecret = "foobar" @@ -373,7 +370,6 @@ func NewSignInPageTest() *SignInPageTest { var sip_test SignInPageTest sip_test.opts = NewOptions() - sip_test.opts.Provider = "google" sip_test.opts.CookieSecret = "foobar" sip_test.opts.ClientID = "bazquux" sip_test.opts.ClientSecret = "xyzzyplugh" @@ -445,7 +441,6 @@ func NewProcessCookieTest(opts ProcessCookieTestOpts) *ProcessCookieTest { var pc_test ProcessCookieTest pc_test.opts = NewOptions() - pc_test.opts.Provider = "google" pc_test.opts.ClientID = "bazquux" pc_test.opts.ClientSecret = "xyzzyplugh" pc_test.opts.CookieSecret = "0123456789abcdefabcd" @@ -704,7 +699,6 @@ type SignatureTest struct { func NewSignatureTest() *SignatureTest { opts := NewOptions() - opts.Provider = "google" opts.CookieSecret = "cookie secret" opts.ClientID = "client ID" opts.ClientSecret = "client secret" diff --git a/options.go b/options.go index 951fa84f..70fbec5a 100644 --- a/options.go +++ b/options.go @@ -111,6 +111,7 @@ func NewOptions() *Options { PassHostHeader: true, ApprovalPrompt: "", RequestLogging: true, + Provider: "google", } } diff --git a/options_test.go b/options_test.go index f3cf1a95..3d97beb7 100644 --- a/options_test.go +++ b/options_test.go @@ -14,7 +14,6 @@ import ( func testOptions() *Options { o := NewOptions() o.Upstreams = append(o.Upstreams, "http://127.0.0.1:8080/") - o.Provider = "google" o.CookieSecret = "foobar" o.ClientID = "bazquux" o.ClientSecret = "xyzzyplugh" @@ -39,8 +38,7 @@ func TestNewOptions(t *testing.T) { "missing setting: upstream", "missing setting: cookie-secret", "missing setting: client-id", - "missing setting: client-secret", - "missing setting: provider"}) + "missing setting: client-secret"}) assert.Equal(t, expected, err.Error()) } diff --git a/providers/providers.go b/providers/providers.go index aec0a219..449a5485 100644 --- a/providers/providers.go +++ b/providers/providers.go @@ -1,7 +1,6 @@ package providers import ( - "errors" "github.com/bitly/oauth2_proxy/cookie" ) @@ -32,9 +31,7 @@ func New(provider string, p *ProviderData) (Provider, error) { return NewAzureProvider(p), nil case "gitlab": return NewGitLabProvider(p), nil - case "google": - return NewGoogleProvider(p), nil default: - return nil, errors.New("missing setting: provider") + return NewGoogleProvider(p), nil } }