mirror of
https://github.com/rclone/rclone.git
synced 2025-12-16 16:23:22 +00:00
Compare commits
2 Commits
v1.72-stab
...
test
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
be2c44f5af | ||
|
|
1db0f51be4 |
@@ -20,7 +20,7 @@ Unlocks the config file if it is locked.
|
|||||||
|
|
||||||
Parameters:
|
Parameters:
|
||||||
|
|
||||||
- 'config_password' - password to unlock the config file
|
- 'configPassword' - password to unlock the config file
|
||||||
|
|
||||||
A good idea is to disable AskPassword before making this call
|
A good idea is to disable AskPassword before making this call
|
||||||
`,
|
`,
|
||||||
@@ -30,10 +30,14 @@ A good idea is to disable AskPassword before making this call
|
|||||||
// Unlock the config file
|
// Unlock the config file
|
||||||
// A good idea is to disable AskPassword before making this call
|
// A good idea is to disable AskPassword before making this call
|
||||||
func rcConfigPassword(ctx context.Context, in rc.Params) (out rc.Params, err error) {
|
func rcConfigPassword(ctx context.Context, in rc.Params) (out rc.Params, err error) {
|
||||||
configPass, err := in.GetString("config_password")
|
configPass, err := in.GetString("configPassword")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
var err2 error
|
||||||
|
configPass, err2 = in.GetString("config_password") // backwards compat
|
||||||
|
if err2 != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if SetConfigPassword(configPass) != nil {
|
if SetConfigPassword(configPass) != nil {
|
||||||
return nil, errors.New("failed to set config password")
|
return nil, errors.New("failed to set config password")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -215,13 +215,26 @@ func TestRcPaths(t *testing.T) {
|
|||||||
func TestRcConfigUnlock(t *testing.T) {
|
func TestRcConfigUnlock(t *testing.T) {
|
||||||
call := rc.Calls.Get("config/unlock")
|
call := rc.Calls.Get("config/unlock")
|
||||||
assert.NotNil(t, call)
|
assert.NotNil(t, call)
|
||||||
|
|
||||||
in := rc.Params{
|
in := rc.Params{
|
||||||
"config_password": "test",
|
"configPassword": "test",
|
||||||
}
|
}
|
||||||
out, err := call.Fn(context.Background(), in)
|
out, err := call.Fn(context.Background(), in)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
assert.Nil(t, err)
|
|
||||||
assert.Nil(t, out)
|
assert.Nil(t, out)
|
||||||
|
|
||||||
|
in = rc.Params{
|
||||||
|
"config_password": "test",
|
||||||
|
}
|
||||||
|
out, err = call.Fn(context.Background(), in)
|
||||||
|
require.NoError(t, err)
|
||||||
|
assert.Nil(t, out)
|
||||||
|
|
||||||
|
in = rc.Params{
|
||||||
|
"bad_config_password": "test",
|
||||||
|
}
|
||||||
|
out, err = call.Fn(context.Background(), in)
|
||||||
|
require.Error(t, err)
|
||||||
|
assert.ErrorContains(t, err, `Didn't find key "configPassword" in input`)
|
||||||
|
assert.Nil(t, out)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -425,8 +425,8 @@ Results:
|
|||||||
|
|
||||||
- executeId - string id of rclone executing (change after restart)
|
- executeId - string id of rclone executing (change after restart)
|
||||||
- jobids - array of integer job ids (starting at 1 on each restart)
|
- jobids - array of integer job ids (starting at 1 on each restart)
|
||||||
- running_ids - array of integer job ids that are running
|
- runningIds - array of integer job ids that are running
|
||||||
- finished_ids - array of integer job ids that are finished
|
- finishedIds - array of integer job ids that are finished
|
||||||
`,
|
`,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -436,8 +436,8 @@ func rcJobList(ctx context.Context, in rc.Params) (out rc.Params, err error) {
|
|||||||
out = make(rc.Params)
|
out = make(rc.Params)
|
||||||
out["jobids"] = running.IDs()
|
out["jobids"] = running.IDs()
|
||||||
runningIDs, finishedIDs := running.Stats()
|
runningIDs, finishedIDs := running.Stats()
|
||||||
out["running_ids"] = runningIDs
|
out["runningIds"] = runningIDs
|
||||||
out["finished_ids"] = finishedIDs
|
out["finishedIds"] = finishedIDs
|
||||||
out["executeId"] = executeID
|
out["executeId"] = executeID
|
||||||
return out, nil
|
return out, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -378,8 +378,8 @@ func TestRcJobList(t *testing.T) {
|
|||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.NotNil(t, out1)
|
require.NotNil(t, out1)
|
||||||
assert.Equal(t, []int64{1}, out1["jobids"], "should have job listed")
|
assert.Equal(t, []int64{1}, out1["jobids"], "should have job listed")
|
||||||
assert.Equal(t, []int64{1}, out1["running_ids"], "should have running job")
|
assert.Equal(t, []int64{1}, out1["runningIds"], "should have running job")
|
||||||
assert.Equal(t, []int64{}, out1["finished_ids"], "should not have finished job")
|
assert.Equal(t, []int64{}, out1["finishedIds"], "should not have finished job")
|
||||||
|
|
||||||
_, _, err = NewJob(ctx, longFn, rc.Params{"_async": true})
|
_, _, err = NewJob(ctx, longFn, rc.Params{"_async": true})
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
|
|||||||
Reference in New Issue
Block a user