Remove adapter test dependencies on MockPrincipal.

This commit is contained in:
Ben Alex 2004-11-01 02:08:42 +00:00
parent 35cdd24abf
commit 29c8e110f5
3 changed files with 18 additions and 9 deletions

View File

@ -19,7 +19,6 @@ import junit.framework.TestCase;
import net.sf.acegisecurity.GrantedAuthority;
import net.sf.acegisecurity.GrantedAuthorityImpl;
import net.sf.acegisecurity.adapters.MockPrincipal;
import net.sf.acegisecurity.adapters.PrincipalAcegiUserToken;
import org.apache.catalina.LifecycleException;
@ -243,7 +242,11 @@ public class CatalinaAcegiUserRealmTests extends TestCase {
public void testHasRoleWithAPrincipalTheAdapterDidNotCreateFails() {
CatalinaAcegiUserRealm adapter = new CatalinaAcegiUserRealm();
assertTrue(!adapter.hasRole(new MockPrincipal(), "ROLE_ONE"));
assertTrue(!adapter.hasRole(new Principal() {
public String getName() {
return "MockPrincipal";
}
}, "ROLE_ONE"));
}
public void testHasRoleWithPrincipalAcegiUserToken() {
@ -261,8 +264,8 @@ public class CatalinaAcegiUserRealmTests extends TestCase {
throws Exception {
CatalinaAcegiUserRealm adapter = new CatalinaAcegiUserRealm();
URL url = Thread.currentThread().getContextClassLoader().getResource(
"net/sf/acegisecurity/adapters/" + fileName);
URL url = Thread.currentThread().getContextClassLoader().getResource("net/sf/acegisecurity/adapters/"
+ fileName);
if (url == null) {
throw new Exception("Could not find " + fileName

View File

@ -19,7 +19,6 @@ import junit.framework.TestCase;
import net.sf.acegisecurity.GrantedAuthority;
import net.sf.acegisecurity.GrantedAuthorityImpl;
import net.sf.acegisecurity.adapters.MockPrincipal;
import net.sf.acegisecurity.adapters.PrincipalAcegiUserToken;
import org.springframework.mock.web.MockHttpServletRequest;
@ -115,7 +114,11 @@ public class JbossIntegrationFilterTests extends TestCase {
public void testReturnsNullIfPrincipalNotAnAuthenticationImplementation() {
JbossIntegrationFilter filter = new MockJbossIntegrationFilter(new MockInitialContext(
makeIntoSubject(new MockPrincipal())));
makeIntoSubject(new Principal() {
public String getName() {
return "MockPrincipal";
}
})));
assertEquals(null,
filter.extractFromContainer(new MockHttpServletRequest(null, null)));
}

View File

@ -19,7 +19,6 @@ import junit.framework.TestCase;
import net.sf.acegisecurity.GrantedAuthority;
import net.sf.acegisecurity.GrantedAuthorityImpl;
import net.sf.acegisecurity.adapters.MockPrincipal;
import net.sf.acegisecurity.adapters.PrincipalAcegiUserToken;
import java.security.Principal;
@ -257,8 +256,12 @@ public class ResinAcegiAuthenticatorTests extends TestCase {
"net/sf/acegisecurity/adapters/adaptertest-valid.xml");
adapter.setKey(ADAPTER_KEY);
adapter.init();
assertTrue(!adapter.isUserInRole(null, null, null, new MockPrincipal(),
"ROLE_ONE"));
assertTrue(!adapter.isUserInRole(null, null, null,
new Principal() {
public String getName() {
return "MockPrincipal";
}
}, "ROLE_ONE"));
}
public void testHasRoleWithPrincipalAcegiUserToken()