feat(media): add MinIO storage switch and HTTPS OSS endpoint
This commit is contained in:
@@ -4,6 +4,7 @@ import (
|
||||
"bytes"
|
||||
"io"
|
||||
"net/http"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
@@ -123,3 +124,24 @@ func TestLoadSysConfig(t *testing.T) {
|
||||
t.Fatalf("unexpected OSS cors origins: %+v", handler.conf.CorsOrigins)
|
||||
}
|
||||
}
|
||||
|
||||
func TestOSSEndpointUsesHTTPS(t *testing.T) {
|
||||
for _, endpoint := range []string{
|
||||
"oss-cn-shenzhen.aliyuncs.com",
|
||||
"http://oss-cn-shenzhen.aliyuncs.com",
|
||||
"https://oss-cn-shenzhen.aliyuncs.com",
|
||||
} {
|
||||
handler := &ossHandler{}
|
||||
config := `{"endpoint":"` + endpoint + `","access_key_id":"ak","access_key_secret":"sk","bucket":"im-files"}`
|
||||
if err := handler.Init(config); err != nil {
|
||||
t.Fatalf("Init(%q): %v", endpoint, err)
|
||||
}
|
||||
signedURL, err := handler.bucket.SignURL("test.txt", aliyunoss.HTTPGet, 60)
|
||||
if err != nil {
|
||||
t.Fatalf("SignURL(%q): %v", endpoint, err)
|
||||
}
|
||||
if !strings.HasPrefix(signedURL, "https://") {
|
||||
t.Fatalf("endpoint %q produced non-HTTPS URL %q", endpoint, signedURL)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user