Overlooked this

This commit is contained in:
Minecon724 2025-10-03 17:40:57 +02:00
commit dc8579674f
Signed by untrusted user who does not match committer: m724
GPG key ID: A02E6E67AB961189
3 changed files with 9 additions and 10 deletions

View file

@ -3,7 +3,6 @@ package eu.m724.bsk2.builder.config.parser
import eu.m724.bsk2.builder.config.data.RenderConfiguration
import eu.m724.bsk2.builder.config.data.SiteConfiguration
import eu.m724.bsk2.builder.config.data.WorkspaceConfiguration
import eu.m724.bsk2.builder.config.parser.YamlConfigurationParser
import kotlinx.serialization.SerializationException
import org.junit.jupiter.api.Assertions.assertThrows
import org.junit.jupiter.api.BeforeEach

View file

@ -5,7 +5,7 @@ import eu.m724.bsk2.builder.FileSystem
import eu.m724.bsk2.builder.post.data.PostMeta
import io.mockk.*
import org.junit.jupiter.api.AfterEach
import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.Assertions.assertThrows
import org.junit.jupiter.api.BeforeEach
import java.nio.file.Path
import java.nio.file.Paths
@ -78,7 +78,7 @@ class PostLoaderTest {
fun `getPost should throw YamlException on invalid meta YML file and not cache the failure`() {
everyMetaYmlRead("invalid") returns "Totally invalid"
repeat(3) { Assertions.assertThrows(YamlException::class.java) { loader.getMeta("invalid") } }
repeat(3) { assertThrows(YamlException::class.java) { loader.getMeta("invalid") } }
// ensure not cached
verify(exactly = 3) { fileSystem.readText("invalid".toMetaYmlPath()) }
@ -88,7 +88,7 @@ class PostLoaderTest {
fun `getPost should throw NoSuchFileException and not cache the failure`() {
everyMetaYmlRead("non existent") throws NoSuchFileException("non existent".toMetaYmlPath().toFile())
repeat(3) { Assertions.assertThrows(NoSuchFileException::class.java) { loader.getMeta("non existent") } }
repeat(3) { assertThrows(NoSuchFileException::class.java) { loader.getMeta("non existent") } }
// ensure not cached
verify(exactly = 3) { fileSystem.readText("non existent".toMetaYmlPath()) }
@ -96,7 +96,7 @@ class PostLoaderTest {
@Test
fun `getPost should throw IllegalArgumentException for path traversal attempts`() {
Assertions.assertThrows(IllegalArgumentException::class.java) { loader.getMeta("../traversed") }
assertThrows(IllegalArgumentException::class.java) { loader.getMeta("../traversed") }
// while not necessary, here for explicitness
verify(exactly = 0) { fileSystem.readText(any()) }

View file

@ -3,7 +3,7 @@ package eu.m724.bsk2.builder.template.loader
import eu.m724.bsk2.builder.FileSystem
import io.mockk.*
import org.junit.jupiter.api.AfterEach
import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.Assertions.assertThrows
import org.junit.jupiter.api.BeforeEach
import java.nio.file.Path
import java.nio.file.Paths
@ -11,7 +11,7 @@ import kotlin.io.path.div
import kotlin.test.Test
import kotlin.test.assertEquals
class emplateLoaderTest {
class TemplateLoaderTest {
private companion object {
val ROOT_PATH: Path = Paths.get("workspace", "template")
const val POST_TEMPLATE_TEXT = "This is the post template"
@ -65,17 +65,17 @@ class emplateLoaderTest {
fun `getHtml should throw NoSuchFileException and not cache the failure`() {
everyHtmlTemplateRead("non existent") throws NoSuchFileException("non existent".toHtmlTemplatePath().toFile())
Assertions.assertThrows(NoSuchFileException::class.java) { loader.getHtml("non existent") }
assertThrows(NoSuchFileException::class.java) { loader.getHtml("non existent") }
// ensure that the result is not cached
Assertions.assertThrows(NoSuchFileException::class.java) { loader.getHtml("non existent") }
assertThrows(NoSuchFileException::class.java) { loader.getHtml("non existent") }
verify(exactly = 2) { fileSystem.readText("non existent".toHtmlTemplatePath()) }
}
@Test
fun `getHtml should throw IllegalArgumentException for path traversal attempts`() {
Assertions.assertThrows(IllegalArgumentException::class.java) {
assertThrows(IllegalArgumentException::class.java) {
loader.getHtml("../traversed")
}