kotest-extensions / io.kotest.extensions.system / withSecurityManager

withSecurityManager

inline fun <reified T> withSecurityManager(securityManager: SecurityManager?, block: () -> T): T

Replaces System Security Manager with securityManager

This function replaces the System Security Manager with the specified securityManager, executes block and then returns the original manager to its place. This will also happen if the original manager is null.

Attention: This code is subject to race conditions. As Java's System Manager is only one per JVM, this code will replace it. However, all other tests are going to use it if tests are running in parallel.