commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject cvs commit: jakarta-commons/httpclient/src/test/org/apache/commons/httpclient TestAuthenticator.java
Date Fri, 12 Jul 2002 06:03:25 GMT
dion        2002/07/11 23:03:25

  Modified:    httpclient/src/test/org/apache/commons/httpclient
                        TestAuthenticator.java
  Log:
  Fix for bug 8135 by Jeff Dever
  
  Revision  Changes    Path
  1.7       +40 -4     jakarta-commons/httpclient/src/test/org/apache/commons/httpclient/TestAuthenticator.java
  
  Index: TestAuthenticator.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/httpclient/src/test/org/apache/commons/httpclient/TestAuthenticator.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- TestAuthenticator.java	4 Feb 2002 15:26:43 -0000	1.6
  +++ TestAuthenticator.java	12 Jul 2002 06:03:25 -0000	1.7
  @@ -69,6 +69,7 @@
    *
    * @author Rodney Waldhoff
    * @version $Id$
  + * @author <a href="mailto:jsdever@sympatico.ca">Jeff Dever</a>
    */
   public class TestAuthenticator extends TestCase {
   
  @@ -164,6 +165,41 @@
               // expected
           }
       }
  +
  +    public void testDigestAuthenticationScheme() throws Exception {
  +        HttpState state = new HttpState();
  +        state.setCredentials(null,new UsernamePasswordCredentials("username","password"));
  +        HttpMethod method = new SimpleHttpMethod(new Header("WWW-Authenticate","Digest
realm=\"realm1\""));
  +        try{
  +            assertTrue(Authenticator.authenticate(method, state));
  +            fail("Should have thrown UnsupportedOperationException");
  +        }catch (UnsupportedOperationException uoe){
  +            // expected
  +        }
  +    }
  +
  +    public void testInvalidAuthenticationScheme() throws Exception {
  +        HttpState state = new HttpState();
  +        state.setCredentials(null,new UsernamePasswordCredentials("username","password"));
  +        HttpMethod method = new SimpleHttpMethod(new Header("WWW-Authenticate","invalid
realm=\"realm1\""));
  +        try{
  +            assertTrue(Authenticator.authenticate(method, state));
  +            fail("Should have thrown UnsupportedOperationException");
  +        }catch (UnsupportedOperationException uoe){
  +            // expected
  +        }
  +    }
  +
  +    public void testBasicAuthenticationCaseInsensitivity() throws Exception {
  +        HttpState state = new HttpState();
  +        state.setCredentials(null,new UsernamePasswordCredentials("username","password"));
  +        HttpMethod method = new SimpleHttpMethod(new Header("WwW-AuThEnTiCaTe","bAsIc ReAlM=\"realm1\""));
  +        assertTrue(Authenticator.authenticate(method,state));
  +        assertTrue(null != method.getRequestHeader("Authorization"));
  +        String expected = "Basic " + new String(Base64.encode("username:password".getBytes()));
  +        assertEquals(expected,method.getRequestHeader("Authorization").getValue());
  +    }
  +
   
       public void testBasicAuthenticationWithDefaultCreds() throws Exception {
           HttpState state = new HttpState();
  
  
  

--
To unsubscribe, e-mail:   <mailto:commons-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.org>


Mime
View raw message