Index: java/org/apache/commons/httpclient/auth/DigestScheme.java =================================================================== RCS file: /home/cvspublic/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/auth/DigestScheme.java,v retrieving revision 1.19 diff -u -r1.19 DigestScheme.java --- java/org/apache/commons/httpclient/auth/DigestScheme.java 18 Apr 2004 23:51:36 -0000 1.19 +++ java/org/apache/commons/httpclient/auth/DigestScheme.java 27 Apr 2004 16:35:58 -0000 @@ -153,6 +153,9 @@ throws MalformedChallengeException { super.processChallenge(challenge); + if (getParameter("realm") == null) { + throw new MalformedChallengeException("missing realm in challange"); + } if (getParameter("nonce") == null) { throw new MalformedChallengeException("missing nonce in challange"); } Index: test/org/apache/commons/httpclient/TestAuthenticator.java =================================================================== RCS file: /home/cvspublic/jakarta-commons/httpclient/src/test/org/apache/commons/httpclient/TestAuthenticator.java,v retrieving revision 1.41 diff -u -r1.41 TestAuthenticator.java --- test/org/apache/commons/httpclient/TestAuthenticator.java 27 Feb 2004 19:01:33 -0000 1.41 +++ test/org/apache/commons/httpclient/TestAuthenticator.java 27 Apr 2004 16:36:01 -0000 @@ -1,5 +1,5 @@ /* - * $Header: /home/cvspublic/jakarta-commons/httpclient/src/test/org/apache/commons/httpclient/TestAuthenticator.java,v 1.41 2004/02/27 19:01:33 olegk Exp $ + * $Header: /home/cvs/jakarta-commons/httpclient/src/test/org/apache/commons/httpclient/TestAuthenticator.java,v 1.41 2004/02/27 19:01:33 olegk Exp $ * $Revision: 1.41 $ * $Date: 2004/02/27 19:01:33 $ * ==================================================================== @@ -169,44 +169,38 @@ // --------------------------------- Test Methods for DigestScheme Authentication - public void testDigestAuthenticationWithNoCreds() { - String challenge = "Digest realm=\"realm1\""; + public void testDigestAuthenticationWithNoCreds() throws Exception { + String challenge = "Digest realm=\"realm1\", nonce=\"ABC123\""; HttpState state = new HttpState(); HttpMethod method = new SimpleHttpMethod(new Header("WWW-Authenticate", challenge)); try { AuthScheme authscheme = new DigestScheme(); authscheme.processChallenge(challenge); authenticate(authscheme, method, null, state); - fail("Should have thrown HttpException"); - } catch(HttpException e) { + fail("Should have thrown CredentialsNotAvailableException"); + } catch(CredentialsNotAvailableException e) { // expected } } - public void testDigestAuthenticationWithNoRealm() { + public void testDigestAuthenticationWithNoRealm() throws Exception { String challenge = "Digest"; - HttpState state = new HttpState(); - HttpMethod method = new SimpleHttpMethod(new Header("WWW-Authenticate", challenge)); try { AuthScheme authscheme = new DigestScheme(); authscheme.processChallenge(challenge); - authenticate(authscheme, method, null, state); - fail("Should have thrown HttpException"); - } catch(HttpException e) { + fail("Should have thrown MalformedChallengeException"); + } catch(MalformedChallengeException e) { // expected } } - public void testDigestAuthenticationWithNoRealm2() { + public void testDigestAuthenticationWithNoRealm2() throws Exception { String challenge = "Digest "; - HttpState state = new HttpState(); - HttpMethod method = new SimpleHttpMethod(new Header("WWW-Authenticate", challenge)); try { AuthScheme authscheme = new DigestScheme(); authscheme.processChallenge(challenge); - authenticate(authscheme, method, null, state); - fail("Should have thrown HttpException"); - } catch(HttpException e) { + fail("Should have thrown MalformedChallengeException"); + } catch(MalformedChallengeException e) { // expected } }