-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #45364 from michalvavrik/feature/permissions-check…
…er-so-called-actions Don't treat colon as a permission-to-action separator in @permissionchecker value attribute
- Loading branch information
Showing
5 changed files
with
513 additions
and
58 deletions.
There are no files selected for viewing
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
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
45 changes: 45 additions & 0 deletions
45
...test/permissionsallowed/checker/MissingCheckerForInclusivePermsValidationFailureTest.java
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,45 @@ | ||
package io.quarkus.security.test.permissionsallowed.checker; | ||
|
||
import jakarta.inject.Singleton; | ||
|
||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.quarkus.security.PermissionChecker; | ||
import io.quarkus.security.PermissionsAllowed; | ||
import io.quarkus.security.identity.SecurityIdentity; | ||
import io.quarkus.test.QuarkusUnitTest; | ||
|
||
public class MissingCheckerForInclusivePermsValidationFailureTest { | ||
|
||
@RegisterExtension | ||
static final QuarkusUnitTest config = new QuarkusUnitTest() | ||
.assertException(t -> { | ||
Assertions.assertEquals(RuntimeException.class, t.getClass(), t.getMessage()); | ||
Assertions.assertTrue(t.getMessage().contains("@PermissionsAllowed annotation placed on")); | ||
Assertions.assertTrue( | ||
t.getMessage().contains("SecuredBean#securedBean' has inclusive relation between its permissions")); | ||
Assertions.assertTrue(t.getMessage().contains("you must also define")); | ||
Assertions.assertTrue(t.getMessage().contains("@PermissionChecker for 'checker:missing' permissions")); | ||
}); | ||
|
||
@Test | ||
public void test() { | ||
Assertions.fail(); | ||
} | ||
|
||
@Singleton | ||
public static class SecuredBean { | ||
|
||
@PermissionsAllowed(value = { "checker", "checker:missing" }, inclusive = true) | ||
public void securedBean() { | ||
// EMPTY | ||
} | ||
|
||
@PermissionChecker("checker") | ||
public boolean check(SecurityIdentity identity) { | ||
return false; | ||
} | ||
} | ||
} |
Oops, something went wrong.