2016-07-26 02:18:56 +08:00
|
|
|
// Test Crypt filesystem interface
|
|
|
|
package crypt_test
|
|
|
|
|
|
|
|
import (
|
2018-04-08 01:48:11 +08:00
|
|
|
"os"
|
|
|
|
"path/filepath"
|
2016-07-26 02:18:56 +08:00
|
|
|
"testing"
|
|
|
|
|
2019-07-29 01:47:38 +08: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-26 02:18:56 +08:00
|
|
|
)
|
|
|
|
|
2018-10-24 00:12:38 +08: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 20:40:52 +08:00
|
|
|
RemoteName: *fstest.RemoteName,
|
|
|
|
NilObject: (*crypt.Object)(nil),
|
2019-04-23 02:22:42 +08:00
|
|
|
UnimplementableFsMethods: []string{"OpenWriterAt"},
|
2019-03-20 20:40:52 +08:00
|
|
|
UnimplementableObjectMethods: []string{"MimeType"},
|
2018-10-24 00:12:38 +08:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2018-04-08 01:48:11 +08:00
|
|
|
// TestStandard runs integration tests against the remote
|
2021-11-13 11:48:34 +08:00
|
|
|
func TestStandardBase32(t *testing.T) {
|
2018-10-24 00:12:38 +08:00
|
|
|
if *fstest.RemoteName != "" {
|
|
|
|
t.Skip("Skipping as -remote set")
|
|
|
|
}
|
2018-04-08 01:48:11 +08: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-23 02:22:42 +08:00
|
|
|
UnimplementableFsMethods: []string{"OpenWriterAt"},
|
2019-03-20 20:40:52 +08:00
|
|
|
UnimplementableObjectMethods: []string{"MimeType"},
|
2018-04-08 01:48:11 +08:00
|
|
|
})
|
2016-07-26 02:18:56 +08:00
|
|
|
}
|
|
|
|
|
2021-11-13 11:48:34 +08: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"},
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
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"},
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2018-04-08 01:48:11 +08:00
|
|
|
// TestOff runs integration tests against the remote
|
|
|
|
func TestOff(t *testing.T) {
|
2018-10-24 00:12:38 +08:00
|
|
|
if *fstest.RemoteName != "" {
|
|
|
|
t.Skip("Skipping as -remote set")
|
|
|
|
}
|
2018-04-08 01:48:11 +08: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-23 02:22:42 +08:00
|
|
|
UnimplementableFsMethods: []string{"OpenWriterAt"},
|
2019-03-20 20:40:52 +08:00
|
|
|
UnimplementableObjectMethods: []string{"MimeType"},
|
2018-04-08 01:48:11 +08:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
// TestObfuscate runs integration tests against the remote
|
|
|
|
func TestObfuscate(t *testing.T) {
|
2018-10-24 00:12:38 +08:00
|
|
|
if *fstest.RemoteName != "" {
|
|
|
|
t.Skip("Skipping as -remote set")
|
|
|
|
}
|
2018-04-08 01:48:11 +08: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 20:40:52 +08:00
|
|
|
SkipBadWindowsCharacters: true,
|
2019-04-23 02:22:42 +08:00
|
|
|
UnimplementableFsMethods: []string{"OpenWriterAt"},
|
2019-03-20 20:40:52 +08:00
|
|
|
UnimplementableObjectMethods: []string{"MimeType"},
|
2018-04-08 01:48:11 +08:00
|
|
|
})
|
|
|
|
}
|
2021-02-17 08:40:37 +08:00
|
|
|
|
|
|
|
// TestNoDataObfuscate runs integration tests against the remote
|
|
|
|
func TestNoDataObfuscate(t *testing.T) {
|
|
|
|
if *fstest.RemoteName != "" {
|
|
|
|
t.Skip("Skipping as -remote set")
|
|
|
|
}
|
|
|
|
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"},
|
|
|
|
})
|
|
|
|
}
|