MCPcopy Index your code
hub / github.com/rclone/rclone / TestCreateUpdatePasswordRemote

Function TestCreateUpdatePasswordRemote

fs/config/ui_test.go:194–251  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

192}
193
194func TestCreateUpdatePasswordRemote(t *testing.T) {
195 ctx := context.Background()
196 defer testConfigFile(t, simpleOptions, "update.conf")()
197
198 for _, doObscure := range []bool{false, true} {
199 for _, noObscure := range []bool{false, true} {
200 if doObscure && noObscure {
201 break
202 }
203 t.Run(fmt.Sprintf("doObscure=%v,noObscure=%v", doObscure, noObscure), func(t *testing.T) {
204 opt := config.UpdateRemoteOpt{
205 Obscure: doObscure,
206 NoObscure: noObscure,
207 }
208 _, err := config.CreateRemote(ctx, "test2", "config_test_remote", rc.Params{
209 "bool": true,
210 "pass": "potato",
211 }, opt)
212 require.NoError(t, err)
213
214 assert.Equal(t, []string{"test2"}, config.Data().GetSectionList())
215 assert.Equal(t, "config_test_remote", config.GetValue("test2", "type"))
216 assert.Equal(t, "true", config.GetValue("test2", "bool"))
217 gotPw := config.GetValue("test2", "pass")
218 if !noObscure {
219 gotPw = obscure.MustReveal(gotPw)
220 }
221 assert.Equal(t, "potato", gotPw)
222
223 wantPw := obscure.MustObscure("potato2")
224 _, err = config.UpdateRemote(ctx, "test2", rc.Params{
225 "bool": false,
226 "pass": wantPw,
227 "spare": "spare",
228 }, opt)
229 require.NoError(t, err)
230
231 assert.Equal(t, []string{"test2"}, config.Data().GetSectionList())
232 assert.Equal(t, "config_test_remote", config.GetValue("test2", "type"))
233 assert.Equal(t, "false", config.GetValue("test2", "bool"))
234 gotPw = config.GetValue("test2", "pass")
235 if doObscure {
236 gotPw = obscure.MustReveal(gotPw)
237 }
238 assert.Equal(t, wantPw, gotPw)
239
240 require.NoError(t, config.PasswordRemote(ctx, "test2", rc.Params{
241 "pass": "potato3",
242 }))
243
244 assert.Equal(t, []string{"test2"}, config.Data().GetSectionList())
245 assert.Equal(t, "config_test_remote", config.GetValue("test2", "type"))
246 assert.Equal(t, "false", config.GetValue("test2", "bool"))
247 assert.Equal(t, "potato3", obscure.MustReveal(config.GetValue("test2", "pass")))
248 })
249 }
250 }
251}

Callers

nothing calls this directly

Calls 11

CreateRemoteFunction · 0.92
DataFunction · 0.92
GetValueFunction · 0.92
MustRevealFunction · 0.92
MustObscureFunction · 0.92
UpdateRemoteFunction · 0.92
PasswordRemoteFunction · 0.92
testConfigFileFunction · 0.85
RunMethod · 0.65
GetSectionListMethod · 0.65
EqualMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…