public async Task EncryptionUTCreateItemWithUnknownDek() { Container container = this.GetContainerWithMockSetup(); MyItem item = EncryptionUnitTests.GetNewItem(); try { await container.CreateItemAsync( item, new Cosmos.PartitionKey(item.PK), new ItemRequestOptions { EncryptionOptions = new EncryptionOptions { DataEncryptionKeyId = "random", EncryptionAlgorithm = EncryptionUnitTests.Algo, PathsToEncrypt = MyItem.PathsToEncrypt } }); Assert.Fail("Expected CreateItemAsync with unknown data encryption key to fail"); } catch (Exception) { // todo: Should we expose a exception class in the contract too } }
private static async Task <MyItem> CreateItemAsync(Container container, string dekId, List <string> pathsToEncrypt) { MyItem item = EncryptionUnitTests.GetNewItem(); ItemResponse <MyItem> response = await container.CreateItemAsync <MyItem>( item, requestOptions : new ItemRequestOptions { EncryptionOptions = new EncryptionOptions { DataEncryptionKeyId = dekId, EncryptionAlgorithm = EncryptionUnitTests.Algo, PathsToEncrypt = pathsToEncrypt } }); Assert.AreEqual(HttpStatusCode.Created, response.StatusCode); Assert.AreEqual(item, response.Resource); return(item); }