Update to go1.23
This commit is contained in:
parent
d2030a5835
commit
e56ae1a766
41 changed files with 113 additions and 119 deletions
|
@ -197,7 +197,7 @@ func TestLoggerHeaderFields(t *testing.T) {
|
|||
|
||||
if config.FilePath != "" {
|
||||
_, err = os.Stat(config.FilePath)
|
||||
require.NoError(t, err, fmt.Sprintf("logger should create %s", config.FilePath))
|
||||
require.NoErrorf(t, err, "logger should create %s", config.FilePath)
|
||||
}
|
||||
|
||||
req := &http.Request{
|
||||
|
@ -701,7 +701,7 @@ func assertValidLogData(t *testing.T, expected string, logData []byte) {
|
|||
t.Helper()
|
||||
|
||||
if len(expected) == 0 {
|
||||
assert.Zero(t, len(logData))
|
||||
assert.Empty(t, logData)
|
||||
t.Log(string(logData))
|
||||
return
|
||||
}
|
||||
|
@ -758,7 +758,7 @@ func doLoggingTLSOpt(t *testing.T, config *types.AccessLog, enableTLS bool) {
|
|||
|
||||
if config.FilePath != "" {
|
||||
_, err = os.Stat(config.FilePath)
|
||||
require.NoError(t, err, fmt.Sprintf("logger should create %s", config.FilePath))
|
||||
require.NoErrorf(t, err, "logger should create %s", config.FilePath)
|
||||
}
|
||||
|
||||
req := &http.Request{
|
||||
|
|
|
@ -103,9 +103,8 @@ func (fa *forwardAuth) ServeHTTP(rw http.ResponseWriter, req *http.Request) {
|
|||
forwardReq, err := http.NewRequest(http.MethodGet, fa.address, nil)
|
||||
tracing.LogRequest(tracing.GetSpan(req), forwardReq)
|
||||
if err != nil {
|
||||
logMessage := fmt.Sprintf("Error calling %s. Cause %s", fa.address, err)
|
||||
logger.Debug(logMessage)
|
||||
tracing.SetErrorWithEvent(req, logMessage)
|
||||
logger.Debugf("Error calling %s. Cause %s", fa.address, err)
|
||||
tracing.SetErrorWithEvent(req, "Error calling %s. Cause %s", fa.address, err)
|
||||
|
||||
rw.WriteHeader(http.StatusInternalServerError)
|
||||
return
|
||||
|
@ -119,9 +118,8 @@ func (fa *forwardAuth) ServeHTTP(rw http.ResponseWriter, req *http.Request) {
|
|||
|
||||
forwardResponse, forwardErr := fa.client.Do(forwardReq)
|
||||
if forwardErr != nil {
|
||||
logMessage := fmt.Sprintf("Error calling %s. Cause: %s", fa.address, forwardErr)
|
||||
logger.Debug(logMessage)
|
||||
tracing.SetErrorWithEvent(req, logMessage)
|
||||
logger.Debugf("Error calling %s. Cause: %s", fa.address, forwardErr)
|
||||
tracing.SetErrorWithEvent(req, "Error calling %s. Cause: %s", fa.address, forwardErr)
|
||||
|
||||
rw.WriteHeader(http.StatusInternalServerError)
|
||||
return
|
||||
|
@ -130,9 +128,8 @@ func (fa *forwardAuth) ServeHTTP(rw http.ResponseWriter, req *http.Request) {
|
|||
|
||||
body, readError := io.ReadAll(forwardResponse.Body)
|
||||
if readError != nil {
|
||||
logMessage := fmt.Sprintf("Error reading body %s. Cause: %s", fa.address, readError)
|
||||
logger.Debug(logMessage)
|
||||
tracing.SetErrorWithEvent(req, logMessage)
|
||||
logger.Debugf("Error reading body %s. Cause: %s", fa.address, readError)
|
||||
tracing.SetErrorWithEvent(req, "Error reading body %s. Cause: %s", fa.address, readError)
|
||||
|
||||
rw.WriteHeader(http.StatusInternalServerError)
|
||||
return
|
||||
|
@ -151,9 +148,8 @@ func (fa *forwardAuth) ServeHTTP(rw http.ResponseWriter, req *http.Request) {
|
|||
|
||||
if err != nil {
|
||||
if !errors.Is(err, http.ErrNoLocation) {
|
||||
logMessage := fmt.Sprintf("Error reading response location header %s. Cause: %s", fa.address, err)
|
||||
logger.Debug(logMessage)
|
||||
tracing.SetErrorWithEvent(req, logMessage)
|
||||
logger.Debugf("Error reading response location header %s. Cause: %s", fa.address, err)
|
||||
tracing.SetErrorWithEvent(req, "Error reading response location header %s. Cause: %s", fa.address, err)
|
||||
|
||||
rw.WriteHeader(http.StatusInternalServerError)
|
||||
return
|
||||
|
|
|
@ -66,9 +66,8 @@ func (al *ipAllowLister) ServeHTTP(rw http.ResponseWriter, req *http.Request) {
|
|||
clientIP := al.strategy.GetIP(req)
|
||||
err := al.allowLister.IsAuthorized(clientIP)
|
||||
if err != nil {
|
||||
msg := fmt.Sprintf("Rejecting IP %s: %v", clientIP, err)
|
||||
logger.Debug(msg)
|
||||
tracing.SetErrorWithEvent(req, msg)
|
||||
logger.Debugf("Rejecting IP %s: %v", clientIP, err)
|
||||
tracing.SetErrorWithEvent(req, "Rejecting IP %s: %v", clientIP, err)
|
||||
reject(ctx, rw)
|
||||
return
|
||||
}
|
||||
|
|
|
@ -66,9 +66,8 @@ func (wl *ipWhiteLister) ServeHTTP(rw http.ResponseWriter, req *http.Request) {
|
|||
clientIP := wl.strategy.GetIP(req)
|
||||
err := wl.whiteLister.IsAuthorized(clientIP)
|
||||
if err != nil {
|
||||
msg := fmt.Sprintf("Rejecting IP %s: %v", clientIP, err)
|
||||
logger.Debug(msg)
|
||||
tracing.SetErrorWithEvent(req, msg)
|
||||
logger.Debugf("Rejecting IP %s: %v", clientIP, err)
|
||||
tracing.SetErrorWithEvent(req, "Rejecting IP %s: %v", clientIP, err)
|
||||
reject(ctx, rw)
|
||||
return
|
||||
}
|
||||
|
|
|
@ -319,7 +319,7 @@ func TestPassTLSClientCert_PEM(t *testing.T) {
|
|||
res := httptest.NewRecorder()
|
||||
req := testhelpers.MustNewRequest(http.MethodGet, "http://example.com/foo", nil)
|
||||
|
||||
if test.certContents != nil && len(test.certContents) > 0 {
|
||||
if len(test.certContents) > 0 {
|
||||
req.TLS = buildTLSWith(test.certContents)
|
||||
}
|
||||
|
||||
|
@ -541,7 +541,7 @@ func TestPassTLSClientCert_certInfo(t *testing.T) {
|
|||
res := httptest.NewRecorder()
|
||||
req := testhelpers.MustNewRequest(http.MethodGet, "http://example.com/foo", nil)
|
||||
|
||||
if test.certContents != nil && len(test.certContents) > 0 {
|
||||
if len(test.certContents) > 0 {
|
||||
req.TLS = buildTLSWith(test.certContents)
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue