Skip to content

Commit fc0285d

Browse files
none was not in roles definition and thus was unassignable
1 parent fabdfbd commit fc0285d

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

src/main/kotlin/com/cosmotech/api/rbac/RolesDefinition.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ const val PERMISSION_DELETE = "delete"
2222
const val PERMISSION_LAUNCH = "launch"
2323
const val PERMISSION_VALIDATE = "validate"
2424

25+
val NO_PERMISSIONS = emptyList<String>()
26+
2527
val COMMON_ROLE_READER_PERMISSIONS = listOf(PERMISSION_READ)
2628
val COMMON_ROLE_USER_PERMISSIONS =
2729
listOf(PERMISSION_READ, PERMISSION_READ_SECURITY, PERMISSION_CREATE_CHILDREN)
@@ -92,6 +94,7 @@ fun getCommonRolesDefinition(): RolesDefinition {
9294
return RolesDefinition(
9395
permissions =
9496
mutableMapOf(
97+
ROLE_NONE to NO_PERMISSIONS,
9598
ROLE_VIEWER to COMMON_ROLE_READER_PERMISSIONS,
9699
ROLE_USER to COMMON_ROLE_USER_PERMISSIONS,
97100
ROLE_EDITOR to COMMON_ROLE_EDITOR_PERMISSIONS,
@@ -104,6 +107,7 @@ fun getScenarioRolesDefinition(): RolesDefinition {
104107
return RolesDefinition(
105108
permissions =
106109
mutableMapOf(
110+
ROLE_NONE to NO_PERMISSIONS,
107111
ROLE_VIEWER to SCENARIO_ROLE_VIEWER_PERMISSIONS,
108112
ROLE_EDITOR to SCENARIO_ROLE_EDITOR_PERMISSIONS,
109113
ROLE_VALIDATOR to SCENARIO_ROLE_VALIDATOR_PERMISSIONS,

src/test/kotlin/com/cosmotech/api/rbac/CsmRbacTests.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -634,6 +634,7 @@ class CsmRbacTests {
634634
fun `get default role definition permissions`() {
635635
val expected: MutableMap<String, List<String>> =
636636
mutableMapOf(
637+
ROLE_NONE to NO_PERMISSIONS,
637638
ROLE_VIEWER to COMMON_ROLE_READER_PERMISSIONS,
638639
ROLE_USER to COMMON_ROLE_USER_PERMISSIONS,
639640
ROLE_EDITOR to COMMON_ROLE_EDITOR_PERMISSIONS,
@@ -655,6 +656,7 @@ class CsmRbacTests {
655656
definition.permissions.put(customRole, customRolePermissions)
656657
val expected: MutableMap<String, List<String>> =
657658
mutableMapOf(
659+
ROLE_NONE to NO_PERMISSIONS,
658660
ROLE_VIEWER to COMMON_ROLE_READER_PERMISSIONS,
659661
ROLE_USER to COMMON_ROLE_USER_PERMISSIONS,
660662
ROLE_EDITOR to COMMON_ROLE_EDITOR_PERMISSIONS,

0 commit comments

Comments
 (0)