fix: verify OSS objects before serving
This commit is contained in:
@@ -1,9 +1,12 @@
|
||||
package oss
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
aliyunoss "github.com/aliyun/aliyun-oss-go-sdk/oss"
|
||||
|
||||
"github.com/tinode/chat/server/store"
|
||||
"github.com/tinode/chat/server/store/types"
|
||||
)
|
||||
@@ -46,6 +49,15 @@ func TestGetIdFromUrl(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestIsOSSObjectNotFound(t *testing.T) {
|
||||
if !isOSSObjectNotFound(aliyunoss.ServiceError{StatusCode: http.StatusNotFound, Code: "NoSuchKey"}) {
|
||||
t.Fatal("NoSuchKey should be treated as missing object")
|
||||
}
|
||||
if isOSSObjectNotFound(aliyunoss.ServiceError{StatusCode: http.StatusForbidden, Code: "AccessDenied"}) {
|
||||
t.Fatal("AccessDenied must not be treated as missing object")
|
||||
}
|
||||
}
|
||||
|
||||
func TestLoadSysConfig(t *testing.T) {
|
||||
original := store.ThirdPartyConfig
|
||||
store.ThirdPartyConfig = fakeThirdPartyConfig{
|
||||
|
||||
Reference in New Issue
Block a user