Arquillian Shiro Extension

Sonatype helps open source projects to set up Maven repositories on https://oss.sonatype.org/

Categories

Categories

Arquillian Application Testing & Monitoring
GroupId

GroupId

com.github.rmannibucau
ArtifactId

ArtifactId

arquillian-extension-shiro
Last Version

Last Version

1.0.2
Release Date

Release Date

Type

Type

jar
Description

Description

Arquillian Shiro Extension
Sonatype helps open source projects to set up Maven repositories on https://oss.sonatype.org/
Source Code Management

Source Code Management

https://github.com/rmannibucau/arquillian-extension-shiro

Download arquillian-extension-shiro

How to add to project

<!-- https://jarcasting.com/artifacts/com.github.rmannibucau/arquillian-extension-shiro/ -->
<dependency>
    <groupId>com.github.rmannibucau</groupId>
    <artifactId>arquillian-extension-shiro</artifactId>
    <version>1.0.2</version>
</dependency>
// https://jarcasting.com/artifacts/com.github.rmannibucau/arquillian-extension-shiro/
implementation 'com.github.rmannibucau:arquillian-extension-shiro:1.0.2'
// https://jarcasting.com/artifacts/com.github.rmannibucau/arquillian-extension-shiro/
implementation ("com.github.rmannibucau:arquillian-extension-shiro:1.0.2")
'com.github.rmannibucau:arquillian-extension-shiro:jar:1.0.2'
<dependency org="com.github.rmannibucau" name="arquillian-extension-shiro" rev="1.0.2">
  <artifact name="arquillian-extension-shiro" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.github.rmannibucau', module='arquillian-extension-shiro', version='1.0.2')
)
libraryDependencies += "com.github.rmannibucau" % "arquillian-extension-shiro" % "1.0.2"
[com.github.rmannibucau/arquillian-extension-shiro "1.0.2"]

Dependencies

compile (4)

Group / Artifact Type Version
org.apache.shiro : shiro-core jar 1.2.2
org.jboss.arquillian.container : arquillian-container-test-impl-base jar 1.0.3.Final
org.apache.openejb : ziplock jar 1.5.1
org.jboss.shrinkwrap : shrinkwrap-impl-base jar 1.1.2

test (3)

Group / Artifact Type Version
org.apache.openejb : arquillian-tomee-remote jar 1.5.1
junit : junit jar 4.11
org.jboss.arquillian.junit : arquillian-junit-container jar 1.0.3.Final

Project Modules

There are no modules declared in this project.

Arquillian Extension Shiro

Target

Allow to run arquillian test methods in a shiro context.

Usage

First add the maven dependency:

<dependency>
  <groupId>com.github.rmannibucau</groupId>
  <artifactId>arquillian-extension-shiro</artifactId>
  <version>${arquillian.extension.shiro.version}</version>
</dependency>

Then decorate your test with com.github.rmannibucau.arquillian.shiro.api.LoggedWithSubject annotation.

Here are some examples:

// imports

@RunWith(Arquillian.class)
public class ShiroArquillianAPITest {
    @Deployment
    public static Archive<?> war() {
        return generateMyWar();
    }

    @Test
    @LoggedWithSubject("arquillian")
    public void checkUserIsLogged() {
        // logged as 'arquillian' with no role
    }

    @Test
    @LoggedWithSubject(value = "arquillian", roles = "*")
    public void checkUserHasRoles() {
        // logged as 'arquillian' with all roles
    }

    @Test
    @LoggedWithSubject(value = "foo", password = "bar", ini = "classpath:custom-shiro.ini")
    public void checkOverridedCustomIni() {
        // logged with user foo even if not in the specified ini file
    }

    @Test
    @LoggedWithSubject(value = "jboss", password = "arquillian", ini = "classpath:custom-shiro.ini")
    public void checkCustomIni() {
        // logged with user jboss
    }
}
Note
LoggedWithSubject can be put at class level

Versions

Version
1.0.2
1.0.1
1.0