Add VaultSdkSource.derivePinKey (#609)

This commit is contained in:
Brian Yencho
2024-01-14 14:32:43 -06:00
committed by GitHub
parent c7c96e4d2f
commit cd295c4a3a
3 changed files with 47 additions and 0 deletions

View File

@@ -5,6 +5,7 @@ import com.bitwarden.core.CipherListView
import com.bitwarden.core.CipherView
import com.bitwarden.core.Collection
import com.bitwarden.core.CollectionView
import com.bitwarden.core.DerivePinKeyResponse
import com.bitwarden.core.Folder
import com.bitwarden.core.FolderView
import com.bitwarden.core.InitOrgCryptoRequest
@@ -60,6 +61,28 @@ class VaultSdkSourceTest {
verify { sdkClientManager.destroyClient(userId = userId) }
}
@Test
fun `derivePinKey should call SDK and return a Result with the correct data`() = runBlocking {
val userId = "userId"
val pin = "pin"
val expectedResult = mockk<DerivePinKeyResponse>()
coEvery {
clientCrypto.derivePinKey(pin = pin)
} returns expectedResult
val result = vaultSdkSource.derivePinKey(
userId = userId,
pin = pin,
)
assertEquals(
expectedResult.asSuccess(),
result,
)
coVerify {
clientCrypto.derivePinKey(pin)
}
verify { sdkClientManager.getOrCreateClient(userId = userId) }
}
@Test
fun `getUserEncryptionKey should call SDK and return a Result with correct data`() =
runBlocking {