File tree Expand file tree Collapse file tree 2 files changed +4
-14
lines changed
main/kotlin/com/cosmotech/dataset/service
test/kotlin/com/cosmotech/dataset/service Expand file tree Collapse file tree 2 files changed +4
-14
lines changed Original file line number Diff line number Diff line change @@ -560,14 +560,6 @@ class DatasetServiceImpl(
560560 override fun deleteDataset (organizationId : String , datasetId : String ) {
561561 val dataset = getVerifiedDataset(organizationId, datasetId, PERMISSION_DELETE )
562562
563- val isPlatformAdmin =
564- getCurrentAuthenticatedRoles(csmPlatformProperties).contains(ROLE_PLATFORM_ADMIN )
565- if (dataset.ownerId != getCurrentAuthenticatedUserName(csmPlatformProperties) &&
566- ! isPlatformAdmin) {
567- // TODO Only the owner or an admin should be able to perform this operation
568- throw CsmAccessForbiddenException (" You are not allowed to delete this Resource" )
569- }
570-
571563 csmJedisPool.resource.use { jedis ->
572564 if (jedis.exists(dataset.twingraphId!! )) {
573565 jedis.del(dataset.twingraphId!! )
Original file line number Diff line number Diff line change @@ -5,7 +5,6 @@ package com.cosmotech.dataset.service
55import com.cosmotech.api.config.CsmPlatformProperties
66import com.cosmotech.api.events.CsmEventPublisher
77import com.cosmotech.api.events.TwingraphImportJobInfoRequest
8- import com.cosmotech.api.exceptions.CsmAccessForbiddenException
98import com.cosmotech.api.exceptions.CsmResourceNotFoundException
109import com.cosmotech.api.id.CsmIdGenerator
1110import com.cosmotech.api.rbac.CsmAdmin
@@ -390,13 +389,12 @@ class DatasetServiceImplTests {
390389 }
391390
392391 @Test
393- fun `deleteDataset should throw CsmAccessForbiddenException ` () {
394- val dataset = baseDataset()
392+ fun `deleteDataset do not throw error - rbac is disabled ` () {
393+ val dataset = baseDataset(). apply { twingraphId = " mytwingraphId " }
395394 every { datasetRepository.findBy(ORGANIZATION_ID , DATASET_ID ) } returns Optional .of(dataset)
396395 every { getCurrentAuthenticatedUserName(csmPlatformProperties) } returns " my.account-tester"
397- assertThrows<CsmAccessForbiddenException > {
398- datasetService.deleteDataset(ORGANIZATION_ID , DATASET_ID )
399- }
396+ datasetService.deleteDataset(ORGANIZATION_ID , DATASET_ID )
397+ verify(exactly = 1 ) { datasetRepository.delete(any()) }
400398 }
401399
402400 @Test
You can’t perform that action at this time.
0 commit comments