diff --git a/.fleet/run.json b/.fleet/run.json index 1f631a49..b3f28c35 100644 --- a/.fleet/run.json +++ b/.fleet/run.json @@ -5,7 +5,7 @@ "type": "gradle", "workingDir": "$PROJECT_DIR$", "tasks": [ - ":server:build" + ":admin-server:build" ], "args": [ "" diff --git a/admin-server/README.md b/admin-server/README.md new file mode 100644 index 00000000..eab39d24 --- /dev/null +++ b/admin-server/README.md @@ -0,0 +1,19 @@ +# Admin server + +API +
+```/status``` - To check health status + +
+ +To build +
+```./gradlew admin-server:build``` + +To run +
+```./gradlew admin-server:bootRun``` + +To run tests +
+```./gradlew admin-server:test``` \ No newline at end of file diff --git a/admin-server/build.gradle.kts b/admin-server/build.gradle.kts index 55d5a430..e791b804 100644 --- a/admin-server/build.gradle.kts +++ b/admin-server/build.gradle.kts @@ -19,7 +19,7 @@ dependencies { implementation(libs.springboot.actuator) implementation(libs.springboot.web) implementation(libs.kotlin.reflect) - + testImplementation(libs.springboot.test) runtimeOnly(libs.springboot.devtools) } @@ -30,5 +30,9 @@ kotlin { } tasks.withType { - useJUnitPlatform() + testLogging { + setExceptionFormat("full") + events("started", "skipped", "passed", "failed") + showStandardStreams = true + } } \ No newline at end of file diff --git a/admin-server/src/test/kotlin/com/sphereon/oid/fed/ApplicationTests.kt b/admin-server/src/test/kotlin/com/sphereon/oid/fed/ApplicationTests.kt new file mode 100644 index 00000000..e9539f43 --- /dev/null +++ b/admin-server/src/test/kotlin/com/sphereon/oid/fed/ApplicationTests.kt @@ -0,0 +1,13 @@ +package com.sphereon.oid.fed + +import org.junit.jupiter.api.Test +import org.springframework.boot.test.context.SpringBootTest + +@SpringBootTest +class ApplicationTests { + + @Test + fun contextLoads() { + } + +} diff --git a/admin-server/src/test/kotlin/com/sphereon/oid/fed/StatusEndpointTest.kt b/admin-server/src/test/kotlin/com/sphereon/oid/fed/StatusEndpointTest.kt new file mode 100644 index 00000000..9e3af1ad --- /dev/null +++ b/admin-server/src/test/kotlin/com/sphereon/oid/fed/StatusEndpointTest.kt @@ -0,0 +1,25 @@ +package com.sphereon.oid.fed + +import org.junit.jupiter.api.Test +import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc +import org.springframework.boot.test.context.SpringBootTest +import org.springframework.test.web.servlet.MockMvc +import org.springframework.beans.factory.annotation.Autowired +import org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get +import org.springframework.test.web.servlet.result.MockMvcResultMatchers.* + + +@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) +@AutoConfigureMockMvc +class StatusEndpointTest { + + @Autowired + private lateinit var mockMvc: MockMvc + + @Test + fun testStatusEndpoint() { + mockMvc.perform(get("/status")) + .andExpect(status().isOk()) + .andExpect(jsonPath("$.status").value("UP")) + } +} \ No newline at end of file diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 76006ce9..8f2751ea 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -34,6 +34,7 @@ kotlin-reflect = { module = "org.jetbrains.kotlin:kotlin-reflect" } springboot-actuator = { group = "org.springframework.boot", name = "spring-boot-starter-actuator" } springboot-web = { group = "org.springframework.boot", name = "spring-boot-starter-web" } springboot-devtools = { group = "org.springframework.boot", name = "spring-boot-devtools" } +springboot-test = { group = "org.springframework.boot", name = "spring-boot-starter-test" } [plugins] androidApplication = { id = "com.android.application", version.ref = "agp" }