mirror of https://github.com/kiwix/libkiwix.git
fixup! Make the opds_dumper respect the provided nameMapper used in the server.
This commit is contained in:
parent
96fb4236a6
commit
24472e03dd
|
@ -18,6 +18,11 @@ protected:
|
||||||
const int PORT = 8002;
|
const int PORT = 8002;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
void resetServer(ZimFileServer::Options options) {
|
||||||
|
zfs1_.reset();
|
||||||
|
zfs1_.reset(new ZimFileServer(PORT, options, "./test/library.xml"));
|
||||||
|
}
|
||||||
|
|
||||||
void SetUp() override {
|
void SetUp() override {
|
||||||
zfs1_.reset(new ZimFileServer(PORT, ZimFileServer::DEFAULT_OPTIONS, "./test/library.xml"));
|
zfs1_.reset(new ZimFileServer(PORT, ZimFileServer::DEFAULT_OPTIONS, "./test/library.xml"));
|
||||||
}
|
}
|
||||||
|
@ -95,7 +100,7 @@ std::string maskVariableOPDSFeedData(std::string s)
|
||||||
" </entry>\n"
|
" </entry>\n"
|
||||||
|
|
||||||
|
|
||||||
#define CHARLES_RAY_CATALOG_ENTRY CATALOG_ENTRY( \
|
#define _CHARLES_RAY_CATALOG_ENTRY(CONTENT_NAME) CATALOG_ENTRY( \
|
||||||
"charlesray", \
|
"charlesray", \
|
||||||
"Charles, Ray", \
|
"Charles, Ray", \
|
||||||
"Wikipedia articles about Ray Charles", \
|
"Wikipedia articles about Ray Charles", \
|
||||||
|
@ -104,12 +109,14 @@ std::string maskVariableOPDSFeedData(std::string s)
|
||||||
"jazz",\
|
"jazz",\
|
||||||
"unittest;wikipedia;_category:jazz;_pictures:no;_videos:no;_details:no;_ftindex:yes",\
|
"unittest;wikipedia;_category:jazz;_pictures:no;_videos:no;_details:no;_ftindex:yes",\
|
||||||
"", \
|
"", \
|
||||||
"zimfile%26other", \
|
CONTENT_NAME, \
|
||||||
"zimfile%26other", \
|
"zimfile%26other", \
|
||||||
"569344" \
|
"569344" \
|
||||||
)
|
)
|
||||||
|
|
||||||
#define RAY_CHARLES_CATALOG_ENTRY CATALOG_ENTRY(\
|
#define CHARLES_RAY_CATALOG_ENTRY _CHARLES_RAY_CATALOG_ENTRY("zimfile%26other")
|
||||||
|
|
||||||
|
#define _RAY_CHARLES_CATALOG_ENTRY(CONTENT_NAME) CATALOG_ENTRY(\
|
||||||
"raycharles",\
|
"raycharles",\
|
||||||
"Ray Charles",\
|
"Ray Charles",\
|
||||||
"Wikipedia articles about Ray Charles",\
|
"Wikipedia articles about Ray Charles",\
|
||||||
|
@ -120,11 +127,13 @@ std::string maskVariableOPDSFeedData(std::string s)
|
||||||
"<link rel=\"http://opds-spec.org/image/thumbnail\"\n" \
|
"<link rel=\"http://opds-spec.org/image/thumbnail\"\n" \
|
||||||
" href=\"/ROOT/catalog/v2/illustration/raycharles/?size=48\"\n" \
|
" href=\"/ROOT/catalog/v2/illustration/raycharles/?size=48\"\n" \
|
||||||
" type=\"image/png;width=48;height=48;scale=1\"/>\n ", \
|
" type=\"image/png;width=48;height=48;scale=1\"/>\n ", \
|
||||||
"zimfile", \
|
CONTENT_NAME, \
|
||||||
"zimfile", \
|
"zimfile", \
|
||||||
"569344"\
|
"569344"\
|
||||||
)
|
)
|
||||||
|
|
||||||
|
#define RAY_CHARLES_CATALOG_ENTRY _RAY_CHARLES_CATALOG_ENTRY("zimfile")
|
||||||
|
|
||||||
#define UNCATEGORIZED_RAY_CHARLES_CATALOG_ENTRY CATALOG_ENTRY(\
|
#define UNCATEGORIZED_RAY_CHARLES_CATALOG_ENTRY CATALOG_ENTRY(\
|
||||||
"raycharles_uncategorized",\
|
"raycharles_uncategorized",\
|
||||||
"Ray (uncategorized) Charles",\
|
"Ray (uncategorized) Charles",\
|
||||||
|
@ -774,51 +783,11 @@ TEST_F(LibraryServerTest, catalog_search_excludes_hidden_tags)
|
||||||
#undef EXPECT_ZERO_RESULTS
|
#undef EXPECT_ZERO_RESULTS
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define NO_MAPPER_CHARLES_RAY_CATALOG_ENTRY _CHARLES_RAY_CATALOG_ENTRY("charlesray")
|
||||||
// Same as CHARLES_RAY_CATALOG_ENTRY but with link using the uuid (charlesray).
|
#define NO_MAPPER_RAY_CHARLES_CATALOG_ENTRY _RAY_CHARLES_CATALOG_ENTRY("raycharles")
|
||||||
#define NO_MAPPER_CHARLES_RAY_CATALOG_ENTRY \
|
TEST_F(LibraryServerTest, no_name_mapper_returned_catalog_use_uuid_in_link)
|
||||||
" <entry>\n" \
|
|
||||||
" <id>urn:uuid:charlesray</id>\n" \
|
|
||||||
" <title>Charles, Ray</title>\n" \
|
|
||||||
" <updated>YYYY-MM-DDThh:mm:ssZ</updated>\n" \
|
|
||||||
" <summary>Wikipedia articles about Ray Charles</summary>\n" \
|
|
||||||
" <language>fra</language>\n" \
|
|
||||||
" <name>wikipedia_fr_ray_charles</name>\n" \
|
|
||||||
" <flavour></flavour>\n" \
|
|
||||||
" <category>jazz</category>\n" \
|
|
||||||
" <tags>unittest;wikipedia;_category:jazz;_pictures:no;_videos:no;_details:no;_ftindex:yes</tags>\n" \
|
|
||||||
" <articleCount>284</articleCount>\n" \
|
|
||||||
" <mediaCount>2</mediaCount>\n" \
|
|
||||||
" <link type=\"text/html\" href=\"/ROOT/content/charlesray\" />\n" \
|
|
||||||
" <author>\n" \
|
|
||||||
" <name>Wikipedia</name>\n" \
|
|
||||||
" </author>\n" \
|
|
||||||
" <publisher>\n" \
|
|
||||||
" <name>Kiwix</name>\n" \
|
|
||||||
" </publisher>\n" \
|
|
||||||
" <dc:issued>2020-03-31T00:00:00Z</dc:issued>\n" \
|
|
||||||
" <link rel=\"http://opds-spec.org/acquisition/open-access\" type=\"application/x-zim\" href=\"https://github.com/kiwix/libkiwix/raw/master/test/data/zimfile%26other.zim\" length=\"569344\" />\n" \
|
|
||||||
" </entry>\n"
|
|
||||||
|
|
||||||
class NoMapperLibraryServerTest : public ::testing::Test
|
|
||||||
{
|
|
||||||
protected:
|
|
||||||
std::unique_ptr<ZimFileServer> zfs1_;
|
|
||||||
|
|
||||||
const int PORT = 8002;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
void SetUp() override {
|
|
||||||
zfs1_.reset(new ZimFileServer(PORT, ZimFileServer::NO_NAME_MAPPER, "./test/library.xml"));
|
|
||||||
}
|
|
||||||
|
|
||||||
void TearDown() override {
|
|
||||||
zfs1_.reset();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
TEST_F(NoMapperLibraryServerTest, returned_catalog_use_uuid_in_link)
|
|
||||||
{
|
{
|
||||||
|
resetServer(ZimFileServer::NO_NAME_MAPPER);
|
||||||
const auto r = zfs1_->GET("/ROOT/catalog/search?tag=_category:jazz");
|
const auto r = zfs1_->GET("/ROOT/catalog/search?tag=_category:jazz");
|
||||||
EXPECT_EQ(r->status, 200);
|
EXPECT_EQ(r->status, 200);
|
||||||
EXPECT_EQ(maskVariableOPDSFeedData(r->body),
|
EXPECT_EQ(maskVariableOPDSFeedData(r->body),
|
||||||
|
@ -836,5 +805,20 @@ TEST_F(NoMapperLibraryServerTest, returned_catalog_use_uuid_in_link)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
TEST_F(LibraryServerTest, no_name_mapper_catalog_v2_individual_entry_access)
|
||||||
|
{
|
||||||
|
resetServer(ZimFileServer::NO_NAME_MAPPER);
|
||||||
|
const auto r = zfs1_->GET("/ROOT/catalog/v2/entry/raycharles");
|
||||||
|
EXPECT_EQ(r->status, 200);
|
||||||
|
EXPECT_EQ(maskVariableOPDSFeedData(r->body),
|
||||||
|
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
|
||||||
|
NO_MAPPER_RAY_CHARLES_CATALOG_ENTRY
|
||||||
|
);
|
||||||
|
|
||||||
|
const auto r1 = zfs1_->GET("/ROOT/catalog/v2/entry/non-existent-entry");
|
||||||
|
EXPECT_EQ(r1->status, 404);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#undef EXPECT_SEARCH_RESULTS
|
#undef EXPECT_SEARCH_RESULTS
|
||||||
|
|
|
@ -134,8 +134,8 @@ TEST_F(ServerTest, 200)
|
||||||
TEST_F(ServerTest, 200_IdNameMapper)
|
TEST_F(ServerTest, 200_IdNameMapper)
|
||||||
{
|
{
|
||||||
resetServer(ZimFileServer::NO_NAME_MAPPER);
|
resetServer(ZimFileServer::NO_NAME_MAPPER);
|
||||||
EXPECT_EQ(200, zfs1_->GET("/ROOT/content/6f1d19d0-633f-087b-fb55-7ac324ff9baf/A/index")->status) << "url: /ROOT/content/6f1d19d0-633f-087b-fb55-7ac324ff9baf/A/index";
|
EXPECT_EQ(200, zfs1_->GET("/ROOT/content/6f1d19d0-633f-087b-fb55-7ac324ff9baf/A/index")->status);
|
||||||
EXPECT_EQ(404, zfs1_->GET("/ROOT/content/zimfile/A/index")->status) << "url: /ROOT/content/zimfile/A/index";
|
EXPECT_EQ(404, zfs1_->GET("/ROOT/content/zimfile/A/index")->status);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ServerTest, CompressibleContentIsCompressedIfAcceptable)
|
TEST_F(ServerTest, CompressibleContentIsCompressedIfAcceptable)
|
||||||
|
|
Loading…
Reference in New Issue