Skip to content

Commit

Permalink
small refactor move the every step in the setup
Browse files Browse the repository at this point in the history
  • Loading branch information
mrFlick72 committed Nov 25, 2024
1 parent 050e16a commit 0ebdb61
Showing 1 changed file with 3 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,17 @@ abstract class AbstractMfaAccountMethodsRepositoryTest {
lateinit var uut: MfaAccountMethodsRepository
abstract fun initMfaAccountMethodsRepository(): MfaAccountMethodsRepository
abstract fun resetDatabase()

@BeforeEach
fun setUp() {
every { keyRepository.createKeyFrom(masterKid, KeyType.SYMMETRIC, KeyPurpose.MFA) } returns key

resetDatabase()
uut = initMfaAccountMethodsRepository()
}

@Test
fun `when a mfa account method is stored`() {
whenAKeyIsStored()

uut.save(email, MfaMethod.EMAIL_MFA_METHOD, email, true)
val mfaAccountMethods = uut.findAll(email)
assertEquals(
Expand Down Expand Up @@ -86,7 +86,6 @@ abstract class AbstractMfaAccountMethodsRepositoryTest {

@Test
fun `when decide what mfa use as default`() {
whenAKeyIsStored()
uut.save(email, MfaMethod.EMAIL_MFA_METHOD, email, true)

val expected = Optional.of(mfaDeviceId)
Expand All @@ -98,8 +97,6 @@ abstract class AbstractMfaAccountMethodsRepositoryTest {

@Test
fun `when a mfa account method is stored and then enabled`() {
whenAKeyIsStored()

uut.save(email, MfaMethod.EMAIL_MFA_METHOD, email, false)
val beforeToBeAssociated = uut.findBy(email, MfaMethod.EMAIL_MFA_METHOD, email).get()

Expand All @@ -110,13 +107,10 @@ abstract class AbstractMfaAccountMethodsRepositoryTest {
assertEquals(afterAssociated.mfaDeviceId, beforeToBeAssociated.mfaDeviceId)
assertEquals(afterAssociated.mfaChannel, beforeToBeAssociated.mfaChannel)
assertEquals(afterAssociated.mfaMethod, beforeToBeAssociated.mfaMethod)
assertEquals(beforeToBeAssociated.associated,false)
assertEquals(beforeToBeAssociated.associated, false)
assertEquals(afterAssociated.associated, true)
assertEquals(afterAssociated.key, beforeToBeAssociated.key)
assertEquals(afterAssociated.userName, beforeToBeAssociated.userName)
}

private fun whenAKeyIsStored() {
every { keyRepository.createKeyFrom(masterKid, KeyType.SYMMETRIC, KeyPurpose.MFA) } returns key
}
}

0 comments on commit 0ebdb61

Please sign in to comment.