fix: migrate pre-wizard gateway profiles
This commit is contained in:
+6
-3
@@ -257,10 +257,10 @@ object SetupWizardReducer {
|
||||
hasLegacyConfiguration: Boolean
|
||||
): SetupGateResolution {
|
||||
val entry = entry(config)
|
||||
val existing = entry is SetupEntry.ExistingConfiguration
|
||||
val existing = entry as? SetupEntry.ExistingConfiguration
|
||||
val migrateExistingUser = setupVersion < CURRENT_SETUP_VERSION &&
|
||||
hasLegacyConfiguration &&
|
||||
existing
|
||||
existing != null &&
|
||||
(hasLegacyConfiguration || existing.configuration.isPreWizardCurrentConfiguration())
|
||||
return SetupGateResolution(
|
||||
entry = if (setupVersion >= CURRENT_SETUP_VERSION || migrateExistingUser) {
|
||||
entry
|
||||
@@ -513,6 +513,9 @@ private fun StoredGatewayConfiguration.isValid(): Boolean {
|
||||
}
|
||||
}
|
||||
|
||||
private fun StoredGatewayConfiguration.isPreWizardCurrentConfiguration(): Boolean =
|
||||
authChoice == SetupAuthChoice.Bearer && hasBearerCredential
|
||||
|
||||
private fun ConnectionConfig.toStoredGatewayConfiguration(): StoredGatewayConfiguration =
|
||||
StoredGatewayConfiguration(
|
||||
localUrl = localUrl,
|
||||
|
||||
+17
@@ -198,6 +198,23 @@ class SetupWizardReducerTest {
|
||||
assertTrue(editState.canExit)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun validPreWizardCurrentKeyConfigSkipsSetupAndRequestsVersionMigration() {
|
||||
val resolution = SetupWizardReducer.resolveEntry(
|
||||
config = ConnectionConfig(
|
||||
localUrl = LOCAL,
|
||||
remoteUrl = REMOTE,
|
||||
authMode = ConnectionAuthMode.BearerToken,
|
||||
hasBearerToken = true
|
||||
),
|
||||
setupVersion = 0,
|
||||
hasLegacyConfiguration = false
|
||||
)
|
||||
|
||||
assertTrue(resolution.entry is SetupEntry.ExistingConfiguration)
|
||||
assertTrue(resolution.migrateExistingUser)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun migrationNeverTurnsInvalidLegacyConfigIntoCompletedSetup() {
|
||||
val resolution = SetupWizardReducer.resolveEntry(
|
||||
|
||||
Reference in New Issue
Block a user