MCPcopy Create free account
hub / github.com/apache/arrow / TEST_P

Function TEST_P

cpp/src/parquet/encryption/write_configurations_test.cc:317–360  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

315};
316
317TEST_P(TestGeneratedEncryptionConfiguration, AlgorithmMetadataAndRoundTrip) {
318 const auto cipher = std::get<0>(GetParam());
319 const bool plaintext_footer = std::get<1>(GetParam());
320 const auto prefix_mode = std::get<2>(GetParam());
321 if (plaintext_footer) {
322 CheckPlaintextFooterSignature();
323 }
324 auto reader = OpenReader(MakeDecryptionProperties());
325 const auto metadata = reader->metadata();
326 if (plaintext_footer) {
327 ASSERT_TRUE(metadata->is_encryption_algorithm_set());
328 const auto algorithm = metadata->encryption_algorithm();
329 ASSERT_EQ(cipher, algorithm.algorithm);
330 EXPECT_FALSE(algorithm.aad.aad_file_unique.empty());
331 EXPECT_EQ(prefix_mode == AadPrefixMode::External, algorithm.aad.supply_aad_prefix);
332 EXPECT_EQ(prefix_mode == AadPrefixMode::Stored ? kFileName : "",
333 algorithm.aad.aad_prefix);
334 } else {
335 // An encrypted footer declares the algorithm in FileCryptoMetaData instead.
336 EXPECT_FALSE(metadata->is_encryption_algorithm_set());
337 }
338 reader->Close();
339
340 FileDecryptor decryptor;
341 // Verify every physical column and all row groups through sync and async readers.
342 ASSERT_NO_THROW(decryptor.DecryptFile(file_path_, MakeDecryptionProperties()));
343 if (prefix_mode == AadPrefixMode::Stored) {
344 ASSERT_NO_THROW(decryptor.DecryptFile(
345 file_path_, MakeDecryptionProperties(Keys::All, AadPrefix::Missing)));
346 }
347 if (plaintext_footer) {
348 // This reads only public columns and does not authenticate the keyless footer.
349 ASSERT_NO_THROW(decryptor.DecryptFile(file_path_, nullptr));
350 }
351 EXPECT_THROW(ReadFirstSecretValue(MakeDecryptionProperties(Keys::MissingColumn)),
352 std::out_of_range);
353 EXPECT_THROW(OpenReader(MakeDecryptionProperties(Keys::WrongFooter)), ParquetException);
354 if (prefix_mode == AadPrefixMode::External) {
355 EXPECT_THROW(OpenReader(MakeDecryptionProperties(Keys::All, AadPrefix::Missing)),
356 ParquetException);
357 EXPECT_THROW(OpenReader(MakeDecryptionProperties(Keys::All, AadPrefix::Wrong)),
358 ParquetException);
359 }
360}
361
362INSTANTIATE_TEST_SUITE_P(
363 GeneratedFiles, TestGeneratedEncryptionConfiguration,

Callers

nothing calls this directly

Calls 7

OpenReaderFunction · 0.50
metadataMethod · 0.45
encryption_algorithmMethod · 0.45
emptyMethod · 0.45
CloseMethod · 0.45
DecryptFileMethod · 0.45

Tested by

no test coverage detected