Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

encryption followup PR - separate CI #13270

Merged
merged 4 commits into from
Jul 17, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions eng/pipelines/templates/stages/cosmos-sdk-client.yml
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,14 @@ stages:
ProfileFlag: '-P integration-test-emulator'
DisplayName: 'Spring Emulator only Integration Tests'
AdditionalArgs: '-DargLine="-DACCOUNT_HOST=https://localhost:8081/ -DACCOUNT_KEY=C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw== -DSECONDARY_ACCOUNT_KEY=C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw=="'
Encryption_Integration_Tests_Java8:
OSVmImage: 'windows-2019'
JavaTestVersion: '1.8'
ProfileFlag: '-Pencryption-integration'
DisplayName: 'Encryption Emulator only Integration Tests'
PROTOCOLS: '["Tcp"]'
DESIRED_CONSISTENCIES: '["Session"]'
AdditionalArgs: '-DargLine="-DACCOUNT_HOST=https://localhost:8081/"'

TestStepMavenInputs:
goals: 'verify'
Expand Down
4 changes: 2 additions & 2 deletions sdk/cosmos/azure-cosmos-encryption/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Azure CosmosDB client library for Java
TODO
# Encryption plugin library for Azure Cosmos DB Java SDK for Java
The encryption plugin is under development and not ready to be consumed yet.

## Getting started
### Include the package
Expand Down
167 changes: 5 additions & 162 deletions sdk/cosmos/azure-cosmos-encryption/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ Licensed under the MIT License.
<groupId>com.azure</groupId>
<artifactId>azure-cosmos-encryption</artifactId>
<version>1.0.0-beta.1</version> <!-- {x-version-update;com.azure:azure-cosmos-encryption;current} -->
<name>Microsoft Azure SDK for SQL API of Azure Cosmos DB Service</name>
<description>This Package contains Microsoft Azure Cosmos SDK (with Reactive Extension Reactor support) for Azure Cosmos DB SQL API</description>
<name>Encryption Plugin for Azure Cosmos DB SDK</name>
<description>This Package contains Encryption Plugin for Microsoft Azure Cosmos SDK</description>
<packaging>jar</packaging>
<url>https://github.com/Azure/azure-sdk-for-java</url>

Expand Down Expand Up @@ -202,7 +202,6 @@ Licensed under the MIT License.
<include>com.fasterxml.jackson.core:jackson-databind:[2.10.1]</include> <!-- {x-include-update;com.fasterxml.jackson.core:jackson-databind;external_dependency} -->
<include>com.fasterxml.jackson.datatype:jackson-datatype-jsr310:[2.10.1]</include> <!-- {x-include-update;com.fasterxml.jackson.datatype:jackson-datatype-jsr310;external_dependency} -->
<include>com.fasterxml.jackson.module:jackson-module-afterburner:[2.10.1]</include> <!-- {x-include-update;cosmos_com.fasterxml.jackson.module:jackson-module-afterburner;external_dependency} -->
<include>com.google.code.findbugs:jsr305:[3.0.2]</include> <!-- {x-include-update;com.google.code.findbugs:jsr305;external_dependency} -->
<include>io.dropwizard.metrics:metrics-core:[4.1.0]</include> <!-- {x-include-update;cosmos_io.dropwizard.metrics:metrics-core;external_dependency} -->
<include>io.micrometer:micrometer-core:[1.2.0]</include> <!-- {x-include-update;io.micrometer:micrometer-core;external_dependency} -->
<include>io.netty:netty-codec-http:[4.1.49.Final]</include> <!-- {x-include-update;io.netty:netty-codec-http;external_dependency} -->
Expand Down Expand Up @@ -246,167 +245,11 @@ Licensed under the MIT License.
</plugins>
</build>
</profile>
<profile>
<!-- integration tests, requires Cosmos DB endpoint -->
<id>fast</id>
<properties>
<test.groups>simple,cosmosv3</test.groups>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.22.0</version> <!-- {x-version-update;org.apache.maven.plugins:maven-failsafe-plugin;external_dependency} -->
<configuration>
<suiteXmlFiles>
<suiteXmlFile>src/test/resources/fast-testng.xml</suiteXmlFile>
</suiteXmlFiles>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<profile>
<!-- integration tests, requires Cosmos DB endpoint -->
<id>long</id>
<properties>
<test.groups>long</test.groups>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.22.0</version> <!-- {x-version-update;org.apache.maven.plugins:maven-failsafe-plugin;external_dependency} -->
<configuration>
<suiteXmlFiles>
<suiteXmlFile>src/test/resources/long-testng.xml</suiteXmlFile>
</suiteXmlFiles>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<profile>
<!-- integration tests, requires Cosmos DB endpoint -->
<id>direct</id>
<properties>
<test.groups>direct</test.groups>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.22.0</version> <!-- {x-version-update;org.apache.maven.plugins:maven-failsafe-plugin;external_dependency} -->
<configuration>
<suiteXmlFiles>
<suiteXmlFile>src/test/resources/direct-testng.xml</suiteXmlFile>
</suiteXmlFiles>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<profile>
<!-- integration tests, requires Cosmos DB endpoint with multi master support -->
<id>multi-master</id>
<properties>
<test.groups>multi-master</test.groups>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.22.0</version> <!-- {x-version-update;org.apache.maven.plugins:maven-failsafe-plugin;external_dependency} -->
<configuration>
<suiteXmlFiles>
<suiteXmlFile>src/test/resources/multi-master-testng.xml</suiteXmlFile>
</suiteXmlFiles>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<profile>
<!-- integration tests, requires Cosmos DB endpoint -->
<id>examples</id>
<properties>
<!-- reset the test group as examples have no test group -->
<test.groups>samples,examples</test.groups>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.22.0</version> <!-- {x-version-update;org.apache.maven.plugins:maven-failsafe-plugin;external_dependency} -->
<configuration>
<suiteXmlFiles>
<suiteXmlFile>src/test/resources/examples-testng.xml</suiteXmlFile>
</suiteXmlFiles>
</configuration>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<!-- integration tests, requires Cosmos DB Emulator Endpoint -->
<id>emulator</id>
<properties>
<test.groups>emulator</test.groups>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.22.0</version> <!-- {x-version-update;org.apache.maven.plugins:maven-failsafe-plugin;external_dependency} -->
<configuration>
<suiteXmlFiles>
<suiteXmlFile>src/test/resources/emulator-testng.xml</suiteXmlFile>
</suiteXmlFiles>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<profile>
<!-- integration tests, requires Cosmos DB Emulator Endpoint -->
<id>non-emulator</id>
<properties>
<test.groups>non-emulator</test.groups>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.22.0</version> <!-- {x-version-update;org.apache.maven.plugins:maven-failsafe-plugin;external_dependency} -->
<configuration>
<suiteXmlFiles>
<suiteXmlFile>src/test/resources/non-emulator-testng.xml</suiteXmlFile>
</suiteXmlFiles>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<profile>
<!-- e2e integration tests, requires Cosmos DB endpoint -->
<id>e2e</id>
<id>encryption-integration</id>
<properties>
<test.groups>e2e</test.groups>
<test.groups>encryption</test.groups>
</properties>
<build>
<plugins>
Expand All @@ -416,7 +259,7 @@ Licensed under the MIT License.
<version>2.22.0</version> <!-- {x-version-update;org.apache.maven.plugins:maven-failsafe-plugin;external_dependency} -->
<configuration>
<suiteXmlFiles>
<suiteXmlFile>src/test/resources/e2e-testng.xml</suiteXmlFile>
<suiteXmlFile>src/test/resources/encryption-testng.xml</suiteXmlFile>
</suiteXmlFiles>
</configuration>
</plugin>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
* SQL client implementation with StyleCop related changes - also, we restrict to randomized encryption to start with.
*/
class AeadAes256CbcHmac256Algorithm implements DataEncryptionKey {

// TODO: moderakh is there any other library which we can use?
public final static String ALGORITHM_NAME = "AEAD_AES_256_CBC_HMAC_SHA256";

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
public class CosmosDataEncryptionKeyProvider implements DataEncryptionKeyProvider {
// TODO: proper sample and documentation on container
private static final String ContainerPartitionKeyPath = "/id";
// TODO: moderakh
// Is it a requirement on container definition?
//Then the code-docs and samples needs to explicit cover it.
private final DataEncryptionKeyContainerCore dataEncryptionKeyContainerCore;
private final DekCache DekCache;
private final EncryptionKeyWrapProvider EncryptionKeyWrapProvider;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,26 +43,26 @@ public EncryptionTest2(CosmosClientBuilder clientBuilder) {
super(CosmosBridgeInternal.setDateKeyProvider(clientBuilder, simpleInMemoryProvider));
}

@BeforeClass(groups = {"emulator"}, timeOut = SETUP_TIMEOUT)
@BeforeClass(groups = {"encryption"}, timeOut = SETUP_TIMEOUT)
public void before_CosmosItemTest() {
assertThat(this.client).isNull();
this.client = getClientBuilder().buildClient();
CosmosAsyncContainer asyncContainer = getSharedMultiPartitionCosmosContainer(this.client.asyncClient());
container = client.getDatabase(asyncContainer.getDatabase().getId()).getContainer(asyncContainer.getId());
}

@BeforeClass(groups = "emulator")
@BeforeClass(groups = "encryption")
public void beforeClass() {
TestUtils.initialized();
}

@AfterClass(groups = {"emulator"}, timeOut = SHUTDOWN_TIMEOUT, alwaysRun = true)
@AfterClass(groups = {"encryption"}, timeOut = SHUTDOWN_TIMEOUT, alwaysRun = true)
public void afterClass() {
assertThat(this.client).isNotNull();
this.client.close();
}

@Test(groups = {"emulator"}, timeOut = TIMEOUT)
@Test(groups = {"encryption"}, timeOut = TIMEOUT)
public void createItemEncrypt_readItemDecrypt() throws Exception {
CosmosItemRequestOptions requestOptions = new CosmosItemRequestOptions();
EncryptionOptions encryptionOptions = new EncryptionOptions();
Expand All @@ -88,7 +88,7 @@ public void createItemEncrypt_readItemDecrypt() throws Exception {
validateReadResponseIsValid(properties, readItem);
}

@Test(groups = {"emulator"}, timeOut = TIMEOUT)
@Test(groups = {"encryption"}, timeOut = TIMEOUT)
public void upsertItem_readItem() throws Exception {
CosmosItemRequestOptions requestOptions = new CosmosItemRequestOptions();
EncryptionOptions encryptionOptions = new EncryptionOptions();
Expand Down Expand Up @@ -135,7 +135,7 @@ private void validateQueryResponseIsValid(Pojo originalItem, Pojo result) {
assertThat(result.sensitive).isNull();
}

@Test(groups = {"emulator"}, timeOut = TIMEOUT)
@Test(groups = {"encryption"}, timeOut = TIMEOUT)
public void readItem() throws Exception {
Pojo properties = getItem(UUID.randomUUID().toString());
CosmosItemResponse<Pojo> itemResponse = container.createItem(properties);
Expand All @@ -147,7 +147,7 @@ public void readItem() throws Exception {
validateItemResponse(properties, readResponse1);
}

@Test(groups = {"emulator"}, timeOut = TIMEOUT)
@Test(groups = {"encryption"}, timeOut = TIMEOUT)
public void readAllItems() throws Exception {
Pojo properties = getItem(UUID.randomUUID().toString());
CosmosItemResponse<Pojo> itemResponse = container.createItem(properties);
Expand All @@ -160,7 +160,7 @@ public void readAllItems() throws Exception {
}


@Test(groups = {"emulator"}, timeOut = TIMEOUT)
@Test(groups = {"encryption"}, timeOut = TIMEOUT)
public void queryItems() throws Exception {
Pojo properties = getItem(UUID.randomUUID().toString());
CosmosItemResponse<Pojo> itemResponse = container.createItem(properties);
Expand All @@ -179,7 +179,7 @@ public void queryItems() throws Exception {
assertThat(feedResponseIterator3.iterator().hasNext()).isTrue();
}

@Test(groups = {"emulator"}, timeOut = TIMEOUT)
@Test(groups = {"encryption"}, timeOut = TIMEOUT)
public void queryItemsWithContinuationTokenAndPageSize() throws Exception {
List<String> actualIds = new ArrayList<>();
Pojo properties = getItem(UUID.randomUUID().toString());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,22 +55,22 @@ public DecryptDataEncryptedByDotNetTest(CosmosClientBuilder clientBuilder) {
super(clientBuilder);
}

@BeforeClass(groups = "emulator")
@BeforeClass(groups = "encryption")
public void beforeClass() {
TestUtils.initialized();
}

@AfterClass(groups = "emulator")
@AfterClass(groups = "encryption")
public void afterClass() {
safeDeleteDatabase(databaseCore);
}

@AfterMethod(groups = "emulator")
@AfterMethod(groups = "encryption")
public void afterMethod() {
safeClose(client);
}

@BeforeMethod(groups = "emulator")
@BeforeMethod(groups = "encryption")
public void beforeMethod() {
keyWrapProvider = new TestKeyWrapProvider();
dekProvider = new CosmosDataEncryptionKeyProvider(keyWrapProvider);
Expand All @@ -88,7 +88,7 @@ public void beforeMethod() {
dekProvider.initialize(databaseCore, keyContainer.getId());
}

@Test(groups = "emulator")
@Test(groups = "encryption")
public void canReadKeyEncryptionKeyGeneratedByDotNet() throws Exception {
// add key generated by dotnet
ObjectNode dataEncryptionKeyProperties = TestUtils.loadPojo("./encryption/dotnet/DataEncryptionKeyProperties.json", ObjectNode.class);
Expand All @@ -106,7 +106,7 @@ public void canReadKeyEncryptionKeyGeneratedByDotNet() throws Exception {
assertThat(loadedKey.getRawKey()).isEqualTo(expectedUnWrappedKey.getDataEncryptionKey());
}

@Test(groups = "emulator")
@Test(groups = "encryption")
public void canDecryptDataEncryptedByDotNet() throws Exception {
// add key generated by dotnet
DataEncryptionKeyProperties dataEncryptionKeyProperties = TestUtils.loadPojo("./encryption/dotnet/DataEncryptionKeyProperties.json", DataEncryptionKeyProperties.class);
Expand Down
Loading