Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Test that a 404 is neither cached nor recorded as valid
Exercises the new status checking against the real wwPDB archive: downloadFile
must throw HttpStatusException rather than writing the error page to the
destination, and createValidationFiles must not record a .size for it. Without
the second half the cached error page would pass validateFile, since its
recorded size would match the error body exactly.
  • Loading branch information
aalhossary committed Aug 15, 2026
commit 80e9daab55d7269f380239acc7140bf8b1681703
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,31 @@ void testValidationFiles() throws IOException{
}
}

@Nested
class HttpStatus {

@Test
void notFoundThrowsAndLeavesNothingBehind() throws IOException {
// A path that is guaranteed absent from the wwPDB archive.
URL missing = new URL("https://files.wwpdb.org/pub/pdb/data/structures/divided/mmCIF/zz/zzzz.cif.gz");
File dest = new File(System.getProperty("java.io.tmpdir"), "bj-missing.cif.gz");
File sizeFile = new File(dest.getParentFile(), dest.getName() + ".size");
dest.delete();
sizeFile.delete();

HttpStatusException e = assertThrows(HttpStatusException.class,
() -> FileDownloadUtils.downloadFile(missing, dest));
assertEquals(404, e.getStatusCode());
assertTrue(e.isNotFound());
assertFalse(dest.exists(), "a 404 body must never be written to the destination");

// ... and no validation metadata may be recorded for it either, or the
// cached error page would later pass validation.
FileDownloadUtils.createValidationFiles(missing, dest, null, FileDownloadUtils.Hash.UNKNOWN);
assertFalse(sizeFile.exists(), "no size file should be written for a 404 response");
}
}

@Nested
class Hashing {

Expand Down