Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sdorra/junit-shiro-extension
Simplify unit tests with JUnit 5 and Apache Shiro
https://github.com/sdorra/junit-shiro-extension
apache-shiro java junit5 junit5-extension testing
Last synced: 25 days ago
JSON representation
Simplify unit tests with JUnit 5 and Apache Shiro
- Host: GitHub
- URL: https://github.com/sdorra/junit-shiro-extension
- Owner: sdorra
- License: mit
- Created: 2021-03-15T07:15:38.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2021-03-24T16:36:20.000Z (over 3 years ago)
- Last Synced: 2024-04-14T03:13:05.302Z (7 months ago)
- Topics: apache-shiro, java, junit5, junit5-extension, testing
- Language: Java
- Homepage:
- Size: 545 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# JUnit Shiro Extension
Simplify unit tests with JUnit 5 and Apache Shiro.
## Usage
```java
@ExtendWith(ShiroExtension.class)
@SubjectAware(
value = "trillian",
roles = "user",
permissions = "one:*"
)
class ShiroExtensionTest {@Test
void shouldHavePreparedSubject() {
Subject subject = SecurityUtils.getSubject();
assertThat(subject.getPrincipal()).isEqualTo("trillian");
assertThat(subject.hasRole("user")).isTrue();
assertThat(subject.isPermitted("one:dot:one")).isTrue();
}}
```The `SubjectAware` annotation can be placed on classes, nested classes or on methods.
Roles and permissions are merged. If the `value` is of `SubjectAware` is empty, no subject is bound.For more samples have a look at the [ShiroExtensionTest](lib/src/test/java/org/github/sdorra/jse/ShiroExtensionTest.java).
## Installation
Get the latest stable version from [![Maven Central](https://img.shields.io/maven-central/v/com.github.sdorra/junit-shiro-extension.svg)](https://search.maven.org/search?q=g:com.github.sdorra%20a:junit-shiro-extension)
### Gradle
```groovy
testImplementation 'com.github.sdorra:junit-shiro-extension:x.y.z'
```### Maven
```xml
com.github.sdorra
junit-shiro-extension
x.y.z
test```
## License
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details