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/gitlab/gitlab_test.go | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'server/auth/gitlab/gitlab_test.go') diff --git a/server/auth/gitlab/gitlab_test.go b/server/auth/gitlab/gitlab_test.go index 39c2701..676cda2 100644 --- a/server/auth/gitlab/gitlab_test.go +++ b/server/auth/gitlab/gitlab_test.go @@ -2,6 +2,7 @@ package gitlab import ( "fmt" + "net/http" "testing" "github.com/nsheridan/cashier/server/auth" @@ -25,7 +26,6 @@ func TestNew(t *testing.T) { g := p.(*Config) a.Equal(g.config.ClientID, oauthClientID) a.Equal(g.config.ClientSecret, oauthClientSecret) - a.Equal(g.config.RedirectURL, oauthCallbackURL) } func TestNewBrokenSiteURL(t *testing.T) { @@ -55,7 +55,10 @@ func TestGoodAllUsers(t *testing.T) { a := assert.New(t) p, _ := newGitlab() - s := p.StartSession("test_state") + r := &http.Request{ + Host: oauthCallbackURL, + } + s := p.StartSession("test_state", r) a.Contains(s.AuthURL, "exampleorg/oauth/authorize") a.Contains(s.AuthURL, "state=test_state") a.Contains(s.AuthURL, fmt.Sprintf("client_id=%s", oauthClientID)) @@ -77,7 +80,10 @@ func TestStartSession(t *testing.T) { a := assert.New(t) p, _ := newGitlab() - s := p.StartSession("test_state") + r := &http.Request{ + Host: oauthCallbackURL, + } + s := p.StartSession("test_state", r) a.Contains(s.AuthURL, "exampleorg/oauth/authorize") a.Contains(s.AuthURL, "state=test_state") a.Contains(s.AuthURL, fmt.Sprintf("client_id=%s", oauthClientID)) @@ -87,7 +93,6 @@ func newGitlab() (auth.Provider, error) { c := &config.Auth{ OauthClientID: oauthClientID, OauthClientSecret: oauthClientSecret, - OauthCallbackURL: oauthCallbackURL, ProviderOpts: map[string]string{ "group": group, "siteurl": siteurl, -- cgit v1.2.3