Skip to content

"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files

seafile: fix error when not configured for 2fa (#5665)

Fredb085aa1a3f6e
diff --git a/backend/seafile/seafile.go b/backend/seafile/seafile.go
index 70f3730bd..3445c6e3b 100644
--- a/backend/seafile/seafile.go
+++ b/backend/seafile/seafile.go
@@ -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)
diff --git a/backend/seafile/seafile_internal_test.go b/backend/seafile/seafile_internal_test.go
index 53c7a3042..c8e3c7410 100644
--- a/backend/seafile/seafile_internal_test.go
+++ b/backend/seafile/seafile_internal_test.go
@@ -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)