public async Task GetItemQuery() { TestDoc testDoc = TestDoc.Create(); ItemResponse <TestDoc> createResponseb = await EncryptionContainerTests.propertyEncryptionContainer.CreateItemAsync( testDoc, new PartitionKey(testDoc.PK)); TestDoc expectedDoc = new TestDoc(testDoc); await EncryptionContainerTests.ValidateQueryResultsAsync( EncryptionContainerTests.propertyEncryptionContainer, "SELECT * FROM c", expectedDoc); await EncryptionContainerTests.ValidateQueryResultsAsync( EncryptionContainerTests.propertyEncryptionContainer, string.Format( "SELECT * FROM c where c.Name = {0}", expectedDoc.Name), expectedDoc); await EncryptionContainerTests.ValidateQueryResultsAsync( EncryptionContainerTests.propertyEncryptionContainer, queryDefinition : new QueryDefinition( "select * from c where c.Name = @Name") .WithParameter("@Name", expectedDoc.Name), expectedDoc : expectedDoc); }
public async Task CreateItemWith2Property1DekEncr() { TestDoc testDoc = TestDoc.Create(); ItemResponse <TestDoc> createResponse = await EncryptionContainerTests.twoPropertyOneDekEncryptionContainer.CreateItemAsync( testDoc, new PartitionKey(testDoc.PK)); await EncryptionContainerTests.VerifyItemByReadAsync(EncryptionContainerTests.twoPropertyOneDekEncryptionContainer, testDoc); await EncryptionContainerTests.VerifyItemByReadStreamAsync(EncryptionContainerTests.twoPropertyOneDekEncryptionContainer, testDoc); }
public async Task CreateStreamItemWithPropertyEncr() { TestDoc testDoc = TestDoc.Create(); Stream testStream = testDoc.ToStream(); await EncryptionContainerTests.propertyEncryptionContainer.CreateItemStreamAsync( testStream, new PartitionKey(testDoc.PK)); await EncryptionContainerTests.VerifyItemByReadAsync(EncryptionContainerTests.propertyEncryptionContainer, testDoc); await EncryptionContainerTests.VerifyItemByReadStreamAsync(EncryptionContainerTests.propertyEncryptionContainer, testDoc); }
public async Task CreateItemWithPropertyEncr() { TestDoc testDoc = TestDoc.Create(); ItemResponse <TestDoc> createResponse = await EncryptionContainerTests.propertyEncryptionContainer.CreateItemAsync( testDoc, new PartitionKey(testDoc.PK)); await EncryptionContainerTests.VerifyItemByReadAsync(EncryptionContainerTests.propertyEncryptionContainer, testDoc); await EncryptionContainerTests.VerifyItemByReadStreamAsync(EncryptionContainerTests.propertyEncryptionContainer, testDoc); Assert.AreNotEqual(createResponse.Resource.Name, testDoc.Name); }
public async Task ClassInitialize(TestContext context) { EncryptionContainerTests.dekProvider = new CosmosDataEncryptionKeyProvider(new TestKeyWrapProvider()); EncryptionContainerTests.encryptor = new TestEncryptor(EncryptionContainerTests.dekProvider); EncryptionContainerTests.client = TestCommon.CreateCosmosClient(); EncryptionContainerTests.database = await EncryptionContainerTests.client.CreateDatabaseAsync(Guid.NewGuid().ToString()); EncryptionContainerTests.keyContainer = await EncryptionContainerTests.database.CreateContainerAsync(Guid.NewGuid().ToString(), "/id", 400); await EncryptionContainerTests.dekProvider.InitializeAsync(EncryptionContainerTests.database, EncryptionContainerTests.keyContainer.Id); EncryptionContainerTests.itemContainer = await EncryptionContainerTests.database.CreateContainerAsync(Guid.NewGuid().ToString(), "/PK", 400); EncryptionContainerTests.propertyEncryptionContainer = EncryptionContainerTests.itemContainer.WithPropertyEncryptor(encryptor, EncryptionContainerTests.PathsToEncrypt); EncryptionContainerTests.pdekProperties = await EncryptionContainerTests.CreatePropertyDekAsync(EncryptionContainerTests.dekProvider, EncryptionContainerTests.pdekId); EncryptionContainerTests.twoPropertyEncryptionContainer = EncryptionContainerTests.itemContainer.WithPropertyEncryptor(encryptor, EncryptionContainerTests.PathsToEncrypt3); EncryptionContainerTests.twoPropertyOneDekEncryptionContainer = EncryptionContainerTests.itemContainer.WithPropertyEncryptor(encryptor, EncryptionContainerTests.PathsToEncrypt4); }