From 8c7fdb77d7bb6c64c939ad8168df4342837087df Mon Sep 17 00:00:00 2001 From: benoit74 Date: Wed, 24 Jul 2024 11:47:57 +0000 Subject: [PATCH] Handle case where the redirect target is bad --- test-website/Caddyfile | 1 + .../{redirection-loops.html => bad-redirections.html} | 8 ++++++-- test-website/content/index.html | 2 +- tests/test_warc_to_zim.py | 3 ++- 4 files changed, 10 insertions(+), 4 deletions(-) rename test-website/content/{redirection-loops.html => bad-redirections.html} (73%) diff --git a/test-website/Caddyfile b/test-website/Caddyfile index ebdd8e3..83f1908 100644 --- a/test-website/Caddyfile +++ b/test-website/Caddyfile @@ -75,6 +75,7 @@ redir /bad-redir-loop-B /bad-redir-loop-C 307 redir /bad-redir-loop-C /bad-redir-loop-D 307 redir /bad-redir-loop-D /bad-redir-loop-B 307 + redir /bad-redir-target https://I%20mNotAhostname 307 header /content-types/script1.js Content-Type application/javascript header /content-types/script2.js Content-Type text/javascript diff --git a/test-website/content/redirection-loops.html b/test-website/content/bad-redirections.html similarity index 73% rename from test-website/content/redirection-loops.html rename to test-website/content/bad-redirections.html index 702893b..c25ddd7 100644 --- a/test-website/content/redirection-loops.html +++ b/test-website/content/bad-redirections.html @@ -13,14 +13,18 @@ -

Redirection loops

+

Bad redirections

-

Links below are indefinitely redirecting

+

Links below are indefinitely redirecting and hence not working

Redirect to self through loop

Redirect to inner-loop

+

Links below is targeting something which is not working

+ +

Redirect to silly URL

+ diff --git a/test-website/content/index.html b/test-website/content/index.html index 4e68ab3..8197da2 100644 --- a/test-website/content/index.html +++ b/test-website/content/index.html @@ -47,7 +47,7 @@
  • Base href
  • onxxx HTML events
  • links to folder instead of file
  • -
  • Bad redirections loops
  • +
  • Bad redirections
  • Handling of content types
  • diff --git a/tests/test_warc_to_zim.py b/tests/test_warc_to_zim.py index c60b06f..fd44354 100644 --- a/tests/test_warc_to_zim.py +++ b/tests/test_warc_to_zim.py @@ -805,7 +805,7 @@ def test_redirection_loops(self, tmp_path): zim_output = tmp_path / zim_output for exising_website_items in [ - "redirection-loops.html", + "bad-redirects.html", ]: self.assert_item_exist( zim_output, f"website.test.openzim.org/{exising_website_items}" @@ -816,6 +816,7 @@ def test_redirection_loops(self, tmp_path): "/bad-redir-loop-B", "/bad-redir-loop-C", "/bad-redir-loop-D", + "/bad-redir-target", ]: self.assert_item_does_not_exist( zim_output, f"website.test.openzim.org/{ignored_website_items}"