From 2de4e9fc73da09dba767ebced5284416a5bd3a23 Mon Sep 17 00:00:00 2001 From: Markus Schulte Date: Tue, 20 Jun 2017 16:23:02 +0200 Subject: [PATCH] go fmt --- caddy/setup_test.go | 20 ++++++++++---------- logging/logger.go | 1 - logging/logger_test.go | 6 +++--- login/config_test.go | 4 ++-- login/handler_test.go | 12 ++++++------ 5 files changed, 21 insertions(+), 22 deletions(-) diff --git a/caddy/setup_test.go b/caddy/setup_test.go index 080d4fc..634501d 100644 --- a/caddy/setup_test.go +++ b/caddy/setup_test.go @@ -38,8 +38,8 @@ func TestSetup(t *testing.T) { "bob": "secret", }, }, - Oauth: login.Options{}, - GracePeriod: 5*time.Second, + Oauth: login.Options{}, + GracePeriod: 5 * time.Second, }}, { input: `login { @@ -73,8 +73,8 @@ func TestSetup(t *testing.T) { "client_secret": "secret", }, }, - Oauth: login.Options{}, - GracePeriod: 5*time.Second, + Oauth: login.Options{}, + GracePeriod: 5 * time.Second, }}, { // backwards compatibility // * login path as argument @@ -97,8 +97,8 @@ func TestSetup(t *testing.T) { "bob": "secret", }, }, - Oauth: login.Options{}, - GracePeriod: 5*time.Second, + Oauth: login.Options{}, + GracePeriod: 5 * time.Second, }}, { // backwards compatibility // * login path as argument @@ -121,8 +121,8 @@ func TestSetup(t *testing.T) { "bob": "secret", }, }, - Oauth: login.Options{}, - GracePeriod: 5*time.Second, + Oauth: login.Options{}, + GracePeriod: 5 * time.Second, }}, // error cases @@ -143,8 +143,8 @@ func TestSetup(t *testing.T) { "bob": "secret", }, }, - Oauth: login.Options{}, - GracePeriod: 5*time.Second, + Oauth: login.Options{}, + GracePeriod: 5 * time.Second, }}, {input: "login {\n}", shouldErr: true}, {input: "login xx yy {\n}", shouldErr: true}, diff --git a/logging/logger.go b/logging/logger.go index 2d2ceb2..4f43de8 100644 --- a/logging/logger.go +++ b/logging/logger.go @@ -235,7 +235,6 @@ func ServerClosed(appName string) { Logger.WithFields(fields).Infof("http server was closed: %v", appName) } - func getRemoteIp(r *http.Request) string { if r.Header.Get("X-Cluster-Client-Ip") != "" { return r.Header.Get("X-Cluster-Client-Ip") diff --git a/logging/logger_test.go b/logging/logger_test.go index 2c1adfc..43e20a8 100644 --- a/logging/logger_test.go +++ b/logging/logger_test.go @@ -4,8 +4,8 @@ import ( "bytes" "encoding/json" "errors" - "github.com/tarent/logrus" "github.com/stretchr/testify/assert" + "github.com/tarent/logrus" "net/http" "os" "testing" @@ -319,7 +319,7 @@ func Test_Logger_Cacheinfo(t *testing.T) { func Test_Logger_GetRemoteIp1(t *testing.T) { a := assert.New(t) req, _ := http.NewRequest("GET", "test.com", nil) - req.Header["X-Cluster-Client-Ip"] = []string {"1234"} + req.Header["X-Cluster-Client-Ip"] = []string{"1234"} ret := getRemoteIp(req) a.Equal("1234", ret) } @@ -327,7 +327,7 @@ func Test_Logger_GetRemoteIp1(t *testing.T) { func Test_Logger_GetRemoteIp2(t *testing.T) { a := assert.New(t) req, _ := http.NewRequest("GET", "test.com", nil) - req.Header["X-Real-Ip"] = []string {"1234"} + req.Header["X-Real-Ip"] = []string{"1234"} ret := getRemoteIp(req) a.Equal("1234", ret) } diff --git a/login/config_test.go b/login/config_test.go index ae26eed..e93817c 100644 --- a/login/config_test.go +++ b/login/config_test.go @@ -66,7 +66,7 @@ func TestConfig_ReadConfig(t *testing.T) { "client_secret": "bar", }, }, - GracePeriod: 4*time.Second, + GracePeriod: 4 * time.Second, } cfg, err := readConfig(flag.NewFlagSet("", flag.ContinueOnError), input) @@ -119,7 +119,7 @@ func TestConfig_ReadConfigFromEnv(t *testing.T) { "client_secret": "bar", }, }, - GracePeriod: 4*time.Second, + GracePeriod: 4 * time.Second, } cfg, err := readConfig(flag.NewFlagSet("", flag.ContinueOnError), []string{}) diff --git a/login/handler_test.go b/login/handler_test.go index 3dbfef7..969235f 100644 --- a/login/handler_test.go +++ b/login/handler_test.go @@ -244,7 +244,7 @@ func TestHandler_Refresh(t *testing.T) { token, err := h.createToken(input) NoError(t, err) - cookieStr := "Cookie: "+h.config.CookieName + "=" + token + ";" + cookieStr := "Cookie: " + h.config.CookieName + "=" + token + ";" // refreshSuccess recorder := call(req("POST", "/context/login", "", AcceptHTML, cookieStr)) @@ -270,11 +270,11 @@ func TestHandler_Refresh(t *testing.T) { func TestHandler_Refresh_Expired(t *testing.T) { h := testHandler() - input := model.UserInfo{Sub: "bob", Expiry: time.Now().Unix()-1} + input := model.UserInfo{Sub: "bob", Expiry: time.Now().Unix() - 1} token, err := h.createToken(input) NoError(t, err) - cookieStr := "Cookie: "+h.config.CookieName + "=" + token + ";" + cookieStr := "Cookie: " + h.config.CookieName + "=" + token + ";" // refreshSuccess recorder := call(req("POST", "/context/login", "", AcceptHTML, cookieStr)) @@ -288,7 +288,7 @@ func TestHandler_Refresh_Expired(t *testing.T) { func TestHandler_Refresh_Invalid_Token(t *testing.T) { h := testHandler() - cookieStr := "Cookie: "+h.config.CookieName + "=kjsbkabsdkjbasdbkasbdk.dfgdfg.fdgdfg;" + cookieStr := "Cookie: " + h.config.CookieName + "=kjsbkabsdkjbasdbkasbdk.dfgdfg.fdgdfg;" // refreshSuccess recorder := call(req("POST", "/context/login", "", AcceptHTML, cookieStr)) @@ -301,11 +301,11 @@ func TestHandler_Refresh_Invalid_Token(t *testing.T) { func TestHandler_Refresh_Max_Refreshes_Reached(t *testing.T) { h := testHandler() - input := model.UserInfo{Sub: "bob", Expiry: time.Now().Add(time.Second).Unix(), Refreshes:1} + input := model.UserInfo{Sub: "bob", Expiry: time.Now().Add(time.Second).Unix(), Refreshes: 1} token, err := h.createToken(input) NoError(t, err) - cookieStr := "Cookie: "+h.config.CookieName + "=" + token + ";" + cookieStr := "Cookie: " + h.config.CookieName + "=" + token + ";" // refreshSuccess recorder := call(req("POST", "/context/login", "", AcceptJwt, cookieStr))