Files
fnx_web/webcontroller/opengraph_test.go

25 lines
732 B
Go

package webcontroller
import (
"net/http/httptest"
"strings"
"testing"
"fornaxian.tech/nova_server/api"
)
// The services which make link previews have no cookies, so a password in the
// link has to be in the URLs they open
func TestMetadataPassword(t *testing.T) {
var r = httptest.NewRequest("GET", "/d/abc/a%20b.png?password=p%26w+1", nil)
var og = (&WebController{}).metadataFromFilesystem(r, api.FilesystemPath{
Path: []api.FilesystemNode{{Path: "/abc/a b.png", FileType: "image/png"}},
})
for _, prop := range og.MetaPropRules {
if (prop.Key == "og:url" || prop.Key == "og:image") &&
!strings.HasSuffix(prop.Value, "/abc/a%20b.png?password=p%26w+1") {
t.Errorf("%s is %s", prop.Key, prop.Value)
}
}
}