JUnit rule to simplify apache shiro unit tests.
JUnit rule to simplify apache shiro unit tests.
[users]
trillian = secret, user
[roles]
admin = *
user = something:*
public class ShiroUnitTest {
@Test
@SubjectAware(
username = "trillian",
password = "secret",
configuration = "classpath:path/to/shiro.ini"
)
public void testMethod(){
Subject subject = SecurityUtils.getSubject();
assertNotNull(subject);
assertTrue(subject.isAuthenticated());
assertEquals("trillian", subject.getPrincipal());
}
@Rule
public ShiroRule rule = new ShiroRule();
}
Artifacts are deployed to Maven Central. To use, drop this in your pom.xml:
<dependency>
<groupId>com.github.sdorra</groupId>
<artifactId>shiro-unit</artifactId>
<version>1.0.0</version>
</dependency>