update unit tests

This commit is contained in:
Adam Velebil 2024-03-13 11:14:11 +01:00
parent 9a19a9c608
commit 4490547e2d
No known key found for this signature in database
GPG Key ID: C9B1E4A3CBBD2E10
2 changed files with 11 additions and 12 deletions

View File

@ -17,6 +17,7 @@
package com.yubico.authenticator.oath
import androidx.arch.core.executor.testing.InstantTaskExecutorRule
import com.yubico.authenticator.ViewModelData
import com.yubico.authenticator.device.Version
import com.yubico.authenticator.oath.OathTestHelper.code
import com.yubico.authenticator.oath.OathTestHelper.emptyCredentials
@ -44,8 +45,7 @@ class ModelTest {
Version(1, 2, 3),
isAccessKeySet = false,
isRemembered = false,
isLocked = false,
initialized = true
isLocked = false
)
)
}
@ -117,7 +117,7 @@ class ModelTest {
viewModel.updateCredentials(m2)
assertEquals("device1", viewModel.sessionState.value?.deviceId)
assertEquals("device1", viewModel.currentSession()?.deviceId)
assertEquals(3, viewModel.credentials.value!!.size)
assertTrue(viewModel.credentials.value!!.find { it.credential == cred1 } != null)
assertTrue(viewModel.credentials.value!!.find { it.credential == cred2 } != null)
@ -388,9 +388,9 @@ class ModelTest {
val deviceId = "device"
connectDevice(deviceId)
viewModel.updateCredentials(mapOf(totp() to code()))
viewModel.setSessionState(null)
viewModel.clearSession()
assertNull(viewModel.sessionState.value)
assertEquals(ViewModelData.Empty, viewModel.sessionState.value)
assertNull(viewModel.credentials.value)
}
}

View File

@ -40,8 +40,7 @@ class SerializationTest {
Version(1, 2, 3),
isAccessKeySet = false,
isRemembered = false,
isLocked = false,
initialized = true
isLocked = false
)
@Test