implemented 07-server-mode.md: added server profile with REST API for builds, artifacts, live logs, and control tokens; lifecycle management for watcher; controller and service tests

This commit is contained in:
Michael Hoennig
2026-07-07 11:27:27 +02:00
parent a1db450bdb
commit 490914de0b
25 changed files with 1128 additions and 6 deletions
@@ -0,0 +1,42 @@
package de.hoennig.gittally.server
import io.kotest.core.spec.style.FunSpec
import io.kotest.matchers.shouldBe
import io.kotest.matchers.string.shouldMatch
import java.nio.file.Files
import java.nio.file.Path
class ControlTokenServiceTest : FunSpec() {
private fun newTokenFile(): Path = Files.createTempDirectory("gittally-token-test").resolve("control-token")
init {
test("generates a hex token once and persists it") {
val tokenFile = newTokenFile()
val service = ControlTokenService(tokenFile)
val token = service.token()
token shouldMatch Regex("[0-9a-f]{48}")
Files.readString(tokenFile).trim() shouldBe token
service.token() shouldBe token
}
test("reuses an operator-provided token file") {
val tokenFile = newTokenFile()
Files.createDirectories(tokenFile.parent)
Files.writeString(tokenFile, "my-own-token\n")
ControlTokenService(tokenFile).token() shouldBe "my-own-token"
}
test("matches only the exact token") {
val service = ControlTokenService(newTokenFile())
val token = service.token()
service.matches(token) shouldBe true
service.matches(token + "x") shouldBe false
service.matches("") shouldBe false
service.matches(null) shouldBe false
}
}
}