PM-12733: Trim totp codes before saving them (#4315)

This commit is contained in:
David Perez 2024-11-18 09:05:00 -06:00 committed by GitHub
parent e90bd136f6
commit ffeae93728
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 2 additions and 3 deletions

View file

@ -46,7 +46,7 @@ class ManualCodeEntryViewModel @Inject constructor(
} }
private fun handleCodeSubmit() { private fun handleCodeSubmit() {
vaultRepository.emitTotpCodeResult(TotpCodeResult.Success(state.code)) vaultRepository.emitTotpCodeResult(TotpCodeResult.Success(state.code.trim()))
sendEvent(ManualCodeEntryEvent.NavigateBack) sendEvent(ManualCodeEntryEvent.NavigateBack)
} }

View file

@ -36,8 +36,7 @@ class ManualCodeEntryViewModelTests : BaseViewModelTest() {
@Test @Test
fun `CodeSubmit should emit new code and NavigateBack`() = runTest { fun `CodeSubmit should emit new code and NavigateBack`() = runTest {
val viewModel = val viewModel = createViewModel(initialState = ManualCodeEntryState(" TestCode "))
createViewModel(initialState = ManualCodeEntryState("TestCode"))
viewModel.eventFlow.test { viewModel.eventFlow.test {
viewModel.trySendAction(ManualCodeEntryAction.CodeSubmit) viewModel.trySendAction(ManualCodeEntryAction.CodeSubmit)