MCPcopy
hub / github.com/rclone/rclone / TestConfigLoadEncryptedWithValidPassCommand

Function TestConfigLoadEncryptedWithValidPassCommand

fs/config/crypt_test.go:44–71  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

42}
43
44func TestConfigLoadEncryptedWithValidPassCommand(t *testing.T) {
45 ctx := context.Background()
46 ci := fs.GetConfig(ctx)
47 oldConfigPath := config.GetConfigPath()
48 oldConfig := *ci
49 assert.NoError(t, config.SetConfigPath("./testdata/encrypted.conf"))
50 // using ci.PasswordCommand, correct password
51 ci.PasswordCommand = fs.SpaceSepList{"echo", "asdf"}
52 defer func() {
53 assert.NoError(t, config.SetConfigPath(oldConfigPath))
54 config.ClearConfigPassword()
55 *ci = oldConfig
56 ci.PasswordCommand = nil
57 }()
58
59 config.ClearConfigPassword()
60
61 err := config.Data().Load()
62 require.NoError(t, err)
63
64 sections := config.Data().GetSectionList()
65 var expect = []string{"nounc", "unc"}
66 assert.Equal(t, expect, sections)
67
68 keys := config.Data().GetKeyList("nounc")
69 expect = []string{"type", "nounc"}
70 assert.Equal(t, expect, keys)
71}
72
73func TestConfigLoadEncryptedWithInvalidPassCommand(t *testing.T) {
74 ctx := context.Background()

Callers

nothing calls this directly

Calls 9

GetConfigFunction · 0.92
GetConfigPathFunction · 0.92
SetConfigPathFunction · 0.92
ClearConfigPasswordFunction · 0.92
DataFunction · 0.92
LoadMethod · 0.65
GetSectionListMethod · 0.65
GetKeyListMethod · 0.65
EqualMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…