From 4490547e2d2251daaa6e9f7d091c083229b7e880 Mon Sep 17 00:00:00 2001 From: Adam Velebil Date: Wed, 13 Mar 2024 11:14:11 +0100 Subject: [PATCH] update unit tests --- .../yubico/authenticator/oath/ModelTest.kt | 20 +++++++++---------- .../authenticator/oath/SerializationTest.kt | 3 +-- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/android/app/src/test/java/com/yubico/authenticator/oath/ModelTest.kt b/android/app/src/test/java/com/yubico/authenticator/oath/ModelTest.kt index 22b23889..98abb2a2 100644 --- a/android/app/src/test/java/com/yubico/authenticator/oath/ModelTest.kt +++ b/android/app/src/test/java/com/yubico/authenticator/oath/ModelTest.kt @@ -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 @@ -40,13 +41,12 @@ class ModelTest { private fun connectDevice(deviceId: String) { viewModel.setSessionState( Session( - deviceId, - Version(1, 2, 3), - isAccessKeySet = false, - isRemembered = false, - isLocked = false, - initialized = true - ) + deviceId, + Version(1, 2, 3), + isAccessKeySet = false, + isRemembered = false, + 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) } } \ No newline at end of file diff --git a/android/app/src/test/java/com/yubico/authenticator/oath/SerializationTest.kt b/android/app/src/test/java/com/yubico/authenticator/oath/SerializationTest.kt index 6fde4bcf..0c833721 100644 --- a/android/app/src/test/java/com/yubico/authenticator/oath/SerializationTest.kt +++ b/android/app/src/test/java/com/yubico/authenticator/oath/SerializationTest.kt @@ -40,8 +40,7 @@ class SerializationTest { Version(1, 2, 3), isAccessKeySet = false, isRemembered = false, - isLocked = false, - initialized = true + isLocked = false ) @Test