1 22 package org.jboss.test.security.container.auth.config; 23 24 import java.security.Principal ; 25 26 import javax.security.auth.Subject ; 27 import javax.servlet.http.HttpServlet ; 28 29 import org.jboss.security.SimplePrincipal; 30 import org.jboss.security.auth.container.modules.SimpleServerAuthModule; 31 import org.jboss.security.auth.message.HttpServletAuthParam; 32 import org.jboss.test.JBossTestCase; 33 34 36 42 public class SimpleServerAuthModuleTestCase extends JBossTestCase 43 { 44 private SimpleServerAuthModule module = null; 45 46 public SimpleServerAuthModuleTestCase(String name) 47 { 48 super(name); 49 } 50 51 public void testCreation() 52 { 53 Class [] clazzArr = new Class [] {HttpServlet .class}; 54 module = new SimpleServerAuthModule(clazzArr); 55 assertNotNull("Supported class types != null", module.getSupportedMessageTypes()); 56 assertEquals(clazzArr, module.getSupportedMessageTypes()); 57 module = null; 58 } 59 60 public void testValidateRequest() throws Exception 61 { 62 Class [] clazzArr = new Class [] {HttpServlet .class}; 63 module = new SimpleServerAuthModule(clazzArr); 64 Subject sub = createSubject(); 65 module.validateRequest(new HttpServletAuthParam(null,null), sub, sub, null ); 66 module = null; 67 } 68 69 public void testSecureResponse() throws Exception 70 { 71 module = new SimpleServerAuthModule(new Class [] {HttpServlet .class}); 73 Subject sub = createSubject(); 74 module.secureResponse(new HttpServletAuthParam(null,null), sub, null); 75 module = null; 76 } 77 78 private Subject createSubject() 79 { 80 Subject subj = new Subject (); 81 Principal principal = new SimplePrincipal("dummy"); 82 subj.getPrincipals().add(principal); 83 subj.getPublicCredentials().add("password"); 84 return subj; 85 } 86 } 87 | Popular Tags |