Index: TestAuthenticator.java =================================================================== RCS file: /home/cvspublic/jakarta-commons/httpclient/src/test/org/apache/commons/httpclient/TestAuthenticator.java,v retrieving revision 1.17 diff -u -r1.17 TestAuthenticator.java --- TestAuthenticator.java 30 Sep 2002 19:42:13 -0000 1.17 +++ TestAuthenticator.java 2 Oct 2002 07:24:02 -0000 @@ -375,6 +375,7 @@ public void testNTLMAuthenticationWithNoCreds() { HttpState state = new HttpState(); HttpMethod method = new SimpleHttpMethod(new Header("WWW-Authenticate","NTLM")); + method.addRequestHeader("Host", "host"); try { Authenticator.authenticate(method,state); fail("Should have thrown HttpException"); @@ -385,6 +386,7 @@ public void testNTLMAuthenticationWithNullHttpState() throws Exception { HttpMethod method = new SimpleHttpMethod(new Header("WWW-Authenticate","NTLM")); + method.addRequestHeader("Host", "host"); try { Authenticator.authenticate(method,(HttpState)null); fail("Should have thrown NullPointerException"); @@ -396,8 +398,9 @@ public void testNTLMAuthenticationCaseInsensitivity() throws Exception { HttpState state = new HttpState(); NTCredentials cred = new NTCredentials("username","password", "host", "domain"); - state.setCredentials(null, cred); + state.setCredentials("host", cred); HttpMethod method = new SimpleHttpMethod(new Header("WwW-AuThEnTiCaTe","nTlM")); + method.addRequestHeader("Host", "host"); assertTrue(Authenticator.authenticate(method,state)); assertTrue(null != method.getRequestHeader("Authorization")); } @@ -407,8 +410,9 @@ "1NURE9NQUlO"; HttpState state = new HttpState(); NTCredentials cred = new NTCredentials("username","password", "host", "domain"); - state.setCredentials(null, cred); + state.setCredentials("host", cred); HttpMethod method = new SimpleHttpMethod(new Header("WWW-Authenticate","NTLM")); + method.addRequestHeader("Host", "host"); assertTrue(Authenticator.authenticate(method,state)); assertTrue(null != method.getRequestHeader("Authorization")); assertEquals(expected, method.getRequestHeader("Authorization").getValue()); @@ -420,6 +424,25 @@ "9TVAaC+vLxUEHnUtpItj9Dp4kzwQfd61Lztg=="; HttpState state = new HttpState(); NTCredentials cred = new NTCredentials("username","password", "host", "domain"); + state.setCredentials("host", cred); + HttpMethod method = new SimpleHttpMethod(new Header("WWW-Authenticate", + "NTLM TlRMTVNTUAACAAAACgAKADAAAAAGgoEAPc4kP4LtCV8AAAAAAAAAAJ4AngA" + + "6AAAASU5UUkFFUEhPWAIAFABJAE4AVABSAEEARQBQAEgATwBYAAEAEgBCAE8AQQB" + + "SAEQAUgBPAE8ATQAEACgAaQBuAHQAcgBhAGUAcABoAG8AeAAuAGUAcABoAG8AeAA" + + "uAGMAbwBtAAMAPABCAG8AYQByAGQAcgBvAG8AbQAuAGkAbgB0AHIAYQBlAHAAaAB" + + "vAHgALgBlAHAAaABvAHgALgBjAG8AbQAAAAAA")); + method.addRequestHeader("Host", "host"); + assertTrue(Authenticator.authenticate(method,state)); + assertTrue(null != method.getRequestHeader("Authorization")); + assertEquals(expected, method.getRequestHeader("Authorization").getValue()); + } + + public void testNTLMAuthenticationWithDefaultCreds() throws Exception { + String expected = "NTLM TlRMTVNTUAADAAAAGAAYAFIAAAAAAAAAagAAAAYABgB" + + "AAAAACAAIAEYAAAAEAAQATgAAAAAAAABqAAAABlIAAERPTUFJTlVTRVJOQU1FSE" + + "9TVAaC+vLxUEHnUtpItj9Dp4kzwQfd61Lztg=="; + HttpState state = new HttpState(); + NTCredentials cred = new NTCredentials("username","password", "host", "domain"); state.setCredentials(null, cred); HttpMethod method = new SimpleHttpMethod(new Header("WWW-Authenticate", "NTLM TlRMTVNTUAACAAAACgAKADAAAAAGgoEAPc4kP4LtCV8AAAAAAAAAAJ4AngA" + @@ -427,6 +450,7 @@ "SAEQAUgBPAE8ATQAEACgAaQBuAHQAcgBhAGUAcABoAG8AeAAuAGUAcABoAG8AeAA" + "uAGMAbwBtAAMAPABCAG8AYQByAGQAcgBvAG8AbQAuAGkAbgB0AHIAYQBlAHAAaAB" + "vAHgALgBlAHAAaABvAHgALgBjAG8AbQAAAAAA")); + method.addRequestHeader("Host", "host"); assertTrue(Authenticator.authenticate(method,state)); assertTrue(null != method.getRequestHeader("Authorization")); assertEquals(expected, method.getRequestHeader("Authorization").getValue());