Skip to content

Commit a54c8f3

Browse files
committed
Add test
1 parent 5129293 commit a54c8f3

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

security/core/src/main/java/org/seedstack/seed/security/internal/ShiroRealmAdapter.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
* License, v. 2.0. If a copy of the MPL was not distributed with this
66
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
77
*/
8+
89
package org.seedstack.seed.security.internal;
910

1011
import java.util.ArrayList;
@@ -149,7 +150,7 @@ public String getAuthorizationCacheName() {
149150
return realm.getClass().getName() + ".authorizationCache";
150151
}
151152

152-
Realm getRealm() {
153+
public Realm getRealm() {
153154
return realm;
154155
}
155156

security/core/src/test/java/org/seedstack/seed/security/SecurityIT.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,20 @@
55
* License, v. 2.0. If a copy of the MPL was not distributed with this
66
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
77
*/
8+
89
package org.seedstack.seed.security;
910

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

14+
import java.util.Set;
1315
import javax.inject.Inject;
1416
import javax.inject.Named;
1517
import org.apache.shiro.SecurityUtils;
1618
import org.apache.shiro.authc.AuthenticationException;
1719
import org.apache.shiro.authc.UsernamePasswordToken;
1820
import org.apache.shiro.mgt.SecurityManager;
21+
import org.apache.shiro.realm.Realm;
1922
import org.apache.shiro.subject.Subject;
2023
import org.junit.Test;
2124
import org.junit.runner.RunWith;
@@ -33,6 +36,8 @@ public class SecurityIT {
3336
@Inject
3437
@Named("test")
3538
private SecurityManager testSecurityManager;
39+
@Inject
40+
private Set<Realm> realms;
3641

3742
@Test
3843
@WithUser(id = "Obiwan", password = "yodarulez")
@@ -110,4 +115,9 @@ public void anakinShouldHaveCustomizedPrincipal() {
110115
public void sessionsShouldBeEnabledByDefault() {
111116
assertThat(SecurityUtils.getSubject().getSession(false)).isNotNull();
112117
}
118+
119+
@Test
120+
public void realmsCanBeInjected() {
121+
assertThat(realms).hasSize(2);
122+
}
113123
}

0 commit comments

Comments
 (0)