-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
108 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 48 additions & 1 deletion
49
src/test/kotlin/com/vauthenticator/server/ticket/TicketCreatorTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,53 @@ | ||
package com.vauthenticator.server.ticket | ||
|
||
import com.vauthenticator.server.clientapp.ClientAppFixture | ||
import com.vauthenticator.server.extentions.expirationTimeStampInSecondFromNow | ||
import com.vauthenticator.server.support.AccountTestFixture | ||
import io.mockk.every | ||
import io.mockk.impl.annotations.MockK | ||
import io.mockk.junit5.MockKExtension | ||
import io.mockk.just | ||
import io.mockk.runs | ||
import org.junit.jupiter.api.Assertions.assertEquals | ||
import org.junit.jupiter.api.Test | ||
import org.junit.jupiter.api.extension.ExtendWith | ||
import java.time.Clock | ||
import java.time.Duration | ||
import java.time.Instant | ||
import java.time.ZoneId | ||
|
||
private const val TICKET_ID = "A_TICKET_ID" | ||
|
||
@ExtendWith(MockKExtension::class) | ||
class TicketCreatorTest { | ||
private val ticketGenerator = { TICKET_ID } | ||
private val now = Instant.now() | ||
private val clock: Clock = Clock.fixed(now, ZoneId.systemDefault()) | ||
|
||
@MockK | ||
private lateinit var ticketRepository: TicketRepository | ||
|
||
private val ticketFeatures: TicketFeatures = TicketFeatures(Duration.ofSeconds(100)) | ||
private val clientAppId = ClientAppFixture.aClientAppId() | ||
private val account = AccountTestFixture.anAccount() | ||
private val ticket = Ticket( | ||
TicketId(TICKET_ID), | ||
account.email, | ||
clientAppId.content, | ||
ticketFeatures.ttl.expirationTimeStampInSecondFromNow(clock), | ||
TicketContext.empty() | ||
) | ||
|
||
@Test | ||
fun `happy path`() { | ||
|
||
val uut = TicketCreator(ticketGenerator, clock, ticketRepository, ticketFeatures) | ||
|
||
every { ticketRepository.store(ticket) } just runs | ||
|
||
val createTicketFor = | ||
uut.createTicketFor(account, clientAppId, TicketContext.empty()) | ||
|
||
//TODO | ||
assertEquals(TICKET_ID, createTicketFor.content) | ||
} | ||
} |