"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files
Go azure-blobazure-blob-storageazure-filesbackblaze-b2cloud-storagedropboxencryptionftpfuse-filesystemgogolanggoogle-cloud-storagegoogle-driveonedriveopenstack-swiftrclones3sftpsyncwebdav
package dlna
import (
"net/http"
"net/http/httptest"
"testing"
"github.com/rclone/rclone/cmd/bisync/bilib"
"github.com/stretchr/testify/assert"
)
func TestAdjustXML(t *testing.T) {
tests := []struct {
name string
input []byte
expected string
}{
{
name: "no quotes",
input: []byte(`<title>Simple File</title>`),
expected: `<title>Simple File</title>`,
},
{
name: "numeric quote entities",
input: []byte(`<title>File "with quotes" in name</title>`),
expected: `<title>File "with quotes" in name</title>`,
},
{
name: "mixed entities",
input: []byte(`<title>File "test" & "demo"</title>`),
expected: `<title>File "test" & "demo"</title>`,
},
{
name: "already correct entities",
input: []byte(`<title>File "already correct"</title>`),
expected: `<title>File "already correct"</title>`,
},
{
name: "complex XML structure",
input: []byte(`<item><dc:title>Movie "Title"</dc:title><upnp:artist>Artist "Name"</upnp:artist></item>`),
expected: `<item><dc:title>Movie "Title"</dc:title><upnp:artist>Artist "Name"</upnp:artist></item>`,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
result := adjustXML(tt.input)
assert.Equal(t, tt.expected, result)
})
}
}
func TestLoggingUnescapedPath(t *testing.T) {
handler := logging(http.NotFoundHandler())
req := httptest.NewRequest("GET", "/r/%D0%91%D0%B0%D1%80%D0%B4%D1%8B/file%20name.mp3", nil)
logged := bilib.CaptureOutput(func() {
handler.ServeHTTP(httptest.NewRecorder(), req)
})
assert.Contains(t, string(logged), "ERROR : /r/Барды/file name.mp3: ")
}