fix panic on auth

This commit is contained in:
kevin
2020-07-30 16:22:18 +08:00
parent e56ebf1f72
commit 53973bc0f7
2 changed files with 30 additions and 10 deletions

View File

@@ -75,6 +75,14 @@ func TestAuthHandlerWithPrevSecret(t *testing.T) {
assert.Equal(t, "content", resp.Body.String())
}
func TestAuthHandler_NilError(t *testing.T) {
req := httptest.NewRequest(http.MethodGet, "http://localhost", nil)
resp := httptest.NewRecorder()
assert.NotPanics(t, func() {
unauthorized(resp, req, nil, nil)
})
}
func buildToken(secretKey string, payloads map[string]interface{}, seconds int64) (string, error) {
now := time.Now().Unix()
claims := make(jwt.MapClaims)