Skip to content

Commit

Permalink
add test for default session duration
Browse files Browse the repository at this point in the history
  • Loading branch information
elefantel committed Jul 10, 2024
1 parent 523b5d0 commit 6afb3b9
Showing 1 changed file with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,25 @@ import org.junit.Before
import org.junit.Test

class SessionManagerTests {
private val testFile = "testFile"
private val sessionConfigFile: String = "SESSION_CONFIG_FILE"
private lateinit var keyStorage: SecureStorage
private lateinit var sessionManager: SessionManager
@Before
fun setUp() {
keyStorage = MockKeyStorage()
keyStorage.clear(testFile)
sessionManager = SessionManager(store = keyStorage, 7 * 24 * 3600, logger = TestLogger)
keyStorage.clear(sessionConfigFile)
sessionManager = SessionManager(store = keyStorage, logger = TestLogger)
}
@Test
fun testInitLoadsSessionConfig() = runTest {
assertNotNull(sessionManager.sessionId)
}
@Test
fun testDefaultSessionDuration() = runTest {
val sessionConfig = sessionManager.getSessionConfig()
val defaultDuration = 30 * 24 * 3600L // 30 days
assertEquals(sessionConfig.expiryDate, System.currentTimeMillis() + defaultDuration * 1000)
}
@OptIn(ExperimentalCoroutinesApi::class)
@Test
fun testUpdateSessionDuration() = runTest {
Expand Down

0 comments on commit 6afb3b9

Please sign in to comment.