loginsrv

Unnamed repository; edit this file 'description' to name the repository.
git clone git@jamesshield.xyz:repos/loginsrv.git
Log | Files | Refs | README | LICENSE

commit adb465e486850d54a0b3d3151749bb9f03a875fc
parent 7ceb900c37ac44d9abc444eda048d6bbccd3cba0
Author: Sebastian Mancke <s.mancke@tarent.de>
Date:   Tue, 20 Jun 2017 22:15:06 +0200

Merge pull request #33 from SchulteMarkus/master

go fmt
Diffstat:
Mcaddy/setup_test.go | 20++++++++++----------
Mlogging/logger.go | 1-
Mlogging/logger_test.go | 6+++---
Mlogin/config_test.go | 4++--
Mlogin/handler_test.go | 12++++++------
5 files changed, 21 insertions(+), 22 deletions(-)

diff --git 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 @@ -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 @@ -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 @@ -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 @@ -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))