mirror of
https://github.com/rclone/rclone.git
synced 2024-12-23 07:29:35 +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)
|
is2faEnabled, _ := m.Get(config2FA)
|
||||||
if is2faEnabled != "true" {
|
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)
|
username, _ := m.Get(configUser)
|
||||||
|
@ -136,6 +136,7 @@ func Test2FAStateMachine(t *testing.T) {
|
|||||||
expectErrorMessage string
|
expectErrorMessage string
|
||||||
expectResult string
|
expectResult string
|
||||||
expectFail bool
|
expectFail bool
|
||||||
|
expectNil bool
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
name: "no url",
|
name: "no url",
|
||||||
@ -143,18 +144,18 @@ func Test2FAStateMachine(t *testing.T) {
|
|||||||
input: fs.ConfigIn{State: ""},
|
input: fs.ConfigIn{State: ""},
|
||||||
expectFail: true,
|
expectFail: true,
|
||||||
},
|
},
|
||||||
{
|
|
||||||
name: "2fa not set",
|
|
||||||
mapper: configmap.Simple{"url": "http://localhost/"},
|
|
||||||
input: fs.ConfigIn{State: ""},
|
|
||||||
expectFail: true,
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
name: "unknown state",
|
name: "unknown state",
|
||||||
mapper: configmap.Simple{"url": "http://localhost/", "2fa": "true", "user": "username"},
|
mapper: configmap.Simple{"url": "http://localhost/", "2fa": "true", "user": "username"},
|
||||||
input: fs.ConfigIn{State: "unknown"},
|
input: fs.ConfigIn{State: "unknown"},
|
||||||
expectFail: true,
|
expectFail: true,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "2fa not set",
|
||||||
|
mapper: configmap.Simple{"url": "http://localhost/"},
|
||||||
|
input: fs.ConfigIn{State: ""},
|
||||||
|
expectNil: true,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: "no password in config",
|
name: "no password in config",
|
||||||
mapper: configmap.Simple{"url": "http://localhost/", "2fa": "true", "user": "username"},
|
mapper: configmap.Simple{"url": "http://localhost/", "2fa": "true", "user": "username"},
|
||||||
@ -215,6 +216,10 @@ func Test2FAStateMachine(t *testing.T) {
|
|||||||
t.Log(err)
|
t.Log(err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if fixture.expectNil {
|
||||||
|
require.Nil(t, output)
|
||||||
|
return
|
||||||
|
}
|
||||||
assert.Equal(t, fixture.expectState, output.State)
|
assert.Equal(t, fixture.expectState, output.State)
|
||||||
assert.Equal(t, fixture.expectErrorMessage, output.Error)
|
assert.Equal(t, fixture.expectErrorMessage, output.Error)
|
||||||
assert.Equal(t, fixture.expectResult, output.Result)
|
assert.Equal(t, fixture.expectResult, output.Result)
|
||||||
|
Loading…
Reference in New Issue
Block a user