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

Added API to inject custom serializer for point read and query #38997

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
e1241ef
Added API to inject custom serializer for point read and query
FabianMeiswinkel Feb 28, 2024
83b5d0a
Update CosmosItemSerializer.java
FabianMeiswinkel Feb 28, 2024
adadc4e
Adding CreateItemCustomSerializer
FabianMeiswinkel Feb 29, 2024
a55feba
Update DatabaseAccount.java
FabianMeiswinkel Feb 29, 2024
affe591
Update JsonSerializable.java
FabianMeiswinkel Mar 1, 2024
2225b7a
Fixing primitive serialization
FabianMeiswinkel Mar 1, 2024
f079153
Update PrimitiveJsonNodeMap.java
FabianMeiswinkel Mar 1, 2024
27d6932
Merge branch 'main' of https://github.com/Azure/azure-sdk-for-java in…
FabianMeiswinkel Mar 4, 2024
cc4213d
Update ItemBulkOperation.java
FabianMeiswinkel Mar 4, 2024
cdb7a5a
Merge branch 'main' of https://github.com/Azure/azure-sdk-for-java in…
FabianMeiswinkel Mar 4, 2024
74f3c1f
Merge branch 'main' of https://github.com/Azure/azure-sdk-for-java in…
FabianMeiswinkel Mar 5, 2024
ffec5f0
Merge branch 'main' of https://github.com/Azure/azure-sdk-for-java in…
FabianMeiswinkel Mar 20, 2024
892859b
Iterating on fix
FabianMeiswinkel Mar 21, 2024
b468a6e
Merge branch 'main' of https://github.com/Azure/azure-sdk-for-java in…
FabianMeiswinkel Mar 22, 2024
bcf0900
Fixing build issues
FabianMeiswinkel Mar 22, 2024
aac26d8
Update CosmosItemSerializer.java
FabianMeiswinkel Mar 23, 2024
599b725
Fixing test failures
FabianMeiswinkel Mar 23, 2024
9053878
Attempting to fix flakiness of Change feed split tests
FabianMeiswinkel Mar 23, 2024
133883c
Merge branch 'main' of https://github.com/Azure/azure-sdk-for-java in…
FabianMeiswinkel Mar 23, 2024
4197626
Update Utils.java
FabianMeiswinkel Mar 25, 2024
001ffac
Iterating on test coverage
FabianMeiswinkel Mar 26, 2024
765ca6b
Iterating on test coverage
FabianMeiswinkel Mar 26, 2024
966abb3
Update Utils.java
FabianMeiswinkel Mar 26, 2024
a5fd6fa
Update EncryptionUtils.java
FabianMeiswinkel Mar 26, 2024
4ddd982
Iterating on test coverage
FabianMeiswinkel Mar 26, 2024
58a0d00
Update Utils.java
FabianMeiswinkel Mar 27, 2024
70432ce
Added upsert to test coverage
FabianMeiswinkel Mar 27, 2024
cbb5da6
Merge branch 'main' of https://github.com/Azure/azure-sdk-for-java in…
FabianMeiswinkel Mar 27, 2024
f6fa294
Update ImplementationBridgeHelpers.java
FabianMeiswinkel Mar 27, 2024
f1fae94
Update Utils.java
FabianMeiswinkel Mar 27, 2024
1b7ae97
Added Bulk test coverage
FabianMeiswinkel Mar 28, 2024
be4c1b6
Merge branch 'main' of https://github.com/Azure/azure-sdk-for-java in…
FabianMeiswinkel Apr 3, 2024
aa4cdf2
Update ItemBulkOperation.java
FabianMeiswinkel Apr 3, 2024
ba66b16
Update CosmosItemSerializer.java
FabianMeiswinkel Apr 3, 2024
c464353
Adding batch and change feed test coverage
FabianMeiswinkel Apr 3, 2024
93a67f0
Update ItemBatchOperation.java
FabianMeiswinkel Apr 3, 2024
6495aea
Merge branch 'main' of https://github.com/Azure/azure-sdk-for-java in…
FabianMeiswinkel Apr 3, 2024
438cfd4
Merge branch 'main' of https://github.com/Azure/azure-sdk-for-java in…
FabianMeiswinkel Apr 3, 2024
fa163dd
Update SimpleSerializationTest.java
FabianMeiswinkel Apr 4, 2024
0d30958
Update ParallelDocumentQueryTest.java
FabianMeiswinkel Apr 4, 2024
bbd72fa
Adding remaining test coverage
FabianMeiswinkel Apr 8, 2024
3630a44
Merge branch 'main' of https://github.com/Azure/azure-sdk-for-java in…
FabianMeiswinkel Apr 8, 2024
ca52d16
Update CosmosEncryptionItemSerializerTest.java
FabianMeiswinkel Apr 8, 2024
17f5d41
Added change log
FabianMeiswinkel Apr 8, 2024
18bd284
Update TestSuiteBase.java
FabianMeiswinkel Apr 8, 2024
dc67843
Update TestSuiteBase.java
FabianMeiswinkel Apr 8, 2024
c18c2de
Fixing JavaDoc break
FabianMeiswinkel Apr 8, 2024
6329923
NITs
FabianMeiswinkel Apr 8, 2024
2ddd8f2
Update CosmosEncryptionAsyncClient.java
FabianMeiswinkel Apr 8, 2024
3234fb2
Fixing test failures
FabianMeiswinkel Apr 9, 2024
8f54689
Merge branch 'main' of https://github.com/Azure/azure-sdk-for-java in…
FabianMeiswinkel Apr 9, 2024
f4495ab
Merge branch 'main' of https://github.com/Azure/azure-sdk-for-java in…
FabianMeiswinkel Apr 10, 2024
e7508d0
Exclduing netty-all in Spark 3.1 and 3.2
FabianMeiswinkel Apr 10, 2024
15441f5
Merge branch 'main' of https://github.com/Azure/azure-sdk-for-java in…
FabianMeiswinkel Apr 11, 2024
3bd3378
Reacting to code review feeedback
FabianMeiswinkel Apr 16, 2024
305111b
Merge branch 'main' of https://github.com/Azure/azure-sdk-for-java in…
FabianMeiswinkel Apr 16, 2024
58dcb67
Merge branch 'main' of https://github.com/Azure/azure-sdk-for-java in…
FabianMeiswinkel Apr 16, 2024
aaf5944
Merge branch 'main' of https://github.com/Azure/azure-sdk-for-java in…
FabianMeiswinkel Apr 22, 2024
1c4b332
Update sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/CosmosE…
FabianMeiswinkel Apr 22, 2024
a70af81
Update sdk/cosmos/azure-cosmos-encryption/src/main/java/com/azure/cos…
FabianMeiswinkel Apr 22, 2024
ef42b2c
Update sdk/cosmos/azure-cosmos-encryption/src/main/java/com/azure/cos…
FabianMeiswinkel Apr 22, 2024
d47d7fc
Reacting to code review feedback
FabianMeiswinkel Apr 22, 2024
1265d74
Merge branch 'users/fabianm/PayloadTransformations' of https://github…
FabianMeiswinkel Apr 22, 2024
e2d7b9b
Update FeedResponse.java
FabianMeiswinkel Apr 22, 2024
98a261d
Merge branch 'main' of https://github.com/Azure/azure-sdk-for-java in…
FabianMeiswinkel Apr 23, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@

package com.azure.cosmos.benchmark;

import com.azure.cosmos.BridgeInternal;
import com.azure.cosmos.CosmosBridgeInternal;
import com.azure.cosmos.CosmosException;
import com.azure.cosmos.CosmosItemSerializer;
import com.azure.cosmos.implementation.AsyncDocumentClient;
import com.azure.cosmos.implementation.CosmosPagedFluxOptions;
import com.azure.cosmos.implementation.Database;
Expand Down Expand Up @@ -194,12 +194,12 @@ private Flux<Document> writeDocument(Integer i) {
String randomVal = UUID.randomUUID().toString();
Document document = new Document();
document.setId(idString);
BridgeInternal.setProperty(document, partitionKey, idString);
BridgeInternal.setProperty(document, QUERY_FIELD_NAME, randomVal);
BridgeInternal.setProperty(document, "dataField1", randomVal);
BridgeInternal.setProperty(document, "dataField2", randomVal);
BridgeInternal.setProperty(document, "dataField3", randomVal);
BridgeInternal.setProperty(document, "dataField4", randomVal);
document.set(partitionKey, idString, CosmosItemSerializer.DEFAULT_SERIALIZER);
document.set(QUERY_FIELD_NAME, randomVal, CosmosItemSerializer.DEFAULT_SERIALIZER);
document.set("dataField1", randomVal, CosmosItemSerializer.DEFAULT_SERIALIZER);
document.set("dataField2", randomVal, CosmosItemSerializer.DEFAULT_SERIALIZER);
document.set("dataField3", randomVal, CosmosItemSerializer.DEFAULT_SERIALIZER);
document.set("dataField4", randomVal, CosmosItemSerializer.DEFAULT_SERIALIZER);

Integer key = i == null ? cacheKey() : i;
return client.createDocument(getCollectionLink(), document, null, false)
Expand Down
1 change: 1 addition & 0 deletions sdk/cosmos/azure-cosmos-encryption/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
### 2.11.0-beta.1 (Unreleased)

#### Features Added
FabianMeiswinkel marked this conversation as resolved.
Show resolved Hide resolved
* Added public APIs `getCustomeSerializer` and `setCustomSerializer` to allow customers to specify custom payload transformations or serialization settings. - See [PR 38997](https://github.com/Azure/azure-sdk-for-java/pull/38997)

#### Breaking Changes

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import com.azure.cosmos.CosmosAsyncContainer;
import com.azure.cosmos.CosmosAsyncDatabase;
import com.azure.cosmos.CosmosException;
import com.azure.cosmos.CosmosItemSerializer;
import com.azure.cosmos.encryption.implementation.Constants;
import com.azure.cosmos.encryption.implementation.EncryptionImplementationBridgeHelpers;
import com.azure.cosmos.encryption.implementation.keyprovider.EncryptionKeyStoreProviderImpl;
Expand Down Expand Up @@ -46,6 +47,8 @@ public final class CosmosEncryptionAsyncClient implements Closeable {
private final EncryptionKeyStoreProviderImpl encryptionKeyStoreProviderImpl;
private final static ImplementationBridgeHelpers.CosmosAsyncClientEncryptionKeyHelper.CosmosAsyncClientEncryptionKeyAccessor cosmosAsyncClientEncryptionKeyAccessor = ImplementationBridgeHelpers.CosmosAsyncClientEncryptionKeyHelper.getCosmosAsyncClientEncryptionKeyAccessor();

private final static ImplementationBridgeHelpers.CosmosAsyncClientHelper.CosmosAsyncClientAccessor cosmosAsyncClientAccessor = ImplementationBridgeHelpers.CosmosAsyncClientHelper.getCosmosAsyncClientAccessor();

CosmosEncryptionAsyncClient(CosmosAsyncClient cosmosAsyncClient,
KeyEncryptionKeyResolver keyEncryptionKeyResolver,
String keyEncryptionKeyResolverName) {
Expand Down Expand Up @@ -230,6 +233,15 @@ private CosmosContainerProperties getContainerPropertiesWithVersionValidation(Co
return cosmosContainerResponse.getProperties();
}

CosmosItemSerializer getEffectiveItemSerializer(
CosmosItemSerializer requestOptionsItemSerializer) {

return cosmosAsyncClientAccessor
.getEffectiveItemSerializer(
this.getCosmosAsyncClient(),
requestOptionsItemSerializer);
}

static {
EncryptionImplementationBridgeHelpers.CosmosEncryptionAsyncClientHelper.seCosmosEncryptionAsyncClientAccessor(new EncryptionImplementationBridgeHelpers.CosmosEncryptionAsyncClientHelper.CosmosEncryptionAsyncClientAccessor() {
@Override
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -3,49 +3,58 @@
package com.azure.cosmos.encryption.implementation;

import com.azure.cosmos.BridgeInternal;
import com.azure.cosmos.CosmosItemSerializer;
import com.azure.cosmos.implementation.CosmosPagedFluxOptions;
import com.azure.cosmos.implementation.ItemDeserializer;
import com.azure.cosmos.implementation.ObjectNodeMap;
import com.azure.cosmos.implementation.PrimitiveJsonNodeMap;
import com.azure.cosmos.implementation.Utils;
import com.azure.cosmos.implementation.query.Transformer;
import com.azure.cosmos.models.FeedResponse;
import com.azure.cosmos.models.ModelBridgeInternal;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.node.ObjectNode;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
import reactor.core.scheduler.Scheduler;

import java.util.List;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;

import static com.azure.cosmos.implementation.guava25.base.Preconditions.checkNotNull;

public class CosmosEncryptionQueryTransformer<T> implements Transformer<T> {
private final Scheduler encryptionScheduler;
private final EncryptionProcessor encryptionProcessor;
private final ItemDeserializer itemDeserializer;
private final Class<T> classType;
private final boolean isChangeFeed;

public CosmosEncryptionQueryTransformer(
Scheduler encryptionScheduler,
EncryptionProcessor encryptionProcessor,
ItemDeserializer itemDeserializer,
Class<T> classType,
Boolean isChangeFeed) {

this.encryptionScheduler = encryptionScheduler;
this.encryptionProcessor = encryptionProcessor;
this.itemDeserializer = itemDeserializer;
this.classType = classType;
this.isChangeFeed = isChangeFeed;
}

@Override
public Function<CosmosPagedFluxOptions, Flux<FeedResponse<T>>> transform(Function<CosmosPagedFluxOptions, Flux<FeedResponse<JsonNode>>> func) {
return queryDecryptionTransformer(this.classType, this.isChangeFeed, func);
public Function<CosmosPagedFluxOptions, Flux<FeedResponse<T>>> transform(
Function<CosmosPagedFluxOptions, Flux<FeedResponse<JsonNode>>> func,
CosmosItemSerializer effectiveSerializer) {

return queryDecryptionTransformer(this.classType, this.isChangeFeed, func, effectiveSerializer);
}

private <T> Function<CosmosPagedFluxOptions, Flux<FeedResponse<T>>> queryDecryptionTransformer(
Class<T> classType,
private <TTransform> Function<CosmosPagedFluxOptions, Flux<FeedResponse<TTransform>>> queryDecryptionTransformer(
Class<TTransform> classType,
boolean isChangeFeed,
Function<CosmosPagedFluxOptions, Flux<FeedResponse<JsonNode>>> func) {
Function<CosmosPagedFluxOptions, Flux<FeedResponse<JsonNode>>> func,
CosmosItemSerializer effectiveSerializer) {
return func.andThen(flux ->
flux.publishOn(encryptionScheduler)
.flatMap(
Expand All @@ -55,9 +64,27 @@ private <T> Function<CosmosPagedFluxOptions, Flux<FeedResponse<T>>> queryDecrypt
ModelBridgeInternal.getNoChangesFromFeedResponse(page)
: false;
List<Mono<JsonNode>> jsonNodeArrayMonoList =
page.getResults().stream().map(jsonNode -> decryptResponseNode(jsonNode)).collect(Collectors.toList());
page.getResults().stream().map(jsonNode -> decryptResponseNode(jsonNode))
.collect(Collectors.toList());
return Flux.concat(jsonNodeArrayMonoList).map(
item -> this.itemDeserializer.convert(classType, item)
item -> {
Map<String, Object> decryptedJsonTree;

if (item instanceof ObjectNode) {
decryptedJsonTree = new ObjectNodeMap((ObjectNode)item);
} else if (item.isValueNode()) {
decryptedJsonTree = new PrimitiveJsonNodeMap(item);
} else {
return Utils.getSimpleObjectMapper()
.convertValue(
item,
classType);
}

return effectiveSerializer.deserialize(
decryptedJsonTree,
classType);
}
).collectList().map(itemList -> BridgeInternal.createFeedResponseWithQueryMetrics(itemList,
page.getResponseHeaders(),
BridgeInternal.queryMetricsFromFeedResponse(page),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@

package com.azure.cosmos.encryption.implementation;

import com.azure.cosmos.CosmosItemSerializer;
import com.azure.cosmos.implementation.ImplementationBridgeHelpers;
import com.azure.cosmos.implementation.ImplementationBridgeHelpers.CosmosItemResponseHelper.CosmosItemResponseBuilderAccessor;
import com.azure.cosmos.implementation.ItemDeserializer;
import com.azure.cosmos.models.CosmosItemResponse;

public class CosmosResponseFactory {
Expand All @@ -17,10 +17,11 @@ public CosmosResponseFactory() {
}

public <T> CosmosItemResponse<T> createItemResponse(CosmosItemResponse<byte[]> responseMessage,
Class<T> classType) {
Class<T> classType,
CosmosItemSerializer effectiveItemSerializer) {
return cosmosItemResponseBuilderAccessor.createCosmosItemResponse(
responseMessage,
classType,
new ItemDeserializer.JsonDeserializer());
effectiveItemSerializer);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import com.azure.cosmos.BridgeInternal;
import com.azure.cosmos.CosmosAsyncContainer;
import com.azure.cosmos.CosmosItemSerializer;
import com.azure.cosmos.encryption.CosmosEncryptionAsyncClient;
import com.azure.cosmos.encryption.implementation.keyprovider.EncryptionKeyStoreProviderImpl;
import com.azure.cosmos.encryption.implementation.mdesrc.cryptography.EncryptionType;
Expand Down Expand Up @@ -54,10 +55,10 @@

public class EncryptionProcessor {
private final static Logger LOGGER = LoggerFactory.getLogger(EncryptionProcessor.class);
private CosmosEncryptionAsyncClient encryptionCosmosClient;
private CosmosAsyncContainer cosmosAsyncContainer;
private EncryptionSettings encryptionSettings;
private AtomicBoolean isEncryptionSettingsInitDone;
private final CosmosEncryptionAsyncClient encryptionCosmosClient;
private final CosmosAsyncContainer cosmosAsyncContainer;
private final EncryptionSettings encryptionSettings;
private final AtomicBoolean isEncryptionSettingsInitDone;
private ClientEncryptionPolicy clientEncryptionPolicy;
private String containerRid;
private String databaseRid;
Expand Down Expand Up @@ -254,12 +255,15 @@ public Mono<byte[]> encrypt(byte[] payload) {
payload == null ? null : payload.length,
Thread.currentThread().getName());
}
ObjectNode itemJObj = Utils.parse(payload, ObjectNode.class);
ObjectNode itemJObj = Utils.parse(payload, ObjectNode.class, CosmosItemSerializer.DEFAULT_SERIALIZER);
return encrypt(itemJObj);
}

public Mono<byte[]> encrypt(JsonNode itemJObj) {
return encryptObjectNode(itemJObj).map(encryptedObjectNode -> EncryptionUtils.serializeJsonToByteArray(EncryptionUtils.getSimpleObjectMapper(), encryptedObjectNode));
return encryptObjectNode(itemJObj).map(
encryptedObjectNode -> EncryptionUtils.serializeJsonToByteArray(
CosmosItemSerializer.DEFAULT_SERIALIZER,
encryptedObjectNode));
}

public Mono<JsonNode> encryptPatchNode(JsonNode itemObj, String patchPropertyPath) {
Expand All @@ -273,7 +277,8 @@ public Mono<JsonNode> encryptPatchNode(JsonNode itemObj, String patchPropertyPat

for (ClientEncryptionIncludedPath includedPath : this.clientEncryptionPolicy.getIncludedPaths()) {
String propertyName = includedPath.getPath().substring(1);
if (patchPropertyPath.substring(1).equals(propertyName)) {
String relativePatchPropertyPath = patchPropertyPath.substring(1);
if (relativePatchPropertyPath.equals(propertyName) || relativePatchPropertyPath.startsWith(propertyName + "/")) {
if (itemObj.isValueNode()) {
return this.encryptionSettings.getEncryptionSettingForPropertyAsync(propertyName,
this).flatMap(settings -> {
Expand Down Expand Up @@ -497,7 +502,7 @@ public byte[] encryptAndSerializeValue(EncryptionSettings encryptionSettings, Ob
return cipherTextWithTypeMarker;
}

public Mono<Pair<byte[], JsonNode>> decrypt(byte[] input) {
public Mono<Pair<byte[], JsonNode>> decrypt(byte[] input, CosmosItemSerializer itemSerializer) {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Encrypting byte[] of size [{}] on thread [{}]",
input == null ? null : input.length,
Expand All @@ -508,13 +513,13 @@ public Mono<Pair<byte[], JsonNode>> decrypt(byte[] input) {
return Mono.empty();
}

ObjectNode itemJObj = Utils.parse(input, ObjectNode.class);
return decrypt(itemJObj);
ObjectNode itemJObj = Utils.parse(input, ObjectNode.class, CosmosItemSerializer.DEFAULT_SERIALIZER);
return decrypt(itemJObj, itemSerializer);
}

public Mono<Pair<byte[], JsonNode>> decrypt(JsonNode itemJObj) {
public Mono<Pair<byte[], JsonNode>> decrypt(JsonNode itemJObj, CosmosItemSerializer itemSerializer) {
return decryptJsonNode(itemJObj).map(decryptedObjectNode -> Pair.of(
EncryptionUtils.serializeJsonToByteArray(EncryptionUtils.getSimpleObjectMapper(), decryptedObjectNode),
EncryptionUtils.serializeJsonToByteArray(itemSerializer, decryptedObjectNode),
decryptedObjectNode));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

package com.azure.cosmos.encryption.implementation;

import com.azure.cosmos.CosmosItemSerializer;
import com.azure.cosmos.implementation.Utils;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.databind.DeserializationFeature;
Expand All @@ -21,8 +22,8 @@ public class EncryptionUtils {
EncryptionUtils.simpleObjectMapper.configure(DeserializationFeature.ACCEPT_FLOAT_AS_INT, false);
}

public static byte[] serializeJsonToByteArray(ObjectMapper objectMapper, Object object) {
return toByteArray(Utils.serializeJsonToByteBuffer(objectMapper, object));
public static byte[] serializeJsonToByteArray(CosmosItemSerializer itemSerializer, Object object) {
return toByteArray(Utils.serializeJsonToByteBuffer(itemSerializer, object, null));
}

public static ObjectMapper getSimpleObjectMapper() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

package com.azure.cosmos.encryption.models;

import com.azure.cosmos.CosmosItemSerializer;
import com.azure.cosmos.encryption.CosmosEncryptionAsyncContainer;
import com.azure.cosmos.encryption.implementation.Constants;
import com.azure.cosmos.encryption.implementation.EncryptionImplementationBridgeHelpers;
Expand All @@ -27,8 +28,8 @@
* Represents a SQL query with encryption parameters in the Azure Cosmos DB database service.
*/
public final class SqlQuerySpecWithEncryption {
private SqlQuerySpec sqlQuerySpec;
private HashMap<String, SqlParameter> encryptionParamMap = new HashMap<>();
private final SqlQuerySpec sqlQuerySpec;
private final HashMap<String, SqlParameter> encryptionParamMap = new HashMap<>();
private final EncryptionImplementationBridgeHelpers.CosmosEncryptionAsyncContainerHelper.CosmosEncryptionAsyncContainerAccessor cosmosEncryptionAsyncContainerAccessor = EncryptionImplementationBridgeHelpers.CosmosEncryptionAsyncContainerHelper.getCosmosEncryptionAsyncContainerAccessor();

/**
Expand Down Expand Up @@ -83,9 +84,9 @@ Mono<Void> addEncryptionParameterAsync(String path, SqlParameter sqlParameter,
}
}
byte[] valueByte =
EncryptionUtils.serializeJsonToByteArray(EncryptionUtils.getSimpleObjectMapper(),
EncryptionUtils.serializeJsonToByteArray(CosmosItemSerializer.DEFAULT_SERIALIZER,
sqlParameter.getValue(Object.class));
JsonNode itemJObj = Utils.parse(valueByte, JsonNode.class);
JsonNode itemJObj = Utils.parse(valueByte, JsonNode.class, CosmosItemSerializer.DEFAULT_SERIALIZER);
Pair<EncryptionProcessor.TypeMarker, byte[]> typeMarkerPair =
EncryptionProcessor.toByteArray(itemJObj);
byte[] cipherText =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@
// public API surface area
exports com.azure.cosmos.encryption;
exports com.azure.cosmos.encryption.models;
opens com.azure.cosmos.encryption to com.fasterxml.jackson.databind, com.fasterxml.jackson.module.afterburner;
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import java.lang.reflect.Method;

public abstract class CosmosEncryptionAsyncClientTest implements ITest {

private static final ImplementationBridgeHelpers.CosmosClientBuilderHelper.CosmosClientBuilderAccessor cosmosClientBuilderAccessor =
ImplementationBridgeHelpers.CosmosClientBuilderHelper.getCosmosClientBuilderAccessor();

Expand All @@ -36,17 +35,13 @@ public final CosmosClientBuilder getClientBuilder() {
return this.clientBuilder;
}

public final ConnectionPolicy getConnectionPolicy() {
return cosmosClientBuilderAccessor.getConnectionPolicy(this.clientBuilder);
}

@Override
public final String getTestName() {
return this.testName;
}

@BeforeMethod(alwaysRun = true)
public final void setTestName(Method method) {
public final void setTestName(Method method, Object[] row) {
String testClassAndMethodName = Strings.lenientFormat("%s::%s",
method.getDeclaringClass().getSimpleName(),
method.getName());
Expand All @@ -66,10 +61,19 @@ public final void setTestName(Method method) {
} else {
this.testName = testClassAndMethodName;
}

String suffix = this.resolveTestNameSuffix(row);
if (suffix != null && !suffix.isEmpty()) {
this.testName += "(" + suffix + ")";
}
}

@AfterMethod(alwaysRun = true)
public final void unsetTestName() {
this.testName = null;
}

public String resolveTestNameSuffix(Object[] row) {
return "";
}
}
Loading
Loading