From b2141964b9d52da32fdc66e6f92e0b91e8b91d0a Mon Sep 17 00:00:00 2001 From: Robert Mathew Date: Fri, 28 Jun 2024 19:13:04 +0530 Subject: [PATCH 01/24] Added Spring boot with status API --- .fleet/run.json | 24 +++++++++++ .fleet/settings.json | 12 ++++++ build.gradle.kts | 3 ++ gradle/libs.versions.toml | 12 +++--- server/build.gradle.kts | 42 +++++++++++++++++++ .../com/sphereon/oid/fed/Application.kt | 11 +++++ .../src/main/resources/application.properties | 4 ++ settings.gradle.kts | 1 + 8 files changed, 102 insertions(+), 7 deletions(-) create mode 100644 .fleet/run.json create mode 100644 .fleet/settings.json create mode 100644 server/build.gradle.kts create mode 100644 server/src/main/kotlin/com/sphereon/oid/fed/Application.kt create mode 100644 server/src/main/resources/application.properties diff --git a/.fleet/run.json b/.fleet/run.json new file mode 100644 index 00000000..2054655b --- /dev/null +++ b/.fleet/run.json @@ -0,0 +1,24 @@ +{ + "configurations": [ + { + "name": "OpenID-Federation [:server:build]", + "type": "gradle", + "workingDir": "C:\\Users\\Robo\\Sphereon\\OpenID-Federation", + "tasks": [":server:build"], + "args": [""], + "initScripts": { + "flmapper": "ext.mapPath = { path -> null }" + } + }, + { + "name": "OpenID-Federation [build]", + "type": "gradle", + "workingDir": "C:\\Users\\Robo\\Sphereon\\OpenID-Federation", + "tasks": ["build"], + "args": [""], + "initScripts": { + "flmapper": "ext.mapPath = { path -> null }" + } + } + ] +} \ No newline at end of file diff --git a/.fleet/settings.json b/.fleet/settings.json new file mode 100644 index 00000000..9c37f817 --- /dev/null +++ b/.fleet/settings.json @@ -0,0 +1,12 @@ +{ + "plugins": [ + { + "type": "add", + "pluginName": "fleet.spring.boot" + }, + { + "type": "add", + "pluginName": "fleet.mercury" + } + ] +} \ No newline at end of file diff --git a/build.gradle.kts b/build.gradle.kts index ec93b697..239576aa 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -7,4 +7,7 @@ plugins { alias(libs.plugins.compose.compiler) apply false alias(libs.plugins.kotlinJvm) apply false alias(libs.plugins.kotlinMultiplatform) apply false + alias(libs.plugins.springboot) apply false + alias(libs.plugins.springDependencyManagement) apply false + alias(libs.plugins.kotlinPluginSpring) apply false } \ No newline at end of file diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 4559b0da..3db9123b 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -14,8 +14,8 @@ compose-plugin = "1.6.10" junit = "4.13.2" kotlin = "2.0.0" kotlinxSerializationJson = "1.7.0-RC" -ktor = "2.3.11" -logback = "1.5.6" +springboot = "3.3.1" +spingDependencyManagement = "1.1.5" [libraries] kotlin-test = { module = "org.jetbrains.kotlin:kotlin-test", version.ref = "kotlin" } @@ -29,10 +29,6 @@ androidx-material = { group = "com.google.android.material", name = "material", androidx-constraintlayout = { group = "androidx.constraintlayout", name = "constraintlayout", version.ref = "androidx-constraintlayout" } androidx-activity-compose = { module = "androidx.activity:activity-compose", version.ref = "androidx-activityCompose" } kotlinx-serialization-json = { module = "org.jetbrains.kotlinx:kotlinx-serialization-json", version.ref = "kotlinxSerializationJson" } -logback = { module = "ch.qos.logback:logback-classic", version.ref = "logback" } -ktor-server-core = { module = "io.ktor:ktor-server-core-jvm", version.ref = "ktor" } -ktor-server-netty = { module = "io.ktor:ktor-server-netty-jvm", version.ref = "ktor" } -ktor-server-tests = { module = "io.ktor:ktor-server-tests-jvm", version.ref = "ktor" } [plugins] androidApplication = { id = "com.android.application", version.ref = "agp" } @@ -40,5 +36,7 @@ androidLibrary = { id = "com.android.library", version.ref = "agp" } jetbrainsCompose = { id = "org.jetbrains.compose", version.ref = "compose-plugin" } compose-compiler = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" } kotlinJvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" } -ktor = { id = "io.ktor.plugin", version.ref = "ktor" } kotlinMultiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" } +springboot = { id = "org.springframework.boot", version.ref = "springboot"} +springDependencyManagement = { id = "io.spring.dependency-management", version.ref = "spingDependencyManagement"} +kotlinPluginSpring = { id = "org.jetbrains.kotlin.plugin.spring", version.ref = "kotlin" } \ No newline at end of file diff --git a/server/build.gradle.kts b/server/build.gradle.kts new file mode 100644 index 00000000..62c99881 --- /dev/null +++ b/server/build.gradle.kts @@ -0,0 +1,42 @@ +plugins { + alias(libs.plugins.springboot) + alias(libs.plugins.springDependencyManagement) + alias(libs.plugins.kotlinJvm) + alias(libs.plugins.kotlinPluginSpring) + application +} + +group = "com.sphereon.oid.fed" +version = "1.0.0" + +java { + toolchain { + languageVersion = JavaLanguageVersion.of(21) + } +} + +dependencies { + + implementation("org.springframework.boot:spring-boot-starter-actuator") + implementation("org.springframework.boot:spring-boot-starter-web") + implementation("com.fasterxml.jackson.module:jackson-module-kotlin") + implementation("org.jetbrains.kotlin:kotlin-reflect") + + + testImplementation("org.springframework.boot:spring-boot-starter-test") + testImplementation("org.jetbrains.kotlin:kotlin-test-junit5") + testRuntimeOnly("org.junit.platform:junit-platform-launcher") + + runtimeOnly("org.springframework.boot:spring-boot-devtools") + //testImplementation(libs.kotlin.test.junit) +} + +kotlin { + compilerOptions { + freeCompilerArgs.addAll("-Xjsr305=strict") + } +} + +tasks.withType { + useJUnitPlatform() +} \ No newline at end of file diff --git a/server/src/main/kotlin/com/sphereon/oid/fed/Application.kt b/server/src/main/kotlin/com/sphereon/oid/fed/Application.kt new file mode 100644 index 00000000..2d2fe659 --- /dev/null +++ b/server/src/main/kotlin/com/sphereon/oid/fed/Application.kt @@ -0,0 +1,11 @@ +package com.sphereon.oid.fed + +import org.springframework.boot.autoconfigure.SpringBootApplication +import org.springframework.boot.runApplication + +@SpringBootApplication +class Application + +fun main(args: Array) { + runApplication(*args) +} \ No newline at end of file diff --git a/server/src/main/resources/application.properties b/server/src/main/resources/application.properties new file mode 100644 index 00000000..e83bf36f --- /dev/null +++ b/server/src/main/resources/application.properties @@ -0,0 +1,4 @@ +spring.application.name=OpenID Federation + +management.endpoints.web.base-path=/ +management.endpoints.web.path-mapping.health=status diff --git a/settings.gradle.kts b/settings.gradle.kts index fbf00ad3..17c9a425 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -29,3 +29,4 @@ dependencyResolutionManagement { } include(":modules:openid-federation-common") +include(":server") From 12bd9b675bad1b71343a033b78a7a26afe685621 Mon Sep 17 00:00:00 2001 From: Robert Mathew Date: Mon, 1 Jul 2024 14:49:49 +0530 Subject: [PATCH 02/24] chores: PR feedback --- .fleet/run.json | 20 ++++++--- admin-server/build.gradle.kts | 34 +++++++++++++++ .../com/sphereon/oid/fed/Application.kt | 0 .../src/main/resources/application.properties | 1 + gradle/libs.versions.toml | 11 +++-- server/build.gradle.kts | 42 ------------------- 6 files changed, 57 insertions(+), 51 deletions(-) create mode 100644 admin-server/build.gradle.kts rename {server => admin-server}/src/main/kotlin/com/sphereon/oid/fed/Application.kt (100%) rename {server => admin-server}/src/main/resources/application.properties (77%) delete mode 100644 server/build.gradle.kts diff --git a/.fleet/run.json b/.fleet/run.json index 2054655b..1f631a49 100644 --- a/.fleet/run.json +++ b/.fleet/run.json @@ -3,9 +3,13 @@ { "name": "OpenID-Federation [:server:build]", "type": "gradle", - "workingDir": "C:\\Users\\Robo\\Sphereon\\OpenID-Federation", - "tasks": [":server:build"], - "args": [""], + "workingDir": "$PROJECT_DIR$", + "tasks": [ + ":server:build" + ], + "args": [ + "" + ], "initScripts": { "flmapper": "ext.mapPath = { path -> null }" } @@ -13,9 +17,13 @@ { "name": "OpenID-Federation [build]", "type": "gradle", - "workingDir": "C:\\Users\\Robo\\Sphereon\\OpenID-Federation", - "tasks": ["build"], - "args": [""], + "workingDir": "$PROJECT_DIR$", + "tasks": [ + "build" + ], + "args": [ + "" + ], "initScripts": { "flmapper": "ext.mapPath = { path -> null }" } diff --git a/admin-server/build.gradle.kts b/admin-server/build.gradle.kts new file mode 100644 index 00000000..55d5a430 --- /dev/null +++ b/admin-server/build.gradle.kts @@ -0,0 +1,34 @@ +plugins { + alias(libs.plugins.springboot) + alias(libs.plugins.springDependencyManagement) + alias(libs.plugins.kotlinJvm) + alias(libs.plugins.kotlinPluginSpring) + application +} + +group = "com.sphereon.oid.fed" +version = "1.0.0" + +java { + toolchain { + languageVersion = JavaLanguageVersion.of(21) + } +} + +dependencies { + implementation(libs.springboot.actuator) + implementation(libs.springboot.web) + implementation(libs.kotlin.reflect) + + runtimeOnly(libs.springboot.devtools) +} + +kotlin { + compilerOptions { + freeCompilerArgs.addAll("-Xjsr305=strict") + } +} + +tasks.withType { + useJUnitPlatform() +} \ No newline at end of file diff --git a/server/src/main/kotlin/com/sphereon/oid/fed/Application.kt b/admin-server/src/main/kotlin/com/sphereon/oid/fed/Application.kt similarity index 100% rename from server/src/main/kotlin/com/sphereon/oid/fed/Application.kt rename to admin-server/src/main/kotlin/com/sphereon/oid/fed/Application.kt diff --git a/server/src/main/resources/application.properties b/admin-server/src/main/resources/application.properties similarity index 77% rename from server/src/main/resources/application.properties rename to admin-server/src/main/resources/application.properties index e83bf36f..79c568ef 100644 --- a/server/src/main/resources/application.properties +++ b/admin-server/src/main/resources/application.properties @@ -1,4 +1,5 @@ spring.application.name=OpenID Federation +# Mapping /actuator/health to /status management.endpoints.web.base-path=/ management.endpoints.web.path-mapping.health=status diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 3db9123b..76006ce9 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -15,7 +15,7 @@ junit = "4.13.2" kotlin = "2.0.0" kotlinxSerializationJson = "1.7.0-RC" springboot = "3.3.1" -spingDependencyManagement = "1.1.5" +springDependencyManagement = "1.1.5" [libraries] kotlin-test = { module = "org.jetbrains.kotlin:kotlin-test", version.ref = "kotlin" } @@ -30,6 +30,11 @@ androidx-constraintlayout = { group = "androidx.constraintlayout", name = "const androidx-activity-compose = { module = "androidx.activity:activity-compose", version.ref = "androidx-activityCompose" } kotlinx-serialization-json = { module = "org.jetbrains.kotlinx:kotlinx-serialization-json", version.ref = "kotlinxSerializationJson" } +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" } + [plugins] androidApplication = { id = "com.android.application", version.ref = "agp" } androidLibrary = { id = "com.android.library", version.ref = "agp" } @@ -37,6 +42,6 @@ jetbrainsCompose = { id = "org.jetbrains.compose", version.ref = "compose-plugin compose-compiler = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" } kotlinJvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" } kotlinMultiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" } -springboot = { id = "org.springframework.boot", version.ref = "springboot"} -springDependencyManagement = { id = "io.spring.dependency-management", version.ref = "spingDependencyManagement"} +springboot = { id = "org.springframework.boot", version.ref = "springboot" } +springDependencyManagement = { id = "io.spring.dependency-management", version.ref = "springDependencyManagement" } kotlinPluginSpring = { id = "org.jetbrains.kotlin.plugin.spring", version.ref = "kotlin" } \ No newline at end of file diff --git a/server/build.gradle.kts b/server/build.gradle.kts deleted file mode 100644 index 62c99881..00000000 --- a/server/build.gradle.kts +++ /dev/null @@ -1,42 +0,0 @@ -plugins { - alias(libs.plugins.springboot) - alias(libs.plugins.springDependencyManagement) - alias(libs.plugins.kotlinJvm) - alias(libs.plugins.kotlinPluginSpring) - application -} - -group = "com.sphereon.oid.fed" -version = "1.0.0" - -java { - toolchain { - languageVersion = JavaLanguageVersion.of(21) - } -} - -dependencies { - - implementation("org.springframework.boot:spring-boot-starter-actuator") - implementation("org.springframework.boot:spring-boot-starter-web") - implementation("com.fasterxml.jackson.module:jackson-module-kotlin") - implementation("org.jetbrains.kotlin:kotlin-reflect") - - - testImplementation("org.springframework.boot:spring-boot-starter-test") - testImplementation("org.jetbrains.kotlin:kotlin-test-junit5") - testRuntimeOnly("org.junit.platform:junit-platform-launcher") - - runtimeOnly("org.springframework.boot:spring-boot-devtools") - //testImplementation(libs.kotlin.test.junit) -} - -kotlin { - compilerOptions { - freeCompilerArgs.addAll("-Xjsr305=strict") - } -} - -tasks.withType { - useJUnitPlatform() -} \ No newline at end of file From aafe220385b97dbab56953f10f636edbf76cbd8d Mon Sep 17 00:00:00 2001 From: Robert Mathew Date: Mon, 1 Jul 2024 14:56:55 +0530 Subject: [PATCH 03/24] Updated the server name in gradle module --- settings.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/settings.gradle.kts b/settings.gradle.kts index 17c9a425..a7cd08e0 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -29,4 +29,4 @@ dependencyResolutionManagement { } include(":modules:openid-federation-common") -include(":server") +include(":admin-server") From a5c26a61bc2d7eb4d5063e0bd3f263cc9310324b Mon Sep 17 00:00:00 2001 From: Robert Mathew Date: Mon, 1 Jul 2024 19:15:03 +0530 Subject: [PATCH 04/24] Added test for status endpoint and added README --- .fleet/run.json | 2 +- admin-server/README.md | 19 ++++++++++++++ admin-server/build.gradle.kts | 8 ++++-- .../com/sphereon/oid/fed/ApplicationTests.kt | 13 ++++++++++ .../sphereon/oid/fed/StatusEndpointTest.kt | 25 +++++++++++++++++++ gradle/libs.versions.toml | 1 + 6 files changed, 65 insertions(+), 3 deletions(-) create mode 100644 admin-server/README.md create mode 100644 admin-server/src/test/kotlin/com/sphereon/oid/fed/ApplicationTests.kt create mode 100644 admin-server/src/test/kotlin/com/sphereon/oid/fed/StatusEndpointTest.kt 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" } From eceb917a9a08610a6c5a21744129fa583123146a Mon Sep 17 00:00:00 2001 From: Robert Mathew Date: Tue, 2 Jul 2024 12:41:21 +0530 Subject: [PATCH 05/24] Enabled test run on gradle build --- admin-server/build.gradle.kts | 1 + 1 file changed, 1 insertion(+) diff --git a/admin-server/build.gradle.kts b/admin-server/build.gradle.kts index e791b804..e856481f 100644 --- a/admin-server/build.gradle.kts +++ b/admin-server/build.gradle.kts @@ -30,6 +30,7 @@ kotlin { } tasks.withType { + useJUnitPlatform() testLogging { setExceptionFormat("full") events("started", "skipped", "passed", "failed") From e3652bf9ff4ac240c4fe89351b2543e238f222f5 Mon Sep 17 00:00:00 2001 From: Robert Mathew Date: Wed, 3 Jul 2024 12:04:44 +0530 Subject: [PATCH 06/24] Added Postgres and docker --- .fleet/run.json | 12 +++++++++- admin-server/build.gradle.kts | 2 ++ .../src/main/resources/application.properties | 7 +++++- docker/docker-compose.yaml | 23 +++++++++++++++++++ gradle/libs.versions.toml | 2 ++ 5 files changed, 44 insertions(+), 2 deletions(-) create mode 100644 docker/docker-compose.yaml diff --git a/.fleet/run.json b/.fleet/run.json index b3f28c35..5ef399e9 100644 --- a/.fleet/run.json +++ b/.fleet/run.json @@ -1,7 +1,7 @@ { "configurations": [ { - "name": "OpenID-Federation [:server:build]", + "name": "OpenID-Federation [:admin-server:build]", "type": "gradle", "workingDir": "$PROJECT_DIR$", "tasks": [ @@ -27,6 +27,16 @@ "initScripts": { "flmapper": "ext.mapPath = { path -> null }" } + }, + { + "name": "OpenID-Federation [admin-server:bootRun]", + "type": "gradle", + "workingDir": "C:\\Users\\Robo\\Sphereon\\OpenID-Federation", + "tasks": ["admin-server:bootRun"], + "args": [""], + "initScripts": { + "flmapper": "ext.mapPath = { path -> null }" + } } ] } \ No newline at end of file diff --git a/admin-server/build.gradle.kts b/admin-server/build.gradle.kts index e856481f..8bcd3a39 100644 --- a/admin-server/build.gradle.kts +++ b/admin-server/build.gradle.kts @@ -18,8 +18,10 @@ java { dependencies { implementation(libs.springboot.actuator) implementation(libs.springboot.web) + implementation(libs.springboot.data.jdbc) implementation(libs.kotlin.reflect) testImplementation(libs.springboot.test) + runtimeOnly(libs.postgres) runtimeOnly(libs.springboot.devtools) } diff --git a/admin-server/src/main/resources/application.properties b/admin-server/src/main/resources/application.properties index 79c568ef..6f269338 100644 --- a/admin-server/src/main/resources/application.properties +++ b/admin-server/src/main/resources/application.properties @@ -1,5 +1,10 @@ spring.application.name=OpenID Federation +spring.datasource.url=jdbc:postgresql://localhost:5432/openid-federation-db +spring.datasource.username=openid-federation-user +spring.datasource.password=changeit +spring.datasource.driver-class-name=org.postgresql.Driver + # Mapping /actuator/health to /status management.endpoints.web.base-path=/ -management.endpoints.web.path-mapping.health=status +management.endpoints.web.path-mapping.health=status \ No newline at end of file diff --git a/docker/docker-compose.yaml b/docker/docker-compose.yaml new file mode 100644 index 00000000..106b75a5 --- /dev/null +++ b/docker/docker-compose.yaml @@ -0,0 +1,23 @@ +version: '3.9' + +services: + db: + image: postgres:latest + container_name: postgres_db + environment: + POSTGRES_USER: openid-federation-user + POSTGRES_PASSWORD: changeit + POSTGRES_DB: openid-federation-db + ports: + - "5432:5432" + volumes: + - postgres_data:/var/lib/postgresql/data + networks: + - openid_network + +networks: + openid_network: + driver: bridge + +volumes: + postgres_data: \ No newline at end of file diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 8f2751ea..7a25a76a 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -33,8 +33,10 @@ kotlinx-serialization-json = { module = "org.jetbrains.kotlinx:kotlinx-serializa 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-data-jdbc = { group = "org.springframework.boot", name = "spring-boot-starter-data-jdbc" } springboot-devtools = { group = "org.springframework.boot", name = "spring-boot-devtools" } springboot-test = { group = "org.springframework.boot", name = "spring-boot-starter-test" } +postgres = { module = "org.postgresql:postgresql" } [plugins] androidApplication = { id = "com.android.application", version.ref = "agp" } From 11b44a3ae68f99e366f3c32f25bd96e64206444c Mon Sep 17 00:00:00 2001 From: Robert Mathew Date: Fri, 5 Jul 2024 16:09:16 +0530 Subject: [PATCH 07/24] Added environment file --- .gitignore | 2 ++ admin-server/README.md | 7 +++++++ admin-server/src/main/resources/application.properties | 6 +++--- docker/docker-compose.yaml | 6 +++--- 4 files changed, 15 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index f0e9e76a..161fec79 100644 --- a/.gitignore +++ b/.gitignore @@ -20,3 +20,5 @@ captures /platforms/ /platform-tools/ /.temp/ +/docker/.env +/.run/* diff --git a/admin-server/README.md b/admin-server/README.md index eab39d24..0ff5d132 100644 --- a/admin-server/README.md +++ b/admin-server/README.md @@ -6,6 +6,13 @@ API
+Add environment file (.env) with following properties +``` +DATABASE_USER= +DATABASE_PASSWORD= +DATABASE_NAME= +``` + To build
```./gradlew admin-server:build``` diff --git a/admin-server/src/main/resources/application.properties b/admin-server/src/main/resources/application.properties index 6f269338..8844bedb 100644 --- a/admin-server/src/main/resources/application.properties +++ b/admin-server/src/main/resources/application.properties @@ -1,8 +1,8 @@ spring.application.name=OpenID Federation -spring.datasource.url=jdbc:postgresql://localhost:5432/openid-federation-db -spring.datasource.username=openid-federation-user -spring.datasource.password=changeit +spring.datasource.url=jdbc:postgresql://localhost:5432/${DATABASE_NAME} +spring.datasource.username=${DATABASE_USER} +spring.datasource.password=${DATABASE_PASSWORD} spring.datasource.driver-class-name=org.postgresql.Driver # Mapping /actuator/health to /status diff --git a/docker/docker-compose.yaml b/docker/docker-compose.yaml index 106b75a5..e3bb3de1 100644 --- a/docker/docker-compose.yaml +++ b/docker/docker-compose.yaml @@ -5,9 +5,9 @@ services: image: postgres:latest container_name: postgres_db environment: - POSTGRES_USER: openid-federation-user - POSTGRES_PASSWORD: changeit - POSTGRES_DB: openid-federation-db + POSTGRES_USER: ${DATABASE_USER} + POSTGRES_PASSWORD: ${DATABASE_PASSWORD} + POSTGRES_DB: ${DATABASE_NAME} ports: - "5432:5432" volumes: From 4a2f088c7d4b3364faaf23ea9b2ea695ddd751f9 Mon Sep 17 00:00:00 2001 From: Robert Mathew Date: Fri, 5 Jul 2024 18:39:14 +0530 Subject: [PATCH 08/24] Updated env variable --- admin-server/README.md | 6 +++--- admin-server/src/main/resources/application.properties | 6 +++--- docker/docker-compose.yaml | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/admin-server/README.md b/admin-server/README.md index 0ff5d132..dc681041 100644 --- a/admin-server/README.md +++ b/admin-server/README.md @@ -8,9 +8,9 @@ API Add environment file (.env) with following properties ``` -DATABASE_USER= -DATABASE_PASSWORD= -DATABASE_NAME= +DATASOURCE_USER= +DATASOURCE_PASSWORD= +DATASOURCE_URL= ``` To build diff --git a/admin-server/src/main/resources/application.properties b/admin-server/src/main/resources/application.properties index 8844bedb..c87c6311 100644 --- a/admin-server/src/main/resources/application.properties +++ b/admin-server/src/main/resources/application.properties @@ -1,8 +1,8 @@ spring.application.name=OpenID Federation -spring.datasource.url=jdbc:postgresql://localhost:5432/${DATABASE_NAME} -spring.datasource.username=${DATABASE_USER} -spring.datasource.password=${DATABASE_PASSWORD} +spring.datasource.url=${DATASOURCE_URL} +spring.datasource.username=${DATASOURCE_USER} +spring.datasource.password=${DATASOURCE_PASSWORD} spring.datasource.driver-class-name=org.postgresql.Driver # Mapping /actuator/health to /status diff --git a/docker/docker-compose.yaml b/docker/docker-compose.yaml index e3bb3de1..92efe779 100644 --- a/docker/docker-compose.yaml +++ b/docker/docker-compose.yaml @@ -5,9 +5,9 @@ services: image: postgres:latest container_name: postgres_db environment: - POSTGRES_USER: ${DATABASE_USER} - POSTGRES_PASSWORD: ${DATABASE_PASSWORD} - POSTGRES_DB: ${DATABASE_NAME} + POSTGRES_USER: ${DATASOURCE_USER} + POSTGRES_PASSWORD: ${DATASOURCE_PASSWORD} + POSTGRES_DB: openid-federation-db ports: - "5432:5432" volumes: From eb4d318e4af38cae76f859e2a45bb73001698278 Mon Sep 17 00:00:00 2001 From: Robert Mathew Date: Fri, 5 Jul 2024 19:08:48 +0530 Subject: [PATCH 09/24] Fixed merge conflicts --- {admin-server => modules/admin-server}/README.md | 6 +++--- {admin-server => modules/admin-server}/build.gradle.kts | 2 +- .../com/sphereon/oid/fed/server/admin}/Application.kt | 2 +- .../admin-server}/src/main/resources/application.properties | 0 .../com/sphereon/oid/fed/server/admin}/ApplicationTests.kt | 2 +- .../sphereon/oid/fed/server/admin}/StatusEndpointTest.kt | 2 +- settings.gradle.kts | 2 +- 7 files changed, 8 insertions(+), 8 deletions(-) rename {admin-server => modules/admin-server}/README.md (65%) rename {admin-server => modules/admin-server}/build.gradle.kts (95%) rename {admin-server/src/main/kotlin/com/sphereon/oid/fed => modules/admin-server/src/main/kotlin/com/sphereon/oid/fed/server/admin}/Application.kt (84%) rename {admin-server => modules/admin-server}/src/main/resources/application.properties (100%) rename {admin-server/src/test/kotlin/com/sphereon/oid/fed => modules/admin-server/src/test/kotlin/com/sphereon/oid/fed/server/admin}/ApplicationTests.kt (80%) rename {admin-server/src/test/kotlin/com/sphereon/oid/fed => modules/admin-server/src/test/kotlin/com/sphereon/oid/fed/server/admin}/StatusEndpointTest.kt (95%) diff --git a/admin-server/README.md b/modules/admin-server/README.md similarity index 65% rename from admin-server/README.md rename to modules/admin-server/README.md index dc681041..aecd1dbb 100644 --- a/admin-server/README.md +++ b/modules/admin-server/README.md @@ -15,12 +15,12 @@ DATASOURCE_URL= To build
-```./gradlew admin-server:build``` +```./gradlew :modules:admin-server:build``` To run
-```./gradlew admin-server:bootRun``` +```./gradlew :modules:admin-server:bootRun``` To run tests
-```./gradlew admin-server:test``` \ No newline at end of file +```./gradlew :modules:admin-server:test``` \ No newline at end of file diff --git a/admin-server/build.gradle.kts b/modules/admin-server/build.gradle.kts similarity index 95% rename from admin-server/build.gradle.kts rename to modules/admin-server/build.gradle.kts index 8bcd3a39..b1def3cc 100644 --- a/admin-server/build.gradle.kts +++ b/modules/admin-server/build.gradle.kts @@ -6,7 +6,7 @@ plugins { application } -group = "com.sphereon.oid.fed" +group = "com.sphereon.oid.fed.server.admin" version = "1.0.0" java { diff --git a/admin-server/src/main/kotlin/com/sphereon/oid/fed/Application.kt b/modules/admin-server/src/main/kotlin/com/sphereon/oid/fed/server/admin/Application.kt similarity index 84% rename from admin-server/src/main/kotlin/com/sphereon/oid/fed/Application.kt rename to modules/admin-server/src/main/kotlin/com/sphereon/oid/fed/server/admin/Application.kt index 2d2fe659..654f00f7 100644 --- a/admin-server/src/main/kotlin/com/sphereon/oid/fed/Application.kt +++ b/modules/admin-server/src/main/kotlin/com/sphereon/oid/fed/server/admin/Application.kt @@ -1,4 +1,4 @@ -package com.sphereon.oid.fed +package com.sphereon.oid.fed.server.admin import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.boot.runApplication diff --git a/admin-server/src/main/resources/application.properties b/modules/admin-server/src/main/resources/application.properties similarity index 100% rename from admin-server/src/main/resources/application.properties rename to modules/admin-server/src/main/resources/application.properties diff --git a/admin-server/src/test/kotlin/com/sphereon/oid/fed/ApplicationTests.kt b/modules/admin-server/src/test/kotlin/com/sphereon/oid/fed/server/admin/ApplicationTests.kt similarity index 80% rename from admin-server/src/test/kotlin/com/sphereon/oid/fed/ApplicationTests.kt rename to modules/admin-server/src/test/kotlin/com/sphereon/oid/fed/server/admin/ApplicationTests.kt index e9539f43..3f3e34e3 100644 --- a/admin-server/src/test/kotlin/com/sphereon/oid/fed/ApplicationTests.kt +++ b/modules/admin-server/src/test/kotlin/com/sphereon/oid/fed/server/admin/ApplicationTests.kt @@ -1,4 +1,4 @@ -package com.sphereon.oid.fed +package com.sphereon.oid.fed.server.admin import org.junit.jupiter.api.Test import org.springframework.boot.test.context.SpringBootTest diff --git a/admin-server/src/test/kotlin/com/sphereon/oid/fed/StatusEndpointTest.kt b/modules/admin-server/src/test/kotlin/com/sphereon/oid/fed/server/admin/StatusEndpointTest.kt similarity index 95% rename from admin-server/src/test/kotlin/com/sphereon/oid/fed/StatusEndpointTest.kt rename to modules/admin-server/src/test/kotlin/com/sphereon/oid/fed/server/admin/StatusEndpointTest.kt index 9e3af1ad..e1014b98 100644 --- a/admin-server/src/test/kotlin/com/sphereon/oid/fed/StatusEndpointTest.kt +++ b/modules/admin-server/src/test/kotlin/com/sphereon/oid/fed/server/admin/StatusEndpointTest.kt @@ -1,4 +1,4 @@ -package com.sphereon.oid.fed +package com.sphereon.oid.fed.server.admin import org.junit.jupiter.api.Test import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc diff --git a/settings.gradle.kts b/settings.gradle.kts index a7cd08e0..1e991276 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -29,4 +29,4 @@ dependencyResolutionManagement { } include(":modules:openid-federation-common") -include(":admin-server") +include(":modules:admin-server") From f875cfbcd9043dd2b05ca7ed39117f68bea3bc03 Mon Sep 17 00:00:00 2001 From: Robert Mathew Date: Mon, 8 Jul 2024 11:35:13 +0530 Subject: [PATCH 10/24] Updated CI for GitHub secrets --- .github/workflows/ci.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9acc12e1..163233a7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -25,3 +25,7 @@ jobs: - name: Execute Gradle build run: ./gradlew build + env: + DATASOURCE_USER: ${{ secrets.DATASOURCE_USER }} + DATASOURCE_PASSWORD: ${{ secrets.DATASOURCE_PASSWORD }} + DATASOURCE_URL: ${{ secrets.DATASOURCE_URL }} From 3bf5ba4f7b1fed076ea938168cedcff8359d20f0 Mon Sep 17 00:00:00 2001 From: Robert Mathew Date: Mon, 8 Jul 2024 11:46:22 +0530 Subject: [PATCH 11/24] Added docker in GitHub action --- .github/workflows/ci.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 163233a7..3329f327 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -16,6 +16,9 @@ jobs: distribution: adopt-hotspot java-version: 17 + - name: Build the stack + run: docker-compose -f docker/docker-compose.yaml up -d + - name: Setup Gradle uses: gradle/gradle-build-action@v3 From e0f59fc0d17c456215eb52429790dbf4e3738179 Mon Sep 17 00:00:00 2001 From: Robert Mathew Date: Mon, 8 Jul 2024 11:49:01 +0530 Subject: [PATCH 12/24] Added env variable for docker in GitHub action --- .github/workflows/ci.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3329f327..54ec9cec 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,6 +18,10 @@ jobs: - name: Build the stack run: docker-compose -f docker/docker-compose.yaml up -d + env: + DATASOURCE_USER: ${{ secrets.DATASOURCE_USER }} + DATASOURCE_PASSWORD: ${{ secrets.DATASOURCE_PASSWORD }} + DATASOURCE_URL: ${{ secrets.DATASOURCE_URL }} - name: Setup Gradle uses: gradle/gradle-build-action@v3 From ac2129f83c31b5f4573a67a38c0cd4765b50fe12 Mon Sep 17 00:00:00 2001 From: Robert Mathew Date: Mon, 8 Jul 2024 11:54:42 +0530 Subject: [PATCH 13/24] Removed Windows in GitHub action --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 54ec9cec..b7d3a89a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,7 +7,7 @@ jobs: gradle: strategy: matrix: - os: [ ubuntu-latest, windows-latest ] + os: [ ubuntu-latest ] runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v4 From 09284e149b02a33b9c9a3ba6f0b6ee5e45b775a7 Mon Sep 17 00:00:00 2001 From: Robert Mathew Date: Mon, 8 Jul 2024 12:45:28 +0530 Subject: [PATCH 14/24] Added comment for removing Windows in CI --- .github/workflows/ci.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b7d3a89a..fdaff1df 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,6 +7,8 @@ jobs: gradle: strategy: matrix: + # Removed windows, because build failing with docker network. "bridge" network driver is not supported for Windows containers + # os: [ ubuntu-latest, windows-latest ] os: [ ubuntu-latest ] runs-on: ${{ matrix.os }} steps: From bcdf6ce2dc804af250745c4274f8ebee09898ab7 Mon Sep 17 00:00:00 2001 From: Robert Mathew Date: Mon, 8 Jul 2024 15:12:33 +0530 Subject: [PATCH 15/24] Removed hardcoded path from run script --- .fleet/run.json | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/.fleet/run.json b/.fleet/run.json index 797ff2ad..a523f1a3 100644 --- a/.fleet/run.json +++ b/.fleet/run.json @@ -27,16 +27,6 @@ "initScripts": { "flmapper": "ext.mapPath = { path -> null }" } - }, - { - "name": "OpenID-Federation [admin-server:bootRun]", - "type": "gradle", - "workingDir": "C:\\Users\\Robo\\Sphereon\\OpenID-Federation", - "tasks": ["admin-server:bootRun"], - "args": [""], - "initScripts": { - "flmapper": "ext.mapPath = { path -> null }" - } } ] } \ No newline at end of file From 2a50d8e64c16ea8205c9a4d50f842238c36a618a Mon Sep 17 00:00:00 2001 From: sanderPostma Date: Mon, 8 Jul 2024 13:57:13 +0200 Subject: [PATCH 16/24] chore: fix project name --- settings.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/settings.gradle.kts b/settings.gradle.kts index 1e991276..5bece6b0 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -1,4 +1,4 @@ -rootProject.name = "kotlin-mp-genesis" +rootProject.name = "openid-federation" enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS") pluginManagement { From f2ff474bf2e1cbad6d88b1ba169de9ce4d123ad0 Mon Sep 17 00:00:00 2001 From: sanderPostma Date: Wed, 3 Jul 2024 14:03:00 +0200 Subject: [PATCH 17/24] chore: extract ktor version --- modules/openid-federation-common/build.gradle.kts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/modules/openid-federation-common/build.gradle.kts b/modules/openid-federation-common/build.gradle.kts index 2bc918dd..62762b20 100644 --- a/modules/openid-federation-common/build.gradle.kts +++ b/modules/openid-federation-common/build.gradle.kts @@ -9,6 +9,8 @@ plugins { kotlin("plugin.serialization") version "2.0.0" } +val ktorVersion = "2.3.11" + kotlin { @OptIn(ExperimentalWasmDsl::class) @@ -47,7 +49,7 @@ kotlin { sourceSets { val commonMain by getting { dependencies { - implementation("io.ktor:ktor-client-core:2.3.11") + implementation("io.ktor:ktor-client-core:$ktorVersion") implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.7.0") implementation("org.jetbrains.kotlinx:kotlinx-serialization-core:1.7.0") } @@ -60,7 +62,7 @@ kotlin { } val jvmMain by getting { dependencies { - implementation("io.ktor:ktor-client-cio:2.3.11") + implementation("io.ktor:ktor-client-core-jvm:$ktorVersion") } } val jvmTest by getting { @@ -71,7 +73,7 @@ kotlin { val androidMain by getting { dependencies { - implementation("io.ktor:ktor-client-okhttp:2.3.11") + implementation("io.ktor:ktor-client-core-jvm:$ktorVersion") } } val androidUnitTest by getting { @@ -83,7 +85,7 @@ kotlin { val iosMain by creating { dependsOn(commonMain) dependencies { - implementation("io.ktor:ktor-client-ios:2.3.11") + implementation("io.ktor:ktor-client-ios:$ktorVersion") } } val iosX64Main by getting { @@ -105,7 +107,7 @@ kotlin { val jsMain by getting { dependencies { - implementation("io.ktor:ktor-client-js:2.3.11") + implementation("io.ktor:ktor-client-js:$ktorVersion") } } From 3a70c3cb0c08e10fc32c271ec5daed0dd759a038 Mon Sep 17 00:00:00 2001 From: John Melati Date: Tue, 9 Jul 2024 15:48:00 +0200 Subject: [PATCH 18/24] fix: temporarily hardcode db credentials --- .env | 4 ++++ docker/docker-compose.yaml => docker-compose.yaml | 2 +- .../admin-server/src/main/resources/application.properties | 6 +++--- 3 files changed, 8 insertions(+), 4 deletions(-) create mode 100644 .env rename docker/docker-compose.yaml => docker-compose.yaml (89%) diff --git a/.env b/.env new file mode 100644 index 00000000..34ab61a8 --- /dev/null +++ b/.env @@ -0,0 +1,4 @@ +DATASOURCE_URL=jdbc:postgresql://localhost:5432/openid-federation-db +DATASOURCE_USER=openid-federation-db-user +DATASOURCE_PASSWORD=openid-federation-db-password +DATASOURCE_DB=openid-federation-db \ No newline at end of file diff --git a/docker/docker-compose.yaml b/docker-compose.yaml similarity index 89% rename from docker/docker-compose.yaml rename to docker-compose.yaml index 92efe779..af8db708 100644 --- a/docker/docker-compose.yaml +++ b/docker-compose.yaml @@ -3,7 +3,7 @@ version: '3.9' services: db: image: postgres:latest - container_name: postgres_db + container_name: openid-federation-datastore environment: POSTGRES_USER: ${DATASOURCE_USER} POSTGRES_PASSWORD: ${DATASOURCE_PASSWORD} diff --git a/modules/admin-server/src/main/resources/application.properties b/modules/admin-server/src/main/resources/application.properties index c87c6311..e07727f9 100644 --- a/modules/admin-server/src/main/resources/application.properties +++ b/modules/admin-server/src/main/resources/application.properties @@ -1,8 +1,8 @@ spring.application.name=OpenID Federation -spring.datasource.url=${DATASOURCE_URL} -spring.datasource.username=${DATASOURCE_USER} -spring.datasource.password=${DATASOURCE_PASSWORD} +spring.datasource.url=jdbc:postgresql://localhost:5432/openid-federation-db +spring.datasource.username=openid-federation-db-user +spring.datasource.password=openid-federation-db-password spring.datasource.driver-class-name=org.postgresql.Driver # Mapping /actuator/health to /status From 2c633c9ea7c1a28cb27337b8dc58969e0018fff5 Mon Sep 17 00:00:00 2001 From: Robert Mathew Date: Wed, 10 Jul 2024 12:35:59 +0530 Subject: [PATCH 19/24] Added Test container --- gradle/libs.versions.toml | 3 +++ modules/admin-server/build.gradle.kts | 3 +++ .../oid/fed/server/admin/DatabaseTest.kt | 18 ++++++++++++++++++ 3 files changed, 24 insertions(+) create mode 100644 modules/admin-server/src/test/kotlin/com/sphereon/oid/fed/server/admin/DatabaseTest.kt diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 7a25a76a..8f8f7c66 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -37,6 +37,9 @@ springboot-data-jdbc = { group = "org.springframework.boot", name = "spring-boot springboot-devtools = { group = "org.springframework.boot", name = "spring-boot-devtools" } springboot-test = { group = "org.springframework.boot", name = "spring-boot-starter-test" } postgres = { module = "org.postgresql:postgresql" } +springboot-testcontainer = { group = "org.springframework.boot", name = "spring-boot-testcontainers"} +testcontainer-postgres = { group = "org.testcontainers", name = "postgresql"} +testcontainer-junit = { group = "org.testcontainers", name = "junit-jupiter"} [plugins] androidApplication = { id = "com.android.application", version.ref = "agp" } diff --git a/modules/admin-server/build.gradle.kts b/modules/admin-server/build.gradle.kts index b1def3cc..b43c23cc 100644 --- a/modules/admin-server/build.gradle.kts +++ b/modules/admin-server/build.gradle.kts @@ -21,6 +21,9 @@ dependencies { implementation(libs.springboot.data.jdbc) implementation(libs.kotlin.reflect) testImplementation(libs.springboot.test) + testImplementation(libs.testcontainer.junit) + testImplementation(libs.springboot.testcontainer) + testImplementation(libs.testcontainer.postgres) runtimeOnly(libs.postgres) runtimeOnly(libs.springboot.devtools) } diff --git a/modules/admin-server/src/test/kotlin/com/sphereon/oid/fed/server/admin/DatabaseTest.kt b/modules/admin-server/src/test/kotlin/com/sphereon/oid/fed/server/admin/DatabaseTest.kt new file mode 100644 index 00000000..2c8b2b94 --- /dev/null +++ b/modules/admin-server/src/test/kotlin/com/sphereon/oid/fed/server/admin/DatabaseTest.kt @@ -0,0 +1,18 @@ +package com.sphereon.oid.fed.server.admin + +import org.junit.jupiter.api.Test +import org.testcontainers.containers.PostgreSQLContainer +import org.testcontainers.junit.jupiter.Container +import org.testcontainers.junit.jupiter.Testcontainers + +@Testcontainers +class DatabaseTest { + + @Container + val postgres: PostgreSQLContainer<*> = PostgreSQLContainer("postgres:14") + + @Test + fun `test database connection`() { + assert(postgres.isRunning) + } +} \ No newline at end of file From 1f8a010d674ad55b8308c0c855fd684d64c27d70 Mon Sep 17 00:00:00 2001 From: Zoe Maas Date: Wed, 10 Jul 2024 10:35:07 +0200 Subject: [PATCH 20/24] chore: Added flyway dependency --- gradle/libs.versions.toml | 1 + modules/admin-server/build.gradle.kts | 1 + 2 files changed, 2 insertions(+) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 7a25a76a..d5fbc320 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -36,6 +36,7 @@ springboot-web = { group = "org.springframework.boot", name = "spring-boot-start springboot-data-jdbc = { group = "org.springframework.boot", name = "spring-boot-starter-data-jdbc" } springboot-devtools = { group = "org.springframework.boot", name = "spring-boot-devtools" } springboot-test = { group = "org.springframework.boot", name = "spring-boot-starter-test" } +flyway = { module = "org.flywaydb:flyway-core" } postgres = { module = "org.postgresql:postgresql" } [plugins] diff --git a/modules/admin-server/build.gradle.kts b/modules/admin-server/build.gradle.kts index b1def3cc..c21552f2 100644 --- a/modules/admin-server/build.gradle.kts +++ b/modules/admin-server/build.gradle.kts @@ -17,6 +17,7 @@ java { dependencies { implementation(libs.springboot.actuator) + implementation(libs.flyway) implementation(libs.springboot.web) implementation(libs.springboot.data.jdbc) implementation(libs.kotlin.reflect) From 2ba8c902f3b4c7273d232acf593c6fe44ba9ac01 Mon Sep 17 00:00:00 2001 From: Zoe Maas Date: Wed, 10 Jul 2024 15:04:02 +0200 Subject: [PATCH 21/24] feat: Flyway setup --- gradle/libs.versions.toml | 3 ++- modules/admin-server/build.gradle.kts | 3 ++- .../admin-server/src/main/resources/application.properties | 7 +++++++ .../src/main/resources/db/migration/V0.1.0__Account.sql | 7 +++++++ 4 files changed, 18 insertions(+), 2 deletions(-) create mode 100644 modules/admin-server/src/main/resources/db/migration/V0.1.0__Account.sql diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index d5fbc320..12d53ce2 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -36,7 +36,8 @@ springboot-web = { group = "org.springframework.boot", name = "spring-boot-start springboot-data-jdbc = { group = "org.springframework.boot", name = "spring-boot-starter-data-jdbc" } springboot-devtools = { group = "org.springframework.boot", name = "spring-boot-devtools" } springboot-test = { group = "org.springframework.boot", name = "spring-boot-starter-test" } -flyway = { module = "org.flywaydb:flyway-core" } +flyway-core = { module = "org.flywaydb:flyway-core" } +flyway-postgres = { module = "org.flywaydb:flyway-database-postgresql" } postgres = { module = "org.postgresql:postgresql" } [plugins] diff --git a/modules/admin-server/build.gradle.kts b/modules/admin-server/build.gradle.kts index c21552f2..777d971e 100644 --- a/modules/admin-server/build.gradle.kts +++ b/modules/admin-server/build.gradle.kts @@ -17,11 +17,12 @@ java { dependencies { implementation(libs.springboot.actuator) - implementation(libs.flyway) implementation(libs.springboot.web) implementation(libs.springboot.data.jdbc) implementation(libs.kotlin.reflect) testImplementation(libs.springboot.test) + implementation(libs.flyway.core) + implementation(libs.flyway.postgres) runtimeOnly(libs.postgres) runtimeOnly(libs.springboot.devtools) } diff --git a/modules/admin-server/src/main/resources/application.properties b/modules/admin-server/src/main/resources/application.properties index e07727f9..02039c65 100644 --- a/modules/admin-server/src/main/resources/application.properties +++ b/modules/admin-server/src/main/resources/application.properties @@ -5,6 +5,13 @@ spring.datasource.username=openid-federation-db-user spring.datasource.password=openid-federation-db-password spring.datasource.driver-class-name=org.postgresql.Driver +# Flyway +spring.flyway.enabled=false +spring.flyway.baseline-on-migrate = true +spring.flyway.clean-on-validation-error=true +spring.flyway.clean-disabled=false +spring.flyway.baseline-version=0 + # Mapping /actuator/health to /status management.endpoints.web.base-path=/ management.endpoints.web.path-mapping.health=status \ No newline at end of file diff --git a/modules/admin-server/src/main/resources/db/migration/V0.1.0__Account.sql b/modules/admin-server/src/main/resources/db/migration/V0.1.0__Account.sql new file mode 100644 index 00000000..33b56ab1 --- /dev/null +++ b/modules/admin-server/src/main/resources/db/migration/V0.1.0__Account.sql @@ -0,0 +1,7 @@ +CREATE TYPE "public"."KMS_TYPE" AS ENUM ('LOCAL'); + +CREATE TABLE "public"."account" ( + id SERIAL PRIMARY KEY, + username VARCHAR(255) UNIQUE NOT NULL, + kms "public"."KMS_TYPE" NOT NULL DEFAULT 'LOCAL' +); From 95fe29e6aecad02d30630a2fdc8756f93fd0fe9d Mon Sep 17 00:00:00 2001 From: Zoe Maas Date: Wed, 10 Jul 2024 15:18:15 +0200 Subject: [PATCH 22/24] fix: Merging issues --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fdaff1df..73b95060 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -19,7 +19,7 @@ jobs: java-version: 17 - name: Build the stack - run: docker-compose -f docker/docker-compose.yaml up -d + run: docker-compose -f docker-compose.yaml up -d env: DATASOURCE_USER: ${{ secrets.DATASOURCE_USER }} DATASOURCE_PASSWORD: ${{ secrets.DATASOURCE_PASSWORD }} From 0b0ebb6f66e0a3258ca7d1ba7af9fed8405f6026 Mon Sep 17 00:00:00 2001 From: Zoe Maas Date: Tue, 23 Jul 2024 09:21:34 +0200 Subject: [PATCH 23/24] refactor: Removed "public" from the database objects creation/utilization --- .../src/main/resources/db/migration/V0.1.0__Account.sql | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/admin-server/src/main/resources/db/migration/V0.1.0__Account.sql b/modules/admin-server/src/main/resources/db/migration/V0.1.0__Account.sql index 33b56ab1..2a3e2eb7 100644 --- a/modules/admin-server/src/main/resources/db/migration/V0.1.0__Account.sql +++ b/modules/admin-server/src/main/resources/db/migration/V0.1.0__Account.sql @@ -1,7 +1,7 @@ -CREATE TYPE "public"."KMS_TYPE" AS ENUM ('LOCAL'); +CREATE TYPE "KMS_TYPE" AS ENUM ('LOCAL'); -CREATE TABLE "public"."account" ( +CREATE TABLE "account" ( id SERIAL PRIMARY KEY, username VARCHAR(255) UNIQUE NOT NULL, - kms "public"."KMS_TYPE" NOT NULL DEFAULT 'LOCAL' + kms "KMS_TYPE" NOT NULL DEFAULT 'LOCAL' ); From 74a209f6222315c123abf3293568d9fd54310837 Mon Sep 17 00:00:00 2001 From: maikel-maas <86769796+maikel-maas@users.noreply.github.com> Date: Tue, 30 Jul 2024 09:39:59 +0200 Subject: [PATCH 24/24] Revert "Feature/oidf 46" --- gradle/libs.versions.toml | 2 -- modules/admin-server/build.gradle.kts | 2 -- .../src/main/resources/application.properties | 9 +-------- .../src/main/resources/db/migration/V0.1.0__Account.sql | 7 ------- 4 files changed, 1 insertion(+), 19 deletions(-) delete mode 100644 modules/admin-server/src/main/resources/db/migration/V0.1.0__Account.sql diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index d12cf57e..19b09680 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -38,8 +38,6 @@ springboot-web = { group = "org.springframework.boot", name = "spring-boot-start springboot-data-jdbc = { group = "org.springframework.boot", name = "spring-boot-starter-data-jdbc" } springboot-devtools = { group = "org.springframework.boot", name = "spring-boot-devtools" } springboot-test = { group = "org.springframework.boot", name = "spring-boot-starter-test" } -flyway-core = { module = "org.flywaydb:flyway-core" } -flyway-postgres = { module = "org.flywaydb:flyway-database-postgresql" } postgres = { module = "org.postgresql:postgresql" } [plugins] diff --git a/modules/admin-server/build.gradle.kts b/modules/admin-server/build.gradle.kts index 7973d79b..8abb8cef 100644 --- a/modules/admin-server/build.gradle.kts +++ b/modules/admin-server/build.gradle.kts @@ -22,8 +22,6 @@ dependencies { implementation(libs.springboot.data.jdbc) implementation(libs.kotlin.reflect) testImplementation(libs.springboot.test) - implementation(libs.flyway.core) - implementation(libs.flyway.postgres) runtimeOnly(libs.postgres) runtimeOnly(libs.springboot.devtools) } diff --git a/modules/admin-server/src/main/resources/application.properties b/modules/admin-server/src/main/resources/application.properties index 0142bc6f..683495f2 100644 --- a/modules/admin-server/src/main/resources/application.properties +++ b/modules/admin-server/src/main/resources/application.properties @@ -7,13 +7,6 @@ spring.datasource.username=${DATASOURCE_USER} spring.datasource.password=${DATASOURCE_PASSWORD} spring.datasource.driver-class-name=org.postgresql.Driver -# Flyway -spring.flyway.enabled=false -spring.flyway.baseline-on-migrate = true -spring.flyway.clean-on-validation-error=true -spring.flyway.clean-disabled=false -spring.flyway.baseline-version=0 - # Mapping /actuator/health to /status management.endpoints.web.base-path=/ -management.endpoints.web.path-mapping.health=status +management.endpoints.web.path-mapping.health=status \ No newline at end of file diff --git a/modules/admin-server/src/main/resources/db/migration/V0.1.0__Account.sql b/modules/admin-server/src/main/resources/db/migration/V0.1.0__Account.sql deleted file mode 100644 index 2a3e2eb7..00000000 --- a/modules/admin-server/src/main/resources/db/migration/V0.1.0__Account.sql +++ /dev/null @@ -1,7 +0,0 @@ -CREATE TYPE "KMS_TYPE" AS ENUM ('LOCAL'); - -CREATE TABLE "account" ( - id SERIAL PRIMARY KEY, - username VARCHAR(255) UNIQUE NOT NULL, - kms "KMS_TYPE" NOT NULL DEFAULT 'LOCAL' -);