mirror of
https://github.com/rclone/rclone.git
synced 2024-11-07 09:04:52 +01:00
seafile: fix error when not configured for 2fa (#5665)
This commit is contained in:
parent
eb0c8284f1
commit
b085aa1a3f
@ -310,7 +310,8 @@ func Config(ctx context.Context, name string, m configmap.Mapper, config fs.Conf
|
||||
|
||||
is2faEnabled, _ := m.Get(config2FA)
|
||||
if is2faEnabled != "true" {
|
||||
return nil, errors.New("two-factor authentication is not enabled on this account")
|
||||
// no need to do anything here
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
username, _ := m.Get(configUser)
|
||||
|
@ -136,6 +136,7 @@ func Test2FAStateMachine(t *testing.T) {
|
||||
expectErrorMessage string
|
||||
expectResult string
|
||||
expectFail bool
|
||||
expectNil bool
|
||||
}{
|
||||
{
|
||||
name: "no url",
|
||||
@ -143,18 +144,18 @@ func Test2FAStateMachine(t *testing.T) {
|
||||
input: fs.ConfigIn{State: ""},
|
||||
expectFail: true,
|
||||
},
|
||||
{
|
||||
name: "2fa not set",
|
||||
mapper: configmap.Simple{"url": "http://localhost/"},
|
||||
input: fs.ConfigIn{State: ""},
|
||||
expectFail: true,
|
||||
},
|
||||
{
|
||||
name: "unknown state",
|
||||
mapper: configmap.Simple{"url": "http://localhost/", "2fa": "true", "user": "username"},
|
||||
input: fs.ConfigIn{State: "unknown"},
|
||||
expectFail: true,
|
||||
},
|
||||
{
|
||||
name: "2fa not set",
|
||||
mapper: configmap.Simple{"url": "http://localhost/"},
|
||||
input: fs.ConfigIn{State: ""},
|
||||
expectNil: true,
|
||||
},
|
||||
{
|
||||
name: "no password in config",
|
||||
mapper: configmap.Simple{"url": "http://localhost/", "2fa": "true", "user": "username"},
|
||||
@ -215,6 +216,10 @@ func Test2FAStateMachine(t *testing.T) {
|
||||
t.Log(err)
|
||||
return
|
||||
}
|
||||
if fixture.expectNil {
|
||||
require.Nil(t, output)
|
||||
return
|
||||
}
|
||||
assert.Equal(t, fixture.expectState, output.State)
|
||||
assert.Equal(t, fixture.expectErrorMessage, output.Error)
|
||||
assert.Equal(t, fixture.expectResult, output.Result)
|
||||
|
Loading…
Reference in New Issue
Block a user