diff --git a/sdk/storage/Azure.Storage.Blobs/tests/ClientSideEncryptionTests.cs b/sdk/storage/Azure.Storage.Blobs/tests/ClientSideEncryptionTests.cs index 8ebaf3f2964f..e32cd0261803 100644 --- a/sdk/storage/Azure.Storage.Blobs/tests/ClientSideEncryptionTests.cs +++ b/sdk/storage/Azure.Storage.Blobs/tests/ClientSideEncryptionTests.cs @@ -1534,6 +1534,41 @@ static byte[] GetRandomBytes(int length) CollectionAssert.AreEqual(plaintext.ToArray(), roundtrippedPlaintext); } + [Test] + [Combinatorial] + [LiveOnly] + public async Task EncryptionDataCaseInsensitivity( + [Values("ENCRYPTIONDATA", "EncryptionData", "eNcRyPtIoNdAtA")] string newKey, + [ValueSource("GetEncryptionVersions")] ClientSideEncryptionVersion version) + { + // Arrange + ReadOnlyMemory data = GetRandomBuffer(Constants.KB); + Mock mockKey1 = this.GetIKeyEncryptionKey(s_cancellationToken); + var encryptionOptions = new ClientSideEncryptionOptions(version) + { + KeyEncryptionKey = mockKey1.Object, + KeyWrapAlgorithm = s_algorithmName + }; + + await using var disposable = await GetTestContainerAsync(); + + BlobClient standardBlobClient = disposable.Container.GetBlobClient(GetNewBlobName()); + BlobClient encryptedBlobClient = InstrumentClient(standardBlobClient.WithClientSideEncryptionOptions(encryptionOptions)); + + await encryptedBlobClient.UploadAsync(BinaryData.FromBytes(data), cancellationToken: s_cancellationToken); + + // change casing of encryptiondata key + string rawEncryptiondata = (await standardBlobClient.GetPropertiesAsync()).Value.Metadata[EncryptionDataKey]; + Assert.IsNotEmpty(rawEncryptiondata); // quick check we're testing the right thing + await standardBlobClient.SetMetadataAsync(new Dictionary { { newKey, rawEncryptiondata } }); + + // Act + ReadOnlyMemory downloadedContent = (await encryptedBlobClient.DownloadContentAsync(s_cancellationToken)).Value.Content.ToMemory(); + + // Assert + Assert.IsTrue(data.Span.SequenceEqual(downloadedContent.Span)); + } + /// /// There's a few too many things to switch on for key updates. Separate method to determine the correct way to call it. ///