增加日志与退出时404问题处理
This commit is contained in:
1 parent
2a2f78c81e
commit
648b274c55
7 files changed
+226
-2
No files matched your search
@@ -4,9 +4,12 @@ import (
|
||||
"bytes"
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"strings"
|
||||
"syscall"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
@@ -148,6 +151,28 @@ func TestOSSHTTPClientPropagatesContextCancellation(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestOSSTransportDiagnosticIsClassifiedAndDoesNotExposeRequestData(t *testing.T) {
|
||||
request, err := http.NewRequest(http.MethodPut, "https://private-bucket.oss-cn-guangzhou-internal.aliyuncs.com/uploads/private-file.png?credential=secret", nil)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
request.Header.Set("Authorization", "OSS access-key:private-signature")
|
||||
diagnostic := diagnoseOSSTransport(request, &url.Error{
|
||||
Op: "Put",
|
||||
URL: request.URL.String(),
|
||||
Err: syscall.ECONNRESET,
|
||||
})
|
||||
if diagnostic.Method != http.MethodPut || diagnostic.EndpointClass != "internal" || diagnostic.ErrorClass != "connection_reset" {
|
||||
t.Fatalf("diagnostic = %#v", diagnostic)
|
||||
}
|
||||
serialized := fmt.Sprintf("%+v", diagnostic)
|
||||
for _, secret := range []string{"private-bucket", "private-file", "credential", "access-key", "private-signature"} {
|
||||
if strings.Contains(serialized, secret) {
|
||||
t.Fatalf("diagnostic leaks %q: %s", secret, serialized)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestNewOSSHTTPClientRejectsMissingDependencies(t *testing.T) {
|
||||
for _, test := range []struct {
|
||||
id, secret string
|
||||
|
||||
Reference in new issue
Block a user