diff --git a/.classpath b/.classpath
index 53a8eccc..262f4152 100644
--- a/.classpath
+++ b/.classpath
@@ -57,5 +57,5 @@
-
+
diff --git a/modules/src/main/java/org/archive/modules/credential/CommonsHttpCredentialUtil.java b/modules/src/main/java/org/archive/modules/credential/CommonsHttpCredentialUtil.java
index de44da39..7012634e 100644
--- a/modules/src/main/java/org/archive/modules/credential/CommonsHttpCredentialUtil.java
+++ b/modules/src/main/java/org/archive/modules/credential/CommonsHttpCredentialUtil.java
@@ -121,8 +121,7 @@ public class CommonsHttpCredentialUtil {
http.getState().setCredentials(new AuthScope(curi.getUURI().getHost(),
curi.getUURI().getPort(), cred.getRealm()), upc);
logger.fine("Credentials for realm " + cred.getRealm() +
- " for CrawlURI " + curi.toString() + " added to request: " +
- result);
+ " for CrawlURI " + curi.toString() + " added to request");
http.getParams().setParameter(AuthPolicy.AUTH_SCHEME_PRIORITY,
Arrays.asList(AuthPolicy.DIGEST, AuthPolicy.BASIC));
diff --git a/modules/src/test/java/org/archive/modules/fetcher/FetchHTTPTestBase.java b/modules/src/test/java/org/archive/modules/fetcher/FetchHTTPTestBase.java
index 2bfb10ac..77f15f53 100644
--- a/modules/src/test/java/org/archive/modules/fetcher/FetchHTTPTestBase.java
+++ b/modules/src/test/java/org/archive/modules/fetcher/FetchHTTPTestBase.java
@@ -109,12 +109,11 @@ public abstract class FetchHTTPTestBase extends ProcessorTestBase {
ConstraintMapping constraintMapping = new ConstraintMapping();
constraintMapping.setConstraint(constraint);
- constraintMapping.setPathSpec("/auth");
+ constraintMapping.setPathSpec("/auth/*");
SecurityHandler authWrapper = new SecurityHandler();
authWrapper.setAuthMethod(authMethod);
- authWrapper
- .setConstraintMappings(new ConstraintMapping[] { constraintMapping });
+ authWrapper.setConstraintMappings(new ConstraintMapping[] {constraintMapping});
authWrapper.setUserRealm(new HashUserRealm(realm) {
{
put(login, password);
@@ -335,7 +334,7 @@ public abstract class FetchHTTPTestBase extends ProcessorTestBase {
getFetcher().getCredentialStore().getCredentials().put("basic-auth-credential",
basicAuthCredential);
- CrawlURI curi = makeCrawlURI("http://localhost:7777/auth");
+ CrawlURI curi = makeCrawlURI("http://localhost:7777/auth/1");
getFetcher().process(curi);
// check that we got the expected response and the fetcher did its thing
@@ -349,6 +348,14 @@ public abstract class FetchHTTPTestBase extends ProcessorTestBase {
assertTrue(httpRequestString.contains("Authorization: Basic YmFzaWMtYXV0aC1sb2dpbjpiYXNpYy1hdXRoLXBhc3N3b3Jk\r\n"));
// otherwise should be a normal 200 response
runDefaultChecks(curi, new HashSet(Arrays.asList("requestLine")));
+
+ // fetch a fresh uri to make sure auth info was cached and we don't get another 401
+ curi = makeCrawlURI("http://localhost:7777/auth/2");
+ getFetcher().process(curi);
+ httpRequestString = httpRequestString(curi);
+ assertTrue(httpRequestString.contains("Authorization: Basic YmFzaWMtYXV0aC1sb2dpbjpiYXNpYy1hdXRoLXBhc3N3b3Jk\r\n"));
+ // otherwise should be a normal 200 response
+ runDefaultChecks(curi, new HashSet(Arrays.asList("requestLine")));
}
// server for digest auth is at localhost:7778
@@ -364,7 +371,7 @@ public abstract class FetchHTTPTestBase extends ProcessorTestBase {
getFetcher().getCredentialStore().getCredentials().put("digest-auth-credential",
digestAuthCred);
- CrawlURI curi = makeCrawlURI("http://localhost:7778/auth");
+ CrawlURI curi = makeCrawlURI("http://localhost:7778/auth/1");
getFetcher().process(curi);
// check that we got the expected response and the fetcher did its thing
@@ -378,6 +385,14 @@ public abstract class FetchHTTPTestBase extends ProcessorTestBase {
assertTrue(httpRequestString.contains("Authorization: Digest"));
// otherwise should be a normal 200 response
runDefaultChecks(curi, new HashSet(Arrays.asList("requestLine", "hostHeader")));
+
+ // fetch a fresh uri to make sure auth info was cached and we don't get another 401
+ curi = makeCrawlURI("http://localhost:7778/auth/2");
+ getFetcher().process(curi);
+ httpRequestString = httpRequestString(curi);
+ assertTrue(httpRequestString.contains("Authorization: Digest"));
+ // otherwise should be a normal 200 response
+ runDefaultChecks(curi, new HashSet(Arrays.asList("requestLine")));
}
protected void checkSetCookieURI() throws URIException, IOException,