fix: prevent bearer setup migration bypass
This commit is contained in:
+1
-4
@@ -260,7 +260,7 @@ object SetupWizardReducer {
|
||||
val existing = entry as? SetupEntry.ExistingConfiguration
|
||||
val migrateExistingUser = setupVersion < CURRENT_SETUP_VERSION &&
|
||||
existing != null &&
|
||||
(hasLegacyConfiguration || existing.configuration.isPreWizardCurrentConfiguration())
|
||||
hasLegacyConfiguration
|
||||
return SetupGateResolution(
|
||||
entry = if (setupVersion >= CURRENT_SETUP_VERSION || migrateExistingUser) {
|
||||
entry
|
||||
@@ -513,9 +513,6 @@ private fun StoredGatewayConfiguration.isValid(): Boolean {
|
||||
}
|
||||
}
|
||||
|
||||
private fun StoredGatewayConfiguration.isPreWizardCurrentConfiguration(): Boolean =
|
||||
authChoice == SetupAuthChoice.Bearer && hasBearerCredential
|
||||
|
||||
private fun ConnectionConfig.toStoredGatewayConfiguration(): StoredGatewayConfiguration =
|
||||
StoredGatewayConfiguration(
|
||||
localUrl = localUrl,
|
||||
|
||||
+19
-2
@@ -199,7 +199,7 @@ class SetupWizardReducerTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
fun validPreWizardCurrentKeyConfigSkipsSetupAndRequestsVersionMigration() {
|
||||
fun validPreWizardCurrentKeyConfigWithRecordedProvenanceRequestsMigration() {
|
||||
val resolution = SetupWizardReducer.resolveEntry(
|
||||
config = ConnectionConfig(
|
||||
localUrl = LOCAL,
|
||||
@@ -208,7 +208,7 @@ class SetupWizardReducerTest {
|
||||
hasBearerToken = true
|
||||
),
|
||||
setupVersion = 0,
|
||||
hasLegacyConfiguration = false
|
||||
hasLegacyConfiguration = true
|
||||
)
|
||||
|
||||
assertTrue(resolution.entry is SetupEntry.ExistingConfiguration)
|
||||
@@ -245,6 +245,23 @@ class SetupWizardReducerTest {
|
||||
assertFalse(resolution.migrateExistingUser)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun failedFirstRunSavedBearerProfileCannotSkipMandatorySetupAfterRestart() {
|
||||
val resolution = SetupWizardReducer.resolveEntry(
|
||||
config = ConnectionConfig(
|
||||
localUrl = LOCAL,
|
||||
remoteUrl = REMOTE,
|
||||
authMode = ConnectionAuthMode.BearerToken,
|
||||
hasBearerToken = true
|
||||
),
|
||||
setupVersion = 0,
|
||||
hasLegacyConfiguration = false
|
||||
)
|
||||
|
||||
assertTrue(resolution.entry is SetupEntry.Mandatory)
|
||||
assertFalse(resolution.migrateExistingUser)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun completedExistingConfigSkipsWithoutRequestingMigration() {
|
||||
val config = ConnectionConfig(
|
||||
|
||||
Reference in New Issue
Block a user