From 44cb8512c9881687e091cca589a0adcb9f72fa7a Mon Sep 17 00:00:00 2001 From: Niall Sheridan Date: Sat, 4 Feb 2017 23:55:31 +0000 Subject: Remove the oauth_callback_url config option Infer the redirect url from the request instead --- server/auth/google/google_test.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'server/auth/google/google_test.go') diff --git a/server/auth/google/google_test.go b/server/auth/google/google_test.go index b3d2633..4d6191b 100644 --- a/server/auth/google/google_test.go +++ b/server/auth/google/google_test.go @@ -2,6 +2,7 @@ package google import ( "fmt" + "net/http" "testing" "github.com/nsheridan/cashier/server/config" @@ -22,7 +23,6 @@ func TestNew(t *testing.T) { a.NoError(err) a.Equal(p.config.ClientID, oauthClientID) a.Equal(p.config.ClientSecret, oauthClientSecret) - a.Equal(p.config.RedirectURL, oauthCallbackURL) a.Equal(p.domain, domain) a.Equal(p.whitelist, map[string]bool{"user": true}) } @@ -31,7 +31,6 @@ func TestWhitelist(t *testing.T) { c := &config.Auth{ OauthClientID: oauthClientID, OauthClientSecret: oauthClientSecret, - OauthCallbackURL: oauthCallbackURL, ProviderOpts: map[string]string{"domain": ""}, UsersWhitelist: []string{}, } @@ -56,7 +55,10 @@ func TestStartSession(t *testing.T) { p, err := newGoogle() a.NoError(err) - s := p.StartSession("test_state") + r := &http.Request{ + Host: oauthCallbackURL, + } + s := p.StartSession("test_state", r) a.Contains(s.AuthURL, "accounts.google.com/o/oauth2/auth") a.Contains(s.AuthURL, "state=test_state") a.Contains(s.AuthURL, fmt.Sprintf("hd=%s", domain)) @@ -67,7 +69,6 @@ func newGoogle() (*Config, error) { c := &config.Auth{ OauthClientID: oauthClientID, OauthClientSecret: oauthClientSecret, - OauthCallbackURL: oauthCallbackURL, ProviderOpts: map[string]string{"domain": domain}, UsersWhitelist: users, } -- cgit v1.2.3