diff --git a/Microsoft.Azure.Cosmos/src/Resource/ClientEncryptionKey/ClientEncryptionKeyProperties.cs b/Microsoft.Azure.Cosmos/src/Resource/ClientEncryptionKey/ClientEncryptionKeyProperties.cs index d5c6cb0147..7c3af2a1f5 100644 --- a/Microsoft.Azure.Cosmos/src/Resource/ClientEncryptionKey/ClientEncryptionKeyProperties.cs +++ b/Microsoft.Azure.Cosmos/src/Resource/ClientEncryptionKey/ClientEncryptionKeyProperties.cs @@ -81,7 +81,7 @@ internal ClientEncryptionKeyProperties(ClientEncryptionKeyProperties source) /// /// Encryption algorithm that will be used along with this client encryption key to encrypt/decrypt data. /// - [JsonProperty(PropertyName = Constants.Properties.EncryptionAlgorithmId, NullValueHandling = NullValueHandling.Ignore)] + [JsonProperty(PropertyName = Constants.Properties.EncryptionAlgorithm, NullValueHandling = NullValueHandling.Ignore)] public string EncryptionAlgorithm { get; internal set; } /// diff --git a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/FeedToken/ChangeFeedIteratorCoreTests.cs b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/FeedToken/ChangeFeedIteratorCoreTests.cs index 61167add35..d7efc24c70 100644 --- a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/FeedToken/ChangeFeedIteratorCoreTests.cs +++ b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/FeedToken/ChangeFeedIteratorCoreTests.cs @@ -650,6 +650,39 @@ public async Task ChangeFeedIteratorCore_CannotMixTokensFromOtherContainers() Assert.AreEqual(HttpStatusCode.BadRequest, responseMessage.StatusCode); } + /// + /// This test validates Incremental Change Feed by inserting and deleting documents and verifying nothing reported + /// + [TestMethod] + public async Task ChangeFeedIteratorCore_DeleteAfterCreate() + { + ContainerProperties properties = new ContainerProperties(id: Guid.NewGuid().ToString(), partitionKeyPath: ChangeFeedIteratorCoreTests.PartitionKey); + properties.ChangeFeedPolicy.FullFidelityRetention = TimeSpan.FromMinutes(5); + ContainerResponse response = await this.database.CreateContainerAsync( + properties, + cancellationToken: this.cancellationToken); + ContainerInternal container = (ContainerInternal)response; + // Insert documents and then delete them + int totalDocuments = 50; + IList createdItems = await this.CreateRandomItems(container, totalDocuments, randomPartitionKey: true); + foreach (ToDoActivity item in createdItems) + { + await container.DeleteItemAsync(item.id, new PartitionKey(item.pk)); + } + FeedIterator changefeedIterator = container.GetChangeFeedIterator( + ChangeFeedStartFrom.Beginning(), + ChangeFeedMode.Incremental); + while (changefeedIterator.HasMoreResults) + { + FeedResponse feedResponse = await changefeedIterator.ReadNextAsync(this.cancellationToken); + Assert.AreEqual(HttpStatusCode.NotModified, feedResponse.StatusCode, "Incremental Change Feed does not present intermediate results and should return nothing."); + if (feedResponse.StatusCode == HttpStatusCode.NotModified) + { + break; + } + } + } + /// /// This test validates Full Fidelity Change Feed by inserting and deleting documents and verifying all operations are present /// @@ -791,6 +824,31 @@ public async Task TestCancellationTokenAsync() } } + /// + /// This test validates error with Full Fidelity Change Feed and start from beginning. + /// + [TestMethod] + public async Task ChangeFeedIteratorCore_WithFullFidelityReadFromBeginning() + { + ContainerProperties properties = new ContainerProperties(id: Guid.NewGuid().ToString(), partitionKeyPath: ChangeFeedIteratorCoreTests.PartitionKey); + properties.ChangeFeedPolicy.FullFidelityRetention = TimeSpan.FromMinutes(5); + ContainerResponse response = await this.database.CreateContainerAsync( + properties, + cancellationToken: this.cancellationToken); + ContainerInternal container = (ContainerInternal)response; + int totalDocuments = 10; + await this.CreateRandomItems(container, totalDocuments, randomPartitionKey: true); + + // FF does not work with StartFromBeginning currently, capture error + FeedIterator fullFidelityIterator = container.GetChangeFeedIterator( + ChangeFeedStartFrom.Beginning(), + ChangeFeedMode.FullFidelity); + + CosmosException cosmosException = await Assert.ThrowsExceptionAsync(() => fullFidelityIterator.ReadNextAsync()); + Assert.AreEqual(HttpStatusCode.BadRequest, cosmosException.StatusCode, "Full Fidelity Change Feed does not work with StartFromBeginning currently."); + Assert.IsTrue(cosmosException.Message.Contains("FullFidelity Change Feed must have valid If-None-Match header.")); + } + private async Task> CreateRandomItems(ContainerInternal container, int pkCount, int perPKItemCount = 1, bool randomPartitionKey = true) { Assert.IsFalse(!randomPartitionKey && perPKItemCount > 1); diff --git a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/Contracts/DotNetPreviewSDKAPI.json b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/Contracts/DotNetPreviewSDKAPI.json index 399c0171f5..b816451c4a 100644 --- a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/Contracts/DotNetPreviewSDKAPI.json +++ b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/Contracts/DotNetPreviewSDKAPI.json @@ -300,7 +300,7 @@ ], "MethodInfo": "System.Nullable`1[System.DateTime] LastModified;CanRead:True;CanWrite:True;System.Nullable`1[System.DateTime] get_LastModified();IsAbstract:False;IsStatic:False;IsVirtual:False;IsGenericMethod:False;IsConstructor:False;IsFinal:False;" }, - "System.String EncryptionAlgorithm[Newtonsoft.Json.JsonPropertyAttribute(NullValueHandling = 1, PropertyName = \"encryptionAlgorithmId\")]": { + "System.String EncryptionAlgorithm[Newtonsoft.Json.JsonPropertyAttribute(NullValueHandling = 1, PropertyName = \"encryptionAlgorithm\")]": { "Type": "Property", "Attributes": [ "JsonPropertyAttribute"