Skip to content

Commit

Permalink
fix: Fixed not implemented guard for JWT auth
Browse files Browse the repository at this point in the history
  • Loading branch information
LotuxPunk committed Aug 31, 2024
1 parent 794d7ec commit 4c0fcb3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/main/kotlin/be/vandeas/logic/impl/AuthLogicImpl.kt
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,10 @@ class AuthLogicImpl(
override fun <T> guard(token: String, path: Path, protectedMethod: () -> T): T =
validateOneTimeToken(token, path).let { protectedMethod() }

override fun <T> guard(jwt: String, protectedMethod: () -> T): T {
TODO("Not yet implemented")
}
override fun <T> guard(jwt: String, protectedMethod: () -> T): T =
validateJwtToken(jwt).let {
protectedMethod()
}

override fun getJwtToken(apiKey: String, duration: Duration): String {
if (!validateApiKey(apiKey)) {
Expand Down
6 changes: 6 additions & 0 deletions src/test/kotlin/be/vandeas/v2/ApplicationTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import kotlinx.coroutines.delay
import kotlinx.coroutines.runBlocking
import java.util.*
import kotlin.io.path.toPath
import kotlin.test.BeforeTest
import kotlin.test.Test
import kotlin.test.assertEquals
import kotlin.time.Duration
Expand All @@ -38,6 +39,11 @@ class ApplicationTest {
}.body<Map<String, String>>()["token"]
}

@BeforeTest
fun setup() {
// DELETE ALL FILES FROM SCRATCH
}

@Test
fun `Should be able to write and read`() {
runBlocking {
Expand Down

0 comments on commit 4c0fcb3

Please sign in to comment.