Skip to content

Commit b6752c9

Browse files
committed
test file meta before and after decryption
1 parent c029e63 commit b6752c9

1 file changed

Lines changed: 23 additions & 11 deletions

File tree

test/src/html_output_test.cpp

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,16 @@ TEST_P(HtmlOutputTests, html_meta) {
7171

7272
FileMeta file_meta = file.file_meta();
7373

74+
{
75+
const std::string meta_output = output_path + "/meta.json";
76+
const nlohmann::json json =
77+
odr::internal::util::meta::meta_to_json(file_meta);
78+
std::ofstream o(meta_output);
79+
o << std::setw(4) << json << std::endl;
80+
EXPECT_TRUE(fs::is_regular_file(meta_output));
81+
EXPECT_LT(0, fs::file_size(meta_output));
82+
}
83+
7484
// encrypted ooxml type cannot be inspected
7585
if ((file.file_type() != FileType::office_open_xml_encrypted)) {
7686
EXPECT_EQ(test_file.type, file.file_type());
@@ -94,6 +104,19 @@ TEST_P(HtmlOutputTests, html_meta) {
94104

95105
if (test_file.password.has_value()) {
96106
file = file.decrypt(test_file.password.value());
107+
108+
// After decryption, the file meta may change
109+
file_meta = file.file_meta();
110+
111+
{
112+
const std::string meta_output = output_path + "/meta-decrypted.json";
113+
const nlohmann::json json =
114+
odr::internal::util::meta::meta_to_json(file_meta);
115+
std::ofstream o(meta_output);
116+
o << std::setw(4) << json << std::endl;
117+
EXPECT_TRUE(fs::is_regular_file(meta_output));
118+
EXPECT_LT(0, fs::file_size(meta_output));
119+
}
97120
}
98121

99122
if (file.is_document_file()) {
@@ -103,17 +126,6 @@ TEST_P(HtmlOutputTests, html_meta) {
103126
}
104127

105128
fs::create_directories(output_path);
106-
file_meta = file.file_meta();
107-
108-
{
109-
const std::string meta_output = output_path + "/meta.json";
110-
const nlohmann::json json =
111-
odr::internal::util::meta::meta_to_json(file_meta);
112-
std::ofstream o(meta_output);
113-
o << std::setw(4) << json << std::endl;
114-
EXPECT_TRUE(fs::is_regular_file(meta_output));
115-
EXPECT_LT(0, fs::file_size(meta_output));
116-
}
117129

118130
const std::string resource_path = common::Path(output_path_prefix)
119131
.parent()

0 commit comments

Comments
 (0)