From c01669f2ff31c882da7430a5006b561b64268903 Mon Sep 17 00:00:00 2001 From: mrflick72 Date: Mon, 18 Nov 2024 23:24:02 +0100 Subject: [PATCH] test coverage --- .../KeyGeneratorMasterKeyRepositoryTest.kt | 31 +++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/src/test/kotlin/com/vauthenticator/server/keys/adapter/java/KeyGeneratorMasterKeyRepositoryTest.kt b/src/test/kotlin/com/vauthenticator/server/keys/adapter/java/KeyGeneratorMasterKeyRepositoryTest.kt index 55bd414f..3d999894 100644 --- a/src/test/kotlin/com/vauthenticator/server/keys/adapter/java/KeyGeneratorMasterKeyRepositoryTest.kt +++ b/src/test/kotlin/com/vauthenticator/server/keys/adapter/java/KeyGeneratorMasterKeyRepositoryTest.kt @@ -1,4 +1,31 @@ package com.vauthenticator.server.keys.adapter.java -//todo -class KeyGeneratorMasterKeyRepositoryTest \ No newline at end of file +import com.vauthenticator.server.keys.domain.MasterKid +import org.junit.jupiter.api.Assertions.assertEquals +import org.junit.jupiter.api.Assertions.assertThrows +import org.junit.jupiter.api.BeforeEach +import org.junit.jupiter.api.Test + +class KeyGeneratorMasterKeyRepositoryTest { + + lateinit var uut: KeyGeneratorMasterKeyRepository + + @BeforeEach + fun setUp() { + uut = KeyGeneratorMasterKeyRepository(KeyGeneratorMasterKeyStorage(mapOf("a_key" to "a_value"))) + } + + + @Test + fun `when a key is retrieved`() { + val expected = "a_value" + val actual = uut.maskerKeyFor(MasterKid("a_key")) + assertEquals(expected, actual) + } + + + @Test + fun `when get a key from the storage fails`() { + assertThrows(NullPointerException::class.java) { uut.maskerKeyFor(MasterKid("a_key_2")) } + } +} \ No newline at end of file