mirror of
https://github.com/internetarchive/heritrix3.git
synced 2026-09-23 14:15:47 +00:00
stick a basic auth 401 in the middle of testDigestAuth to check it doesn't mess with the digest auth we're working on
This commit is contained in:
@@ -386,11 +386,11 @@ public abstract class HttpMethodBase implements HttpMethod {
|
||||
* @param header the header to add to the request
|
||||
*/
|
||||
public void addRequestHeader(Header header) {
|
||||
LOG.trace("HttpMethodBase.addRequestHeader(Header)");
|
||||
|
||||
if (header == null) {
|
||||
LOG.debug("null header value ignored");
|
||||
} else {
|
||||
LOG.trace("HttpMethodBase.addRequestHeader(" + header.toString().trim() + ")");
|
||||
getRequestHeaderGroup().addHeader(header);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,10 +22,13 @@ package org.archive.state;
|
||||
import java.io.File;
|
||||
import java.io.Serializable;
|
||||
import java.util.Arrays;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.apache.commons.lang.SerializationUtils;
|
||||
import org.archive.modules.fetcher.FetchHTTPTestBase;
|
||||
|
||||
|
||||
/**
|
||||
@@ -35,6 +38,7 @@ import org.apache.commons.lang.SerializationUtils;
|
||||
*/
|
||||
public abstract class ModuleTestBase extends TestCase {
|
||||
|
||||
private static Logger logger = Logger.getLogger(ModuleTestBase.class.getName());
|
||||
|
||||
/**
|
||||
* Magical constructor that attempts to auto-create static key field
|
||||
@@ -203,4 +207,13 @@ public abstract class ModuleTestBase extends TestCase {
|
||||
Object second, byte[] secondBytes) throws Exception {
|
||||
assertTrue(Arrays.equals(firstBytes, secondBytes));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runTest() throws Throwable {
|
||||
try {
|
||||
super.runTest();
|
||||
} catch (Throwable t) {
|
||||
logger.log(Level.SEVERE, "", t);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -377,11 +377,16 @@ public abstract class FetchHTTPTestBase extends ProcessorTestBase {
|
||||
// check that we got the expected response and the fetcher did its thing
|
||||
assertEquals(401, curi.getFetchStatus());
|
||||
assertTrue(curi.getCredentials().contains(digestAuthCred));
|
||||
|
||||
// fetch again with the credentials
|
||||
|
||||
// stick a basic auth 401 in there to check it doesn't mess with the digest auth we're working on
|
||||
CrawlURI inteferingUri = makeCrawlURI("http://localhost:7777/auth/basic");
|
||||
getFetcher().process(inteferingUri);
|
||||
assertEquals(401, inteferingUri.getFetchStatus());
|
||||
|
||||
// fetch origin again with the credentials
|
||||
getFetcher().process(curi);
|
||||
String httpRequestString = httpRequestString(curi);
|
||||
// logger.info('\n' + httpRequestString + contentString(curi));
|
||||
logger.info('\n' + httpRequestString + contentString(curi));
|
||||
assertTrue(httpRequestString.contains("Authorization: Digest"));
|
||||
// otherwise should be a normal 200 response
|
||||
runDefaultChecks(curi, new HashSet<String>(Arrays.asList("requestLine", "hostHeader")));
|
||||
|
||||
Reference in New Issue
Block a user