-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(authorization): ignore unknown granted permissions
fix MODELIX-1018
- Loading branch information
Showing
3 changed files
with
28 additions
and
14 deletions.
There are no files selected for viewing
10 changes: 8 additions & 2 deletions
10
authorization/src/main/kotlin/org/modelix/authorization/permissions/PermissionEvaluator.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 0 additions & 12 deletions
12
model-server/src/test/kotlin/permissions/PermissionTestBase.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
model-server/src/test/kotlin/permissions/UnknownPermissionGrantTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package permissions | ||
|
||
import org.modelix.authorization.permissions.PermissionEvaluator | ||
import org.modelix.authorization.permissions.PermissionParts | ||
import org.modelix.authorization.permissions.SchemaInstance | ||
import org.modelix.model.server.ModelServerPermissionSchema | ||
import kotlin.test.Test | ||
|
||
class UnknownPermissionGrantTest { | ||
/** | ||
* A token may contain granted permission of other services. They should not result in an exception. | ||
*/ | ||
@Test | ||
fun `unknown permission in token is ignored`() { | ||
val evaluator = PermissionEvaluator(SchemaInstance(ModelServerPermissionSchema.SCHEMA)) | ||
for (i in 0..5) { | ||
evaluator.grantPermission(PermissionParts(ModelServerPermissionSchema.repository("myFirstRepo").branch("main").push.parts.take(i)) + "some-non-existent-permission") | ||
} | ||
} | ||
} |