Skip to content

Commit 7ebea3e

Browse files
committed
Enhance test coverage by adding new test cases for AppConfigTest, ApiResponseTest, and ShareServiceTest, focusing on configuration options and error propagation. Improve error handling in ThumbnailCacheTest and StorageServiceTest. Update collaboration-related tests to include new use cases for content operations. Revise TEST_COVERAGE_ACTION_PLAN.md to reflect recent improvements and new test additions.
1 parent 6f7f3a2 commit 7ebea3e

31 files changed

Lines changed: 2535 additions & 5 deletions

File tree

backend/api/src/test/kotlin/com/vaultstadio/api/config/AppConfigTest.kt

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import org.junit.jupiter.api.DisplayName
88
import org.junit.jupiter.api.Nested
99
import org.junit.jupiter.api.Test
1010
import kotlin.test.assertEquals
11+
import kotlin.test.assertFalse
1112
import kotlin.test.assertNotNull
1213
import kotlin.test.assertTrue
1314
import kotlin.time.Duration.Companion.days
@@ -65,6 +66,18 @@ class AppConfigTest {
6566
assertEquals("http://localhost:3000", origins[0])
6667
assertEquals("http://localhost:5173", origins[1])
6768
}
69+
70+
@Test
71+
fun `should support development flag`() {
72+
val config = HttpServerConfig(
73+
host = "127.0.0.1",
74+
port = 9000,
75+
development = true,
76+
corsAllowedOrigins = listOf("*"),
77+
)
78+
assertTrue(config.development)
79+
assertEquals(9000, config.port)
80+
}
6881
}
6982

7083
@Nested
@@ -103,6 +116,40 @@ class AppConfigTest {
103116
assertTrue(config.idleTimeout > 0)
104117
assertTrue(config.connectionTimeout > 0)
105118
}
119+
120+
@Test
121+
fun `should support runMigrations false`() {
122+
val config = DbConfig(
123+
url = "jdbc:postgresql://localhost:5432/app",
124+
user = "u",
125+
password = "p",
126+
driver = "org.postgresql.Driver",
127+
maxPoolSize = 5,
128+
minIdle = 1,
129+
idleTimeout = 300000,
130+
connectionTimeout = 10000,
131+
maxLifetime = 900000,
132+
runMigrations = false,
133+
)
134+
assertFalse(config.runMigrations)
135+
}
136+
137+
@Test
138+
fun `should support runMigrations true`() {
139+
val config = DbConfig(
140+
url = "jdbc:postgresql://localhost:5432/app",
141+
user = "u",
142+
password = "p",
143+
driver = "org.postgresql.Driver",
144+
maxPoolSize = 5,
145+
minIdle = 1,
146+
idleTimeout = 300000,
147+
connectionTimeout = 10000,
148+
maxLifetime = 900000,
149+
runMigrations = true,
150+
)
151+
assertTrue(config.runMigrations)
152+
}
106153
}
107154

108155
@Nested
@@ -154,6 +201,30 @@ class AppConfigTest {
154201
fun `StorageType has exactly three values`() {
155202
assertEquals(3, StorageType.entries.size)
156203
}
204+
205+
@Test
206+
fun `StorageConfig with S3 type holds s3 config`() {
207+
val s3Config = S3Config(
208+
endpoint = "http://minio:9000",
209+
region = "us-east-1",
210+
bucket = "vault",
211+
accessKey = "key",
212+
secretKey = "secret",
213+
usePathStyle = true,
214+
)
215+
val config = StorageConfig(
216+
type = StorageType.S3,
217+
localPath = "./data/storage",
218+
tempPath = "./data/temp",
219+
maxFileSize = 5L * 1024 * 1024 * 1024,
220+
allowedMimeTypes = listOf("*"),
221+
s3 = s3Config,
222+
)
223+
assertEquals(StorageType.S3, config.type)
224+
val s3 = requireNotNull(config.s3)
225+
assertEquals("http://minio:9000", s3.endpoint)
226+
assertEquals("vault", s3.bucket)
227+
}
157228
}
158229

159230
@Nested
@@ -186,6 +257,20 @@ class AppConfigTest {
186257
assertEquals("us-east-1", config.region)
187258
assertTrue(config.usePathStyle)
188259
}
260+
261+
@Test
262+
fun `should support usePathStyle false for AWS S3`() {
263+
val config = S3Config(
264+
endpoint = "https://s3.amazonaws.com",
265+
region = "eu-west-1",
266+
bucket = "my-bucket",
267+
accessKey = "ak",
268+
secretKey = "sk",
269+
usePathStyle = false,
270+
)
271+
assertFalse(config.usePathStyle)
272+
assertEquals("my-bucket", config.bucket)
273+
}
189274
}
190275

191276
@Nested
@@ -273,6 +358,26 @@ class AppConfigTest {
273358
assertTrue(config.rateLimitRequests > 0)
274359
assertTrue(config.rateLimitWindowSeconds > 0)
275360
}
361+
362+
@Test
363+
fun `should support optional federation keys`() {
364+
val config = SecurityConfig(
365+
jwtSecret = "test-secret-key-minimum-32-characters-long",
366+
jwtIssuer = "vaultstadio",
367+
jwtAudience = "vaultstadio-api",
368+
sessionDuration = 24.hours,
369+
refreshTokenDuration = 30.days,
370+
bcryptRounds = 12,
371+
rateLimitEnabled = false,
372+
rateLimitRequests = 50,
373+
rateLimitWindowSeconds = 120,
374+
federationPublicKey = "public-key-pem",
375+
federationPrivateKey = "private-key-pem",
376+
)
377+
assertEquals("public-key-pem", config.federationPublicKey)
378+
assertEquals("private-key-pem", config.federationPrivateKey)
379+
assertFalse(config.rateLimitEnabled)
380+
}
276381
}
277382

278383
@Nested
@@ -316,6 +421,18 @@ class AppConfigTest {
316421

317422
assertTrue(enabledPlugins.isEmpty())
318423
}
424+
425+
@Test
426+
fun `should support autoLoad false`() {
427+
val config = PluginsConfig(
428+
directory = "/opt/plugins",
429+
autoLoad = false,
430+
enabledPlugins = emptyList(),
431+
)
432+
433+
assertFalse(config.autoLoad)
434+
assertEquals("/opt/plugins", config.directory)
435+
}
319436
}
320437

321438
@Nested

0 commit comments

Comments
 (0)