2016-07-25 20:18:56 +02:00
|
|
|
// Test Crypt filesystem interface
|
|
|
|
package crypt_test
|
|
|
|
|
|
|
|
import (
|
2018-04-07 19:48:11 +02:00
|
|
|
"os"
|
|
|
|
"path/filepath"
|
2022-06-29 12:51:46 +02:00
|
|
|
"runtime"
|
2016-07-25 20:18:56 +02:00
|
|
|
"testing"
|
|
|
|
|
2019-07-28 19:47:38 +02:00
|
|
|
"github.com/rclone/rclone/backend/crypt"
|
|
|
|
_ "github.com/rclone/rclone/backend/drive" // for integration tests
|
|
|
|
_ "github.com/rclone/rclone/backend/local"
|
|
|
|
_ "github.com/rclone/rclone/backend/swift" // for integration tests
|
|
|
|
"github.com/rclone/rclone/fs/config/obscure"
|
|
|
|
"github.com/rclone/rclone/fstest"
|
|
|
|
"github.com/rclone/rclone/fstest/fstests"
|
2016-07-25 20:18:56 +02:00
|
|
|
)
|
|
|
|
|
2018-10-23 18:12:38 +02:00
|
|
|
// TestIntegration runs integration tests against the remote
|
|
|
|
func TestIntegration(t *testing.T) {
|
|
|
|
if *fstest.RemoteName == "" {
|
|
|
|
t.Skip("Skipping as -remote not set")
|
|
|
|
}
|
|
|
|
fstests.Run(t, &fstests.Opt{
|
2019-03-20 13:40:52 +01:00
|
|
|
RemoteName: *fstest.RemoteName,
|
|
|
|
NilObject: (*crypt.Object)(nil),
|
2019-04-22 20:22:42 +02:00
|
|
|
UnimplementableFsMethods: []string{"OpenWriterAt"},
|
2019-03-20 13:40:52 +01:00
|
|
|
UnimplementableObjectMethods: []string{"MimeType"},
|
2018-10-23 18:12:38 +02:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2018-04-07 19:48:11 +02:00
|
|
|
// TestStandard runs integration tests against the remote
|
2021-11-13 04:48:34 +01:00
|
|
|
func TestStandardBase32(t *testing.T) {
|
2018-10-23 18:12:38 +02:00
|
|
|
if *fstest.RemoteName != "" {
|
|
|
|
t.Skip("Skipping as -remote set")
|
|
|
|
}
|
2018-04-07 19:48:11 +02:00
|
|
|
tempdir := filepath.Join(os.TempDir(), "rclone-crypt-test-standard")
|
|
|
|
name := "TestCrypt"
|
|
|
|
fstests.Run(t, &fstests.Opt{
|
|
|
|
RemoteName: name + ":",
|
|
|
|
NilObject: (*crypt.Object)(nil),
|
|
|
|
ExtraConfig: []fstests.ExtraConfigItem{
|
|
|
|
{Name: name, Key: "type", Value: "crypt"},
|
|
|
|
{Name: name, Key: "remote", Value: tempdir},
|
|
|
|
{Name: name, Key: "password", Value: obscure.MustObscure("potato")},
|
|
|
|
{Name: name, Key: "filename_encryption", Value: "standard"},
|
|
|
|
},
|
2019-04-22 20:22:42 +02:00
|
|
|
UnimplementableFsMethods: []string{"OpenWriterAt"},
|
2019-03-20 13:40:52 +01:00
|
|
|
UnimplementableObjectMethods: []string{"MimeType"},
|
2022-06-29 12:51:46 +02:00
|
|
|
QuickTestOK: true,
|
2018-04-07 19:48:11 +02:00
|
|
|
})
|
2016-07-25 20:18:56 +02:00
|
|
|
}
|
|
|
|
|
2021-11-13 04:48:34 +01:00
|
|
|
func TestStandardBase64(t *testing.T) {
|
|
|
|
if *fstest.RemoteName != "" {
|
|
|
|
t.Skip("Skipping as -remote set")
|
|
|
|
}
|
|
|
|
tempdir := filepath.Join(os.TempDir(), "rclone-crypt-test-standard")
|
|
|
|
name := "TestCrypt"
|
|
|
|
fstests.Run(t, &fstests.Opt{
|
|
|
|
RemoteName: name + ":",
|
|
|
|
NilObject: (*crypt.Object)(nil),
|
|
|
|
ExtraConfig: []fstests.ExtraConfigItem{
|
|
|
|
{Name: name, Key: "type", Value: "crypt"},
|
|
|
|
{Name: name, Key: "remote", Value: tempdir},
|
|
|
|
{Name: name, Key: "password", Value: obscure.MustObscure("potato")},
|
|
|
|
{Name: name, Key: "filename_encryption", Value: "standard"},
|
|
|
|
{Name: name, Key: "filename_encoding", Value: "base64"},
|
|
|
|
},
|
|
|
|
UnimplementableFsMethods: []string{"OpenWriterAt"},
|
|
|
|
UnimplementableObjectMethods: []string{"MimeType"},
|
2022-06-29 12:51:46 +02:00
|
|
|
QuickTestOK: true,
|
2021-11-13 04:48:34 +01:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestStandardBase32768(t *testing.T) {
|
|
|
|
if *fstest.RemoteName != "" {
|
|
|
|
t.Skip("Skipping as -remote set")
|
|
|
|
}
|
|
|
|
tempdir := filepath.Join(os.TempDir(), "rclone-crypt-test-standard")
|
|
|
|
name := "TestCrypt"
|
|
|
|
fstests.Run(t, &fstests.Opt{
|
|
|
|
RemoteName: name + ":",
|
|
|
|
NilObject: (*crypt.Object)(nil),
|
|
|
|
ExtraConfig: []fstests.ExtraConfigItem{
|
|
|
|
{Name: name, Key: "type", Value: "crypt"},
|
|
|
|
{Name: name, Key: "remote", Value: tempdir},
|
|
|
|
{Name: name, Key: "password", Value: obscure.MustObscure("potato")},
|
|
|
|
{Name: name, Key: "filename_encryption", Value: "standard"},
|
|
|
|
{Name: name, Key: "filename_encoding", Value: "base32768"},
|
|
|
|
},
|
|
|
|
UnimplementableFsMethods: []string{"OpenWriterAt"},
|
|
|
|
UnimplementableObjectMethods: []string{"MimeType"},
|
2022-06-29 12:51:46 +02:00
|
|
|
QuickTestOK: true,
|
2021-11-13 04:48:34 +01:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2018-04-07 19:48:11 +02:00
|
|
|
// TestOff runs integration tests against the remote
|
|
|
|
func TestOff(t *testing.T) {
|
2018-10-23 18:12:38 +02:00
|
|
|
if *fstest.RemoteName != "" {
|
|
|
|
t.Skip("Skipping as -remote set")
|
|
|
|
}
|
2018-04-07 19:48:11 +02:00
|
|
|
tempdir := filepath.Join(os.TempDir(), "rclone-crypt-test-off")
|
|
|
|
name := "TestCrypt2"
|
|
|
|
fstests.Run(t, &fstests.Opt{
|
|
|
|
RemoteName: name + ":",
|
|
|
|
NilObject: (*crypt.Object)(nil),
|
|
|
|
ExtraConfig: []fstests.ExtraConfigItem{
|
|
|
|
{Name: name, Key: "type", Value: "crypt"},
|
|
|
|
{Name: name, Key: "remote", Value: tempdir},
|
|
|
|
{Name: name, Key: "password", Value: obscure.MustObscure("potato2")},
|
|
|
|
{Name: name, Key: "filename_encryption", Value: "off"},
|
|
|
|
},
|
2019-04-22 20:22:42 +02:00
|
|
|
UnimplementableFsMethods: []string{"OpenWriterAt"},
|
2019-03-20 13:40:52 +01:00
|
|
|
UnimplementableObjectMethods: []string{"MimeType"},
|
2022-06-29 12:51:46 +02:00
|
|
|
QuickTestOK: true,
|
2018-04-07 19:48:11 +02:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
// TestObfuscate runs integration tests against the remote
|
|
|
|
func TestObfuscate(t *testing.T) {
|
2018-10-23 18:12:38 +02:00
|
|
|
if *fstest.RemoteName != "" {
|
|
|
|
t.Skip("Skipping as -remote set")
|
|
|
|
}
|
2022-06-29 12:51:46 +02:00
|
|
|
if runtime.GOOS == "darwin" {
|
|
|
|
t.Skip("Skipping on macOS as obfuscating control characters makes filenames macOS can't cope with")
|
|
|
|
}
|
2018-04-07 19:48:11 +02:00
|
|
|
tempdir := filepath.Join(os.TempDir(), "rclone-crypt-test-obfuscate")
|
|
|
|
name := "TestCrypt3"
|
|
|
|
fstests.Run(t, &fstests.Opt{
|
|
|
|
RemoteName: name + ":",
|
|
|
|
NilObject: (*crypt.Object)(nil),
|
|
|
|
ExtraConfig: []fstests.ExtraConfigItem{
|
|
|
|
{Name: name, Key: "type", Value: "crypt"},
|
|
|
|
{Name: name, Key: "remote", Value: tempdir},
|
|
|
|
{Name: name, Key: "password", Value: obscure.MustObscure("potato2")},
|
|
|
|
{Name: name, Key: "filename_encryption", Value: "obfuscate"},
|
|
|
|
},
|
2019-03-20 13:40:52 +01:00
|
|
|
SkipBadWindowsCharacters: true,
|
2019-04-22 20:22:42 +02:00
|
|
|
UnimplementableFsMethods: []string{"OpenWriterAt"},
|
2019-03-20 13:40:52 +01:00
|
|
|
UnimplementableObjectMethods: []string{"MimeType"},
|
2022-06-29 12:51:46 +02:00
|
|
|
QuickTestOK: true,
|
2018-04-07 19:48:11 +02:00
|
|
|
})
|
|
|
|
}
|
2021-02-17 01:40:37 +01:00
|
|
|
|
|
|
|
// TestNoDataObfuscate runs integration tests against the remote
|
|
|
|
func TestNoDataObfuscate(t *testing.T) {
|
|
|
|
if *fstest.RemoteName != "" {
|
|
|
|
t.Skip("Skipping as -remote set")
|
|
|
|
}
|
2022-06-29 12:51:46 +02:00
|
|
|
if runtime.GOOS == "darwin" {
|
|
|
|
t.Skip("Skipping on macOS as obfuscating control characters makes filenames macOS can't cope with")
|
|
|
|
}
|
2021-02-17 01:40:37 +01:00
|
|
|
tempdir := filepath.Join(os.TempDir(), "rclone-crypt-test-obfuscate")
|
|
|
|
name := "TestCrypt4"
|
|
|
|
fstests.Run(t, &fstests.Opt{
|
|
|
|
RemoteName: name + ":",
|
|
|
|
NilObject: (*crypt.Object)(nil),
|
|
|
|
ExtraConfig: []fstests.ExtraConfigItem{
|
|
|
|
{Name: name, Key: "type", Value: "crypt"},
|
|
|
|
{Name: name, Key: "remote", Value: tempdir},
|
|
|
|
{Name: name, Key: "password", Value: obscure.MustObscure("potato2")},
|
|
|
|
{Name: name, Key: "filename_encryption", Value: "obfuscate"},
|
|
|
|
{Name: name, Key: "no_data_encryption", Value: "true"},
|
|
|
|
},
|
|
|
|
SkipBadWindowsCharacters: true,
|
|
|
|
UnimplementableFsMethods: []string{"OpenWriterAt"},
|
|
|
|
UnimplementableObjectMethods: []string{"MimeType"},
|
2022-06-29 12:51:46 +02:00
|
|
|
QuickTestOK: true,
|
2021-02-17 01:40:37 +01:00
|
|
|
})
|
|
|
|
}
|