chore_: remove deprecated `CreateAccount.BackupDisabledDataDir` (#5664)

* chore_: remove deprecated CreateAccount.BackupDisabledDataDir

* test_: cover ErrCreateAccountInvalidRootDataDir
This commit is contained in:
Igor Sirotin 2024-08-07 13:59:43 +01:00 committed by GitHub
parent 2f5437130e
commit eeb34f780f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 12 additions and 24 deletions

View File

@ -1737,11 +1737,11 @@ func TestRestoreAccountAndLogin(t *testing.T) {
Mnemonic: "test test test test test test test test test test test test",
FetchBackup: false,
CreateAccount: requests.CreateAccount{
DisplayName: "Account1",
DeviceName: "StatusIM",
Password: "password",
CustomizationColor: "0x000000",
BackupDisabledDataDir: tmpdir,
DisplayName: "Account1",
DeviceName: "StatusIM",
Password: "password",
CustomizationColor: "0x000000",
RootDataDir: tmpdir,
},
}
account, err := backend.RestoreAccountAndLogin(restoreRequest)
@ -1778,10 +1778,8 @@ func TestCreateAccountPathsValidation(t *testing.T) {
require.NoError(t, err)
request.RootDataDir = ""
request.BackupDisabledDataDir = tmpdir
err = request.Validate(validation)
require.NoError(t, err)
require.Equal(t, tmpdir, request.RootDataDir)
require.ErrorIs(t, err, requests.ErrCreateAccountInvalidRootDataDir)
}
func TestRestoreKeycardAccountAndLogin(t *testing.T) {

View File

@ -204,11 +204,11 @@ func main() {
Mnemonic: *seedPhrase,
FetchBackup: false,
CreateAccount: requests.CreateAccount{
DisplayName: "Account1",
DeviceName: "StatusIM",
Password: *password,
CustomizationColor: "0x000000",
BackupDisabledDataDir: config.DataDir,
DisplayName: "Account1",
DeviceName: "StatusIM",
Password: *password,
CustomizationColor: "0x000000",
RootDataDir: config.DataDir,
APIConfig: &requests.APIConfig{
ConnectorEnabled: config.ClusterConfig.Enabled,
HTTPEnabled: config.HTTPEnabled,

View File

@ -33,10 +33,6 @@ type APIConfig struct {
}
type CreateAccount struct {
// Deprecated: BackupDisabledDataDir is the directory where backup is disabled
// Use `RootDataDir` instead. Effective BackupDisabledDataDir value will default to RootDataDir + "./".
BackupDisabledDataDir string `json:"backupDisabledDataDir"`
// RootDataDir is an absolute path to the root directory where all data will be stored.
RootDataDir string `json:"rootDataDir"`
KdfIterations int `json:"kdfIterations"`
@ -134,13 +130,7 @@ func (c *CreateAccount) Validate(validation *CreateAccountValidation) error {
}
if len(c.RootDataDir) == 0 {
if c.BackupDisabledDataDir == "" {
return ErrCreateAccountInvalidRootDataDir
}
// NOTE: Fallback to old BackupDisabledDataDir field.
// Remove this when both desktop and mobile use the new `RootDataDir` field.
// Return error if `RootDataDir` is empty.
c.RootDataDir = c.BackupDisabledDataDir
return ErrCreateAccountInvalidRootDataDir
}
return nil