11// SPDX-License-Identifier: EUPL-1.2
22// Copyright (C) 2026 Gemeente Utrecht
3- package com.baseflow.api.admin
3+ package com.baseflow.api.settings
44
55import com.auth0.jwt.JWT
66import com.auth0.jwt.algorithms.Algorithm
77import com.baseflow.api.apiJsonConfig
88import com.baseflow.api.documenten.routes.TestBase
9+ import com.baseflow.api.middleware.AuditContext
10+ import com.baseflow.api.settings.settingsModule
911import com.baseflow.api.wopi.wopi.WopiDocumentService
1012import com.baseflow.config.ApplicationConfig
1113import com.baseflow.config.BestandsDeelConfig
@@ -19,7 +21,6 @@ import com.baseflow.services.NotificationService
1921import com.baseflow.services.ObjectInformatieObjectService
2022import com.baseflow.services.StorageService
2123import com.baseflow.services.WopiSlatService
22- import com.baseflow.api.middleware.AuditContext
2324import io.ktor.client.request.*
2425import io.ktor.client.statement.*
2526import io.ktor.http.*
@@ -45,7 +46,7 @@ import kotlin.test.Test
4546import kotlin.test.assertEquals
4647
4748/* *
48- * Tests the admin role-check plugin in `AdminRoutes .kt`.
49+ * Tests the settings role-check plugin in `SettingsRoutes .kt`.
4950 *
5051 * The role-check runs on the [AuthenticationChecked] hook and verifies that the
5152 * authenticated principal carries the required role (`dmf-admin` by default).
@@ -153,7 +154,7 @@ class AdminRoleCheckTest : TestBase("admin_role_check") {
153154 }
154155 }
155156
156- adminModule (useAuthentication = true )
157+ settingsModule (useAuthentication = true )
157158 }
158159
159160 // ── No / invalid auth ─────────────────────────────────────────────────────
@@ -162,8 +163,7 @@ class AdminRoleCheckTest : TestBase("admin_role_check") {
162163 fun `request without Authorization header returns 401` () = testApplication {
163164 application { setupWithAuth() }
164165
165- // No principal → role-check skips → auth challenge fires → 401.
166- val response = client.get(" /admin/storage-repositories" )
166+ val response = client.get(" /settings/storage-repositories" )
167167
168168 assertEquals(HttpStatusCode .Unauthorized , response.status)
169169 }
@@ -172,8 +172,7 @@ class AdminRoleCheckTest : TestBase("admin_role_check") {
172172 fun `request with an invalid token returns 401` () = testApplication {
173173 application { setupWithAuth() }
174174
175- // Invalid token → JWT validator returns null → auth challenge fires → 401.
176- val response = client.get(" /admin/storage-repositories" ) {
175+ val response = client.get(" /settings/storage-repositories" ) {
177176 header(HttpHeaders .Authorization , " Bearer this.is.not.valid" )
178177 }
179178
@@ -186,7 +185,7 @@ class AdminRoleCheckTest : TestBase("admin_role_check") {
186185 fun `valid token with no role claims returns 403` () = testApplication {
187186 application { setupWithAuth() }
188187
189- val response = client.get(" /admin /storage-repositories" ) {
188+ val response = client.get(" /settings /storage-repositories" ) {
190189 header(HttpHeaders .Authorization , " Bearer ${tokenWithNoRoles()} " )
191190 }
192191
@@ -197,7 +196,7 @@ class AdminRoleCheckTest : TestBase("admin_role_check") {
197196 fun `valid token with a different realm_access role returns 403` () = testApplication {
198197 application { setupWithAuth() }
199198
200- val response = client.get(" /admin /storage-repositories" ) {
199+ val response = client.get(" /settings /storage-repositories" ) {
201200 header(HttpHeaders .Authorization , " Bearer ${tokenWithKeycloakRoles(OTHER_ROLE )} " )
202201 }
203202
@@ -208,7 +207,7 @@ class AdminRoleCheckTest : TestBase("admin_role_check") {
208207 fun `valid token with a different top-level role returns 403` () = testApplication {
209208 application { setupWithAuth() }
210209
211- val response = client.get(" /admin /storage-repositories" ) {
210+ val response = client.get(" /settings /storage-repositories" ) {
212211 header(HttpHeaders .Authorization , " Bearer ${tokenWithZgwRoles(OTHER_ROLE )} " )
213212 }
214213
@@ -219,7 +218,7 @@ class AdminRoleCheckTest : TestBase("admin_role_check") {
219218 fun `403 response body is a problem detail with status 403` () = testApplication {
220219 application { setupWithAuth() }
221220
222- val response = client.get(" /admin /storage-repositories" ) {
221+ val response = client.get(" /settings /storage-repositories" ) {
223222 header(HttpHeaders .Authorization , " Bearer ${tokenWithNoRoles()} " )
224223 }
225224
@@ -234,7 +233,7 @@ class AdminRoleCheckTest : TestBase("admin_role_check") {
234233 fun `token with admin role in realm_access returns 200` () = testApplication {
235234 application { setupWithAuth() }
236235
237- val response = client.get(" /admin /storage-repositories" ) {
236+ val response = client.get(" /settings /storage-repositories" ) {
238237 header(HttpHeaders .Authorization , " Bearer ${tokenWithKeycloakRoles(ADMIN_ROLE )} " )
239238 }
240239
@@ -245,7 +244,7 @@ class AdminRoleCheckTest : TestBase("admin_role_check") {
245244 fun `token with admin role alongside other roles in realm_access returns 200` () = testApplication {
246245 application { setupWithAuth() }
247246
248- val response = client.get(" /admin /storage-repositories" ) {
247+ val response = client.get(" /settings /storage-repositories" ) {
249248 header(HttpHeaders .Authorization , " Bearer ${tokenWithKeycloakRoles(OTHER_ROLE , ADMIN_ROLE , " yet-another" )} " )
250249 }
251250
@@ -258,7 +257,7 @@ class AdminRoleCheckTest : TestBase("admin_role_check") {
258257 fun `token with admin role in top-level roles claim returns 200` () = testApplication {
259258 application { setupWithAuth() }
260259
261- val response = client.get(" /admin /storage-repositories" ) {
260+ val response = client.get(" /settings /storage-repositories" ) {
262261 header(HttpHeaders .Authorization , " Bearer ${tokenWithZgwRoles(ADMIN_ROLE )} " )
263262 }
264263
@@ -269,7 +268,7 @@ class AdminRoleCheckTest : TestBase("admin_role_check") {
269268 fun `token with admin role alongside other roles in top-level roles returns 200` () = testApplication {
270269 application { setupWithAuth() }
271270
272- val response = client.get(" /admin /storage-repositories" ) {
271+ val response = client.get(" /settings /storage-repositories" ) {
273272 header(HttpHeaders .Authorization , " Bearer ${tokenWithZgwRoles(OTHER_ROLE , ADMIN_ROLE )} " )
274273 }
275274
@@ -282,7 +281,7 @@ class AdminRoleCheckTest : TestBase("admin_role_check") {
282281 fun `role check applies to POST sub-route` () = testApplication {
283282 application { setupWithAuth() }
284283
285- val response = client.post(" /admin /storage-repositories" ) {
284+ val response = client.post(" /settings /storage-repositories" ) {
286285 header(HttpHeaders .Authorization , " Bearer ${tokenWithNoRoles()} " )
287286 contentType(ContentType .Application .Json )
288287 setBody(" {}" )
@@ -296,7 +295,7 @@ class AdminRoleCheckTest : TestBase("admin_role_check") {
296295 fun `role check applies to nested PUT sub-route` () = testApplication {
297296 application { setupWithAuth() }
298297
299- val response = client.put(" /admin /storage-repositories/default" ) {
298+ val response = client.put(" /settings /storage-repositories/default" ) {
300299 header(HttpHeaders .Authorization , " Bearer ${tokenWithNoRoles()} " )
301300 contentType(ContentType .Application .Json )
302301 setBody(" {}" )
0 commit comments