mirror of
https://github.com/Yubico/yubioath-flutter.git
synced 2024-12-23 18:22:39 +03:00
update unit tests
This commit is contained in:
parent
9a19a9c608
commit
4490547e2d
@ -17,6 +17,7 @@
|
|||||||
package com.yubico.authenticator.oath
|
package com.yubico.authenticator.oath
|
||||||
|
|
||||||
import androidx.arch.core.executor.testing.InstantTaskExecutorRule
|
import androidx.arch.core.executor.testing.InstantTaskExecutorRule
|
||||||
|
import com.yubico.authenticator.ViewModelData
|
||||||
import com.yubico.authenticator.device.Version
|
import com.yubico.authenticator.device.Version
|
||||||
import com.yubico.authenticator.oath.OathTestHelper.code
|
import com.yubico.authenticator.oath.OathTestHelper.code
|
||||||
import com.yubico.authenticator.oath.OathTestHelper.emptyCredentials
|
import com.yubico.authenticator.oath.OathTestHelper.emptyCredentials
|
||||||
@ -40,13 +41,12 @@ class ModelTest {
|
|||||||
private fun connectDevice(deviceId: String) {
|
private fun connectDevice(deviceId: String) {
|
||||||
viewModel.setSessionState(
|
viewModel.setSessionState(
|
||||||
Session(
|
Session(
|
||||||
deviceId,
|
deviceId,
|
||||||
Version(1, 2, 3),
|
Version(1, 2, 3),
|
||||||
isAccessKeySet = false,
|
isAccessKeySet = false,
|
||||||
isRemembered = false,
|
isRemembered = false,
|
||||||
isLocked = false,
|
isLocked = false
|
||||||
initialized = true
|
)
|
||||||
)
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -117,7 +117,7 @@ class ModelTest {
|
|||||||
|
|
||||||
viewModel.updateCredentials(m2)
|
viewModel.updateCredentials(m2)
|
||||||
|
|
||||||
assertEquals("device1", viewModel.sessionState.value?.deviceId)
|
assertEquals("device1", viewModel.currentSession()?.deviceId)
|
||||||
assertEquals(3, viewModel.credentials.value!!.size)
|
assertEquals(3, viewModel.credentials.value!!.size)
|
||||||
assertTrue(viewModel.credentials.value!!.find { it.credential == cred1 } != null)
|
assertTrue(viewModel.credentials.value!!.find { it.credential == cred1 } != null)
|
||||||
assertTrue(viewModel.credentials.value!!.find { it.credential == cred2 } != null)
|
assertTrue(viewModel.credentials.value!!.find { it.credential == cred2 } != null)
|
||||||
@ -388,9 +388,9 @@ class ModelTest {
|
|||||||
val deviceId = "device"
|
val deviceId = "device"
|
||||||
connectDevice(deviceId)
|
connectDevice(deviceId)
|
||||||
viewModel.updateCredentials(mapOf(totp() to code()))
|
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)
|
assertNull(viewModel.credentials.value)
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -40,8 +40,7 @@ class SerializationTest {
|
|||||||
Version(1, 2, 3),
|
Version(1, 2, 3),
|
||||||
isAccessKeySet = false,
|
isAccessKeySet = false,
|
||||||
isRemembered = false,
|
isRemembered = false,
|
||||||
isLocked = false,
|
isLocked = false
|
||||||
initialized = true
|
|
||||||
)
|
)
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
Loading…
Reference in New Issue
Block a user