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"
|
2016-07-25 20:18:56 +02:00
|
|
|
"testing"
|
|
|
|
|
2018-01-11 17:05:41 +01:00
|
|
|
"github.com/ncw/rclone/backend/crypt"
|
|
|
|
_ "github.com/ncw/rclone/backend/local"
|
2018-04-07 19:48:11 +02:00
|
|
|
"github.com/ncw/rclone/fs/config/obscure"
|
2016-07-25 20:18:56 +02:00
|
|
|
"github.com/ncw/rclone/fstest/fstests"
|
|
|
|
)
|
|
|
|
|
2018-04-07 19:48:11 +02: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-25 20:18:56 +02:00
|
|
|
}
|
|
|
|
|
2018-04-07 19:48:11 +02: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,
|
|
|
|
})
|
|
|
|
}
|