Skip to content

Commit 4d92061

Browse files
committed
Remove not necessary check on ownership in dataset deletion endpoint
1 parent bcd1522 commit 4d92061

File tree

2 files changed

+4
-14
lines changed

2 files changed

+4
-14
lines changed

dataset/src/main/kotlin/com/cosmotech/dataset/service/DatasetServiceImpl.kt

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff 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!!)

dataset/src/test/kotlin/com/cosmotech/dataset/service/DatasetServiceImplTests.kt

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ package com.cosmotech.dataset.service
55
import com.cosmotech.api.config.CsmPlatformProperties
66
import com.cosmotech.api.events.CsmEventPublisher
77
import com.cosmotech.api.events.TwingraphImportJobInfoRequest
8-
import com.cosmotech.api.exceptions.CsmAccessForbiddenException
98
import com.cosmotech.api.exceptions.CsmResourceNotFoundException
109
import com.cosmotech.api.id.CsmIdGenerator
1110
import 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

0 commit comments

Comments
 (0)