Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
adrienlauer committed Dec 16, 2019
1 parent 5129293 commit a54c8f3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/

package org.seedstack.seed.security.internal;

import java.util.ArrayList;
Expand Down Expand Up @@ -149,7 +150,7 @@ public String getAuthorizationCacheName() {
return realm.getClass().getName() + ".authorizationCache";
}

Realm getRealm() {
public Realm getRealm() {
return realm;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,20 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/

package org.seedstack.seed.security;

import static org.assertj.core.api.Assertions.assertThat;
import static org.seedstack.seed.security.principals.Principals.getSimplePrincipalByName;

import java.util.Set;
import javax.inject.Inject;
import javax.inject.Named;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authc.AuthenticationException;
import org.apache.shiro.authc.UsernamePasswordToken;
import org.apache.shiro.mgt.SecurityManager;
import org.apache.shiro.realm.Realm;
import org.apache.shiro.subject.Subject;
import org.junit.Test;
import org.junit.runner.RunWith;
Expand All @@ -33,6 +36,8 @@ public class SecurityIT {
@Inject
@Named("test")
private SecurityManager testSecurityManager;
@Inject
private Set<Realm> realms;

@Test
@WithUser(id = "Obiwan", password = "yodarulez")
Expand Down Expand Up @@ -110,4 +115,9 @@ public void anakinShouldHaveCustomizedPrincipal() {
public void sessionsShouldBeEnabledByDefault() {
assertThat(SecurityUtils.getSubject().getSession(false)).isNotNull();
}

@Test
public void realmsCanBeInjected() {
assertThat(realms).hasSize(2);
}
}

0 comments on commit a54c8f3

Please sign in to comment.