blackmwk commented on code in PR #3700:
URL: https://github.com/apache/iceberg-rust/pull/3700#discussion_r4692643265


##########
crates/iceberg/src/encryption/stream.rs:
##########
@@ -975,7 +989,13 @@ mod tests {
         let key = b"0123456789abcdef";
         let aad_prefix = b"test-aad-prefix!";
 
-        for plaintext in [b"".as_slice(), b"sensitive data".as_slice()] {
+        let multi_block = vec![7u8; PLAIN_BLOCK_SIZE as usize + 10];
+        let past_first_block = PLAIN_BLOCK_SIZE as u64..PLAIN_BLOCK_SIZE as 
u64 + 10;
+        for (plaintext, range) in [
+            (b"".as_slice(), 0..0),
+            (b"sensitive data".as_slice(), 0..14),
+            (multi_block.as_slice(), past_first_block),

Review Comment:
   Could we use rstest to simplify this?



##########
crates/iceberg/src/encryption/stream.rs:
##########
@@ -144,14 +145,15 @@ pub struct AesGcmFileRead {
     num_blocks: u64,
     /// Size of the last cipher block (may be smaller than 
`CIPHER_BLOCK_SIZE`).
     last_cipher_block_size: u32,
+    /// Whether a read has checked the AGS1 header, which no block 
authenticates.
+    header_checked: AtomicBool,

Review Comment:
   It's a little wasteful if a file is read concurrently, but I don't see this 
a blocker and fine for now.



##########
crates/iceberg/src/encryption/stream.rs:
##########
@@ -997,13 +1017,61 @@ mod tests {
                 )
                 .unwrap();
 
-                let err = reader.read(0..plaintext.len() as 
u64).await.unwrap_err();
+                let err = reader.read(range.clone()).await.unwrap_err();
                 assert_eq!(err.kind(), ErrorKind::DataInvalid);
                 assert_eq!(err.message(), message);
             }
         }
     }
 
+    #[tokio::test]
+    async fn test_header_is_checked_once() {

Review Comment:
   I would drop this test. Tests should test behaviors rather internals.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to