Skip to content

sdorra/shiro-unit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

shiro-unit

JUnit rule to simplify apache shiro unit tests.

Sample:

shiro.ini

[users]
trillian = secret, user

[roles]
admin = *
user = something:*

ShiroUnitTest.java

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();
}

Maven usage

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>

About

JUnit rule to simplify apache shiro unit tests.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages