mirror of https://github.com/kiwix/libkiwix.git
Unit test for HTTP 500 Internal Server Error
Currently an internal server error can be triggered by accessing an entry belonging to a redirect loop. The ZIM file (test/data/poor.zim) containing such a loop was copied from openzim/zim-tools repository (test/data/zimfiles/poor.zim).
This commit is contained in:
parent
2a20e87341
commit
3f41ce8337
Binary file not shown.
|
@ -29,6 +29,7 @@ if gtest_dep.found() and not meson.is_cross_build()
|
|||
'zimfile.zim',
|
||||
'zimfile&other.zim',
|
||||
'corner_cases.zim',
|
||||
'poor.zim',
|
||||
'library.xml'
|
||||
]
|
||||
foreach file : data_files
|
||||
|
|
|
@ -142,6 +142,7 @@ protected:
|
|||
const int PORT = 8001;
|
||||
const ZimFileServer::FilePathCollection ZIMFILES {
|
||||
"./test/zimfile.zim",
|
||||
"./test/poor.zim",
|
||||
"./test/corner_cases.zim"
|
||||
};
|
||||
|
||||
|
@ -761,6 +762,31 @@ TEST_F(ServerTest, 400WithBodyTesting)
|
|||
}
|
||||
}
|
||||
|
||||
TEST_F(ServerTest, 500)
|
||||
{
|
||||
const std::string expectedBody = R"(<!DOCTYPE html>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<meta content="text/html;charset=UTF-8" http-equiv="content-type" />
|
||||
<title>Internal Server Error</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Internal Server Error</h1>
|
||||
<p>
|
||||
An internal server error occured. We are sorry about that :/
|
||||
</p>
|
||||
<p>
|
||||
Entry redirect_loop.html is a redirect entry.
|
||||
</p>
|
||||
</body>
|
||||
</html>
|
||||
)";
|
||||
|
||||
const auto r = zfs1_->GET("/ROOT/poor/A/redirect_loop.html");
|
||||
EXPECT_EQ(r->status, 500);
|
||||
EXPECT_EQ(r->body, expectedBody);
|
||||
}
|
||||
|
||||
TEST_F(ServerTest, RandomPageRedirectsToAnExistingArticle)
|
||||
{
|
||||
auto g = zfs1_->GET("/ROOT/random?content=zimfile");
|
||||
|
|
Loading…
Reference in New Issue