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"
|
|
|
|
|
2018-01-12 00:05:41 +08:00
|
|
|
"github.com/ncw/rclone/backend/crypt"
|
|
|
|
_ "github.com/ncw/rclone/backend/local"
|
2018-04-08 01:48:11 +08:00
|
|
|
"github.com/ncw/rclone/fs/config/obscure"
|
2016-07-26 02:18:56 +08:00
|
|
|
"github.com/ncw/rclone/fstest/fstests"
|
|
|
|
)
|
|
|
|
|
2018-04-08 01:48:11 +08:00
|
|
|
// TestStandard runs integration tests against the remote
|
|
|
|
func TestStandard(t *testing.T) {
|
|
|
|
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"},
|
|
|
|
},
|
|
|
|
})
|
2016-07-26 02:18:56 +08:00
|
|
|
}
|
|
|
|
|
2018-04-08 01:48:11 +08:00
|
|
|
// TestOff runs integration tests against the remote
|
|
|
|
func TestOff(t *testing.T) {
|
|
|
|
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"},
|
|
|
|
},
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
// TestObfuscate runs integration tests against the remote
|
|
|
|
func TestObfuscate(t *testing.T) {
|
|
|
|
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"},
|
|
|
|
},
|
|
|
|
SkipBadWindowsCharacters: true,
|
|
|
|
})
|
|
|
|
}
|