Search in sources :

Example 6 with FileSegmentInputStream

use of org.apache.cassandra.io.util.FileSegmentInputStream in project cassandra by apache.

the class CommitLogDescriptorTest method writeAndReadHeader_WithEncryptionHeader_EncryptionDisabledInYaml.

/**
     * Check that even though enabledTdeOptions is disabled in the yaml, we can still read the commit log header as encrypted.
     */
@Test
public void writeAndReadHeader_WithEncryptionHeader_EncryptionDisabledInYaml() throws IOException {
    CommitLogDescriptor descriptor = new CommitLogDescriptor(CommitLogDescriptor.current_version, 1, null, enabledEncryption);
    ByteBuffer buffer = ByteBuffer.allocate(16 * 1024);
    CommitLogDescriptor.writeHeader(buffer, descriptor);
    buffer.flip();
    FileSegmentInputStream dataInput = new FileSegmentInputStream(buffer, null, 0);
    CommitLogDescriptor result = CommitLogDescriptor.readHeader(dataInput, previouslyEnabledEncryption);
    Assert.assertNotNull(result);
    Assert.assertNull(result.compression);
    Assert.assertTrue(result.getEncryptionContext().isEnabled());
    Assert.assertArrayEquals(iv, result.getEncryptionContext().getIV());
}
Also used : FileSegmentInputStream(org.apache.cassandra.io.util.FileSegmentInputStream) ByteBuffer(java.nio.ByteBuffer) Test(org.junit.Test)

Aggregations

ByteBuffer (java.nio.ByteBuffer)6 FileSegmentInputStream (org.apache.cassandra.io.util.FileSegmentInputStream)6 Test (org.junit.Test)5 FileDataInput (org.apache.cassandra.io.util.FileDataInput)1