mirror of
https://github.com/android-password-store/Android-Password-Store
synced 2025-08-29 13:27:46 +00:00
app: migrate XkPasswd users to Diceware
This commit is contained in:
parent
a0a8200393
commit
17860407f9
@ -25,6 +25,7 @@ fun runMigrations(filesDirPath: String, sharedPrefs: SharedPreferences, gitSetti
|
|||||||
migrateToHideAll(sharedPrefs)
|
migrateToHideAll(sharedPrefs)
|
||||||
migrateToSshKey(filesDirPath, sharedPrefs)
|
migrateToSshKey(filesDirPath, sharedPrefs)
|
||||||
migrateToClipboardHistory(sharedPrefs)
|
migrateToClipboardHistory(sharedPrefs)
|
||||||
|
migrateToDiceware(sharedPrefs)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun migrateToGitUrlBasedConfig(sharedPrefs: SharedPreferences, gitSettings: GitSettings) {
|
private fun migrateToGitUrlBasedConfig(sharedPrefs: SharedPreferences, gitSettings: GitSettings) {
|
||||||
@ -121,3 +122,13 @@ private fun migrateToClipboardHistory(sharedPrefs: SharedPreferences) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun migrateToDiceware(sharedPrefs: SharedPreferences) {
|
||||||
|
if (sharedPrefs.contains(PreferenceKeys.PREF_KEY_PWGEN_TYPE)) {
|
||||||
|
sharedPrefs.edit {
|
||||||
|
if (sharedPrefs.getString(PreferenceKeys.PREF_KEY_PWGEN_TYPE) == "xkpasswd") {
|
||||||
|
putString(PreferenceKeys.PREF_KEY_PWGEN_TYPE, "diceware")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -155,4 +155,32 @@ class MigrationsTest {
|
|||||||
assertEquals(true, sharedPrefs.getBoolean(PreferenceKeys.CLEAR_CLIPBOARD_HISTORY, false))
|
assertEquals(true, sharedPrefs.getBoolean(PreferenceKeys.CLEAR_CLIPBOARD_HISTORY, false))
|
||||||
assertFalse(sharedPrefs.contains(PreferenceKeys.CLEAR_CLIPBOARD_20X))
|
assertFalse(sharedPrefs.contains(PreferenceKeys.CLEAR_CLIPBOARD_20X))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun verifyClassicPasswordGeneratorMigration() {
|
||||||
|
sharedPrefs.edit {
|
||||||
|
clear()
|
||||||
|
putString(PreferenceKeys.PREF_KEY_PWGEN_TYPE, "classic")
|
||||||
|
}
|
||||||
|
runMigrations(
|
||||||
|
filesDir,
|
||||||
|
sharedPrefs,
|
||||||
|
GitSettings(sharedPrefs, encryptedSharedPreferences, proxySharedPreferences, filesDir),
|
||||||
|
)
|
||||||
|
assertEquals("classic", sharedPrefs.getString(PreferenceKeys.PREF_KEY_PWGEN_TYPE))
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun verifyXkPasswdPasswordGeneratorMigration() {
|
||||||
|
sharedPrefs.edit {
|
||||||
|
clear()
|
||||||
|
putString(PreferenceKeys.PREF_KEY_PWGEN_TYPE, "xkpasswd")
|
||||||
|
}
|
||||||
|
runMigrations(
|
||||||
|
filesDir,
|
||||||
|
sharedPrefs,
|
||||||
|
GitSettings(sharedPrefs, encryptedSharedPreferences, proxySharedPreferences, filesDir),
|
||||||
|
)
|
||||||
|
assertEquals("diceware", sharedPrefs.getString(PreferenceKeys.PREF_KEY_PWGEN_TYPE))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user