@@ -57,6 +57,7 @@ import java.util.*
5757import kotlin.test.assertEquals
5858import kotlin.test.assertNotEquals
5959import kotlin.test.assertNotNull
60+ import kotlin.test.assertNull
6061import kotlin.test.assertTrue
6162import org.junit.jupiter.api.BeforeAll
6263import org.junit.jupiter.api.BeforeEach
@@ -308,6 +309,58 @@ class RunnerServiceIntegrationTest : CsmRedisTestBase() {
308309 }
309310 }
310311
312+ @Test
313+ fun `update parentId on Runner delete` () {
314+ // Create a 3 level hierarchy: grandParent <- parent <- child
315+ val grandParentCreation =
316+ makeRunner(
317+ organizationSaved.id!! ,
318+ workspaceSaved.id!! ,
319+ solutionSaved.id!! ,
320+ )
321+ val grandParentRunner =
322+ runnerApiService.createRunner(
323+ organizationSaved.id!! , workspaceSaved.id!! , grandParentCreation)
324+ val parentCreation =
325+ makeRunner(
326+ organizationSaved.id!! ,
327+ workspaceSaved.id!! ,
328+ solutionSaved.id!! ,
329+ parentId = grandParentRunner.id)
330+ val parentRunner =
331+ runnerApiService.createRunner(organizationSaved.id!! , workspaceSaved.id!! , parentCreation)
332+ val childCreation =
333+ makeRunner(
334+ organizationSaved.id!! ,
335+ workspaceSaved.id!! ,
336+ solutionSaved.id!! ,
337+ parentId = parentRunner.id)
338+ val childRunner =
339+ runnerApiService.createRunner(organizationSaved.id!! , workspaceSaved.id!! , childCreation)
340+
341+ // Initial parents check
342+ assertEquals(grandParentRunner.id, parentRunner.parentId)
343+ assertEquals(parentRunner.id, childRunner.parentId)
344+
345+ // Delete intermediate parent, child should refer to grandParent
346+ runnerApiService.deleteRunner(organizationSaved.id!! , workspaceSaved.id!! , parentRunner.id!! )
347+ var newChildParentId =
348+ runnerApiService
349+ .getRunner(organizationSaved.id!! , workspaceSaved.id!! , childRunner.id!! )
350+ .parentId
351+ assertEquals(grandParentRunner.id, newChildParentId)
352+
353+ // Delete root grandParent, child should clear its parent
354+ runnerApiService.deleteRunner(
355+ organizationSaved.id!! , workspaceSaved.id!! , grandParentRunner.id!! )
356+ newChildParentId =
357+ runnerApiService
358+ .getRunner(organizationSaved.id!! , workspaceSaved.id!! , childRunner.id!! )
359+ .parentId
360+ assertNull(newChildParentId)
361+ }
362+
363+ @Test
311364 fun `test RBAC RunnerSecurity as Platform Admin` () {
312365 every { getCurrentAuthenticatedRoles(any()) } returns listOf (ROLE_PLATFORM_ADMIN )
313366
0 commit comments