Skip to content

Commit c2648e7

Browse files
committed
[SDCOSMO-2480] Fix runner security property visibility for validator
1 parent 78f6547 commit c2648e7

File tree

2 files changed

+47
-1
lines changed

2 files changed

+47
-1
lines changed

runner/src/integrationTest/kotlin/com/cosmotech/runner/service/RunnerServiceIntegrationTest.kt

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import com.cosmotech.api.rbac.ROLE_ADMIN
1414
import com.cosmotech.api.rbac.ROLE_EDITOR
1515
import com.cosmotech.api.rbac.ROLE_NONE
1616
import com.cosmotech.api.rbac.ROLE_USER
17+
import com.cosmotech.api.rbac.ROLE_VALIDATOR
1718
import com.cosmotech.api.rbac.ROLE_VIEWER
1819
import com.cosmotech.api.security.ROLE_ORGANIZATION_USER
1920
import com.cosmotech.api.security.ROLE_PLATFORM_ADMIN
@@ -1064,6 +1065,49 @@ class RunnerServiceIntegrationTest : CsmRedisTestBase() {
10641065
}
10651066
}
10661067

1068+
@Test
1069+
fun `As a validator, I can see whole security property for getRunner`() {
1070+
every { getCurrentAccountIdentifier(any()) } returns defaultName
1071+
runner = makeRunner(userName = defaultName, role = ROLE_VALIDATOR)
1072+
runnerSaved = runnerApiService.createRunner(organizationSaved.id!!, workspaceSaved.id!!, runner)
1073+
1074+
runnerSaved =
1075+
runnerApiService.getRunner(organizationSaved.id!!, workspaceSaved.id!!, runnerSaved.id!!)
1076+
1077+
assertEquals(2, runnerSaved.security!!.accessControlList.size)
1078+
assertEquals(ROLE_NONE, runnerSaved.security!!.default)
1079+
assertEquals(
1080+
RunnerAccessControl(CONNECTED_ADMIN_USER, ROLE_ADMIN),
1081+
runnerSaved.security!!.accessControlList[0])
1082+
assertEquals(
1083+
RunnerAccessControl(defaultName, ROLE_VALIDATOR),
1084+
runnerSaved.security!!.accessControlList[1])
1085+
}
1086+
1087+
@Test
1088+
fun `As a validator, I can see whole security property for listRunners`() {
1089+
every { getCurrentAccountIdentifier(any()) } returns defaultName
1090+
organizationSaved = organizationApiService.registerOrganization(organization)
1091+
datasetSaved = datasetApiService.createDataset(organizationSaved.id!!, dataset)
1092+
materializeTwingraph()
1093+
solutionSaved = solutionApiService.createSolution(organizationSaved.id!!, solution)
1094+
workspace = makeWorkspace()
1095+
workspaceSaved = workspaceApiService.createWorkspace(organizationSaved.id!!, workspace)
1096+
runner = makeRunner(userName = defaultName, role = ROLE_VALIDATOR)
1097+
runnerSaved = runnerApiService.createRunner(organizationSaved.id!!, workspaceSaved.id!!, runner)
1098+
1099+
val runners =
1100+
runnerApiService.listRunners(organizationSaved.id!!, workspaceSaved.id!!, null, null)
1101+
runners.forEach {
1102+
assertEquals(2, it.security!!.accessControlList.size)
1103+
assertEquals(ROLE_NONE, it.security!!.default)
1104+
assertEquals(
1105+
RunnerAccessControl(CONNECTED_ADMIN_USER, ROLE_ADMIN), it.security!!.accessControlList[0])
1106+
assertEquals(
1107+
RunnerAccessControl(defaultName, ROLE_VALIDATOR), it.security!!.accessControlList[1])
1108+
}
1109+
}
1110+
10671111
private fun makeConnector(name: String = "name"): Connector {
10681112
return Connector(
10691113
key = UUID.randomUUID().toString(),

runner/src/main/kotlin/com/cosmotech/runner/service/RunnerService.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,9 @@ class RunnerService(
6363
) : CsmPhoenixService() {
6464

6565
fun updateSecurityVisibility(runner: Runner): Runner {
66-
if (csmRbac.check(runner.getRbac(), PERMISSION_READ_SECURITY).not()) {
66+
if (csmRbac
67+
.check(runner.getRbac(), PERMISSION_READ_SECURITY, getRunnerRolesDefinition())
68+
.not()) {
6769
val username = getCurrentAccountIdentifier(csmPlatformProperties)
6870
val retrievedAC = runner.security!!.accessControlList.firstOrNull { it.id == username }
6971
if (retrievedAC != null) {

0 commit comments

Comments
 (0)