craigmcc    01/05/09 18:21:26

  Modified:    tester/src/bin tester.xml
               tester/web/WEB-INF web.xml
  Added:       tester/web Authentication04.jsp
  Log:
  Add a unit test for retrieving roles (directly and via an alias) from a
  JSP page (Authentication04) as well as a servlet (Authentication03).
  
  Revision  Changes    Path
  1.41      +8 -1      jakarta-tomcat-4.0/tester/src/bin/tester.xml
  
  Index: tester.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/tester/src/bin/tester.xml,v
  retrieving revision 1.40
  retrieving revision 1.41
  diff -u -r1.40 -r1.41
  --- tester.xml        2001/05/08 18:36:22     1.40
  +++ tester.xml        2001/05/10 01:21:26     1.41
  @@ -72,12 +72,19 @@
          inHeaders="Authorization:Basic dG9tY2F0OnRvbWNhdA=="
         outContent="Authentication02 PASSED"/>
   
  -    <!-- Test isUserInRole() on actual role and on an alias -->
  +    <!-- Test isUserInRole() on actual role and on an alias (servlet) -->
       <tester host="${host}" port="${port}" protocol="${protocol}"
             debug="${debug}"
            request="${context.path}/protected/Authentication03"
          inHeaders="Authorization:Basic dG9tY2F0OnRvbWNhdA=="
         outContent="Authentication03 PASSED"/>
  +
  +    <!-- Test isUserInRole() on actual role and on an alias (JSP page) -->
  +    <tester host="${host}" port="${port}" protocol="${protocol}"
  +          debug="${debug}"
  +         request="${context.path}/protected/Authentication04"
  +       inHeaders="Authorization:Basic dG9tY2F0OnRvbWNhdA=="
  +      outContent="Authentication04 PASSED"/>
   
     </target>
   
  
  
  
  1.1                  jakarta-tomcat-4.0/tester/web/Authentication04.jsp
  
  Index: Authentication04.jsp
  ===================================================================
  <%@ page contentType="text/plain" %><%
    StringBuffer results = new StringBuffer();
    String remoteUser = request.getRemoteUser();
    if (remoteUser == null) {
      results.append(" Not Authenticated/");
    } else if (!"tomcat".equals(remoteUser)) {
      results.append(" Authenticated as '");
      results.append(remoteUser);
      results.append("'/");
    }
    if (!request.isUserInRole("tomcat")) {
      results.append(" Not in role 'tomcat'/");
    }
    if (!request.isUserInRole("alias")) {
      results.append(" Not in role 'alias'/");
    }
    if (request.isUserInRole("unknown")) {
      results.append(" In role 'unknown'/");
    }
    if (results.length() < 1) {
      out.println("Authentication04 PASSED");
    } else {
      out.print("Authentication04 FAILED -");
      out.println(results.toString());
    }
  %>
  
  
  
  1.30      +14 -2     jakarta-tomcat-4.0/tester/web/WEB-INF/web.xml
  
  Index: web.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/tester/web/WEB-INF/web.xml,v
  retrieving revision 1.29
  retrieving revision 1.30
  diff -u -r1.29 -r1.30
  --- web.xml   2001/05/03 23:06:35     1.29
  +++ web.xml   2001/05/10 01:21:26     1.30
  @@ -312,6 +312,15 @@
       </servlet>
   
       <servlet>
  +        <servlet-name>Authentication04</servlet-name>
  +        <jsp-file>/Authentication04.jsp</jsp-file>
  +        <security-role-ref>
  +            <role-name>alias</role-name>
  +            <role-link>tomcat</role-link>
  +        </security-role-ref>
  +    </servlet>
  +
  +    <servlet>
           <servlet-name>Decoding01</servlet-name>
           <servlet-class>org.apache.tester.Decoding01</servlet-class>
       </servlet>
  @@ -612,6 +621,11 @@
       </servlet-mapping>
   
       <servlet-mapping>
  +        <servlet-name>Authentication04</servlet-name>
  +        <url-pattern>/protected/Authentication04</url-pattern>
  +    </servlet-mapping>
  +
  +    <servlet-mapping>
           <servlet-name>Decoding01</servlet-name>
           <url-pattern>/Decoding01/*</url-pattern>
       </servlet-mapping>
  @@ -1112,12 +1126,10 @@
           <realm-name>Authentication Servlet</realm-name>
       </login-config>
   
  -<!--
       <security-role>
           <description>Security role we are testing for</description>
           <role-name>tomcat</role-name>
       </security-role>
  --->
   
   
       <!-- ========== Environment Entries =================================== -->
  
  
  

Reply via email to