TEST_F(ZstdDecompressorImplTest, DetectExcessiveCompressionRatio) {
  const absl::string_view ten_whitespaces = "          ";
  Buffer::OwnedImpl buffer;
  for (int i = 0; i < 1000; i++) {
    buffer.add(ten_whitespaces);
  }

  Zstd::Compressor::ZstdCompressorImpl compressor{default_compression_level_,
                                                  default_enable_checksum_, default_strategy_,
                                                  default_cdict_manager_, 4096};
  compressor.compress(buffer, Envoy::Compression::Compressor::State::Finish);

  Buffer::OwnedImpl output_buffer;
  Stats::IsolatedStoreImpl stats_store{};
  ZstdDecompressorImpl decompressor{stats_store, "test.", default_ddict_manager_, 16};
  decompressor.decompress(buffer, output_buffer);
  ASSERT_EQ(stats_store.counterFromString("test.zstd_generic_error").value(), 1);
}
TEST_F(ZstdDecompressorImplTest, DetectExcessiveCompressionRatio) {
  const absl::string_view ten_whitespaces = "          ";
  Buffer::OwnedImpl buffer;
  for (int i = 0; i < 1000; i++) {
    buffer.add(ten_whitespaces);
  }

  Zstd::Compressor::ZstdCompressorImpl compressor{default_compression_level_,
                                                  default_enable_checksum_, default_strategy_,
                                                  default_cdict_manager_, 4096};
  compressor.compress(buffer, Envoy::Compression::Compressor::State::Finish);

  Buffer::OwnedImpl output_buffer;
  Stats::IsolatedStoreImpl stats_store{};
  ZstdDecompressorImpl decompressor{stats_store, "test.", default_ddict_manager_, 16};
  decompressor.decompress(buffer, output_buffer);
  ASSERT_EQ(stats_store.counterFromString("test.zstd_generic_error").value(), 1);
}