Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,38 @@
"result": {
"errorContains": "Driver support of Queryable Encryption is incompatible with server. Upgrade server to use Queryable Encryption."
}
},
{
"name": "assertCollectionNotExists",
"object": "testRunner",
"arguments": {
"database": "default",
"collection": "enxcol_.encryptedCollection.esc"
}
},
{
"name": "assertCollectionNotExists",
"object": "testRunner",
"arguments": {
"database": "default",
"collection": "enxcol_.encryptedCollection.ecc"
}
},
{
"name": "assertCollectionNotExists",
"object": "testRunner",
"arguments": {
"database": "default",
"collection": "enxcol_.encryptedCollection.ecoc"
}
},
{
"name": "assertCollectionNotExists",
"object": "testRunner",
"arguments": {
"database": "default",
"collection": "encryptedCollection"
}
}
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,25 @@ tests:
collection: "encryptedCollection"
result:
errorContains: "Driver support of Queryable Encryption is incompatible with server. Upgrade server to use Queryable Encryption."
# Assert no collections were created.
- name: assertCollectionNotExists
object: testRunner
arguments:
database: *database_name
collection: &esc_collection_name "enxcol_.encryptedCollection.esc"
# ecc collection is no longer created for QEv2
- name: assertCollectionNotExists
object: testRunner
arguments:
database: *database_name
collection: &ecc_collection_name "enxcol_.encryptedCollection.ecc"
- name: assertCollectionNotExists
object: testRunner
arguments:
database: *database_name
collection: &ecoc_collection_name "enxcol_.encryptedCollection.ecoc"
- name: assertCollectionNotExists
object: testRunner
arguments:
database: *database_name
collection: encryptedCollection
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ internal static IWriteOperation<BsonDocument> CreateEncryptedCreateCollectionOpe
{
var mainOperation = new CreateCollectionOperation(
collectionNamespace,
messageEncoderSettings)
messageEncoderSettings,
encryptedFields != null ? Feature.Csfle2QEv2 : null)
{
EncryptedFields = encryptedFields
};
Expand All @@ -62,7 +63,10 @@ internal static IWriteOperation<BsonDocument> CreateEncryptedCreateCollectionOpe
}

CreateCollectionOperation CreateInnerCollectionOperation(string collectionName)
=> new CreateCollectionOperation(new CollectionNamespace(collectionNamespace.DatabaseNamespace.DatabaseName, collectionName), messageEncoderSettings) { ClusteredIndex = new BsonDocument { { "key", new BsonDocument("_id", 1) }, { "unique", true } } };
=> new(new CollectionNamespace(collectionNamespace.DatabaseNamespace.DatabaseName, collectionName), messageEncoderSettings, Feature.Csfle2QEv2)
{
ClusteredIndex = new BsonDocument { { "key", new BsonDocument("_id", 1) }, { "unique", true } }
};
}
#endregion

Expand All @@ -89,6 +93,8 @@ CreateCollectionOperation CreateInnerCollectionOperation(string collectionName)
private BsonDocument _validator;
private WriteConcern _writeConcern;

private readonly Feature _supportedFeature;

// constructors
/// <summary>
/// Initializes a new instance of the <see cref="CreateCollectionOperation"/> class.
Expand All @@ -109,6 +115,7 @@ private CreateCollectionOperation(
{
_collectionNamespace = Ensure.IsNotNull(collectionNamespace, nameof(collectionNamespace));
_messageEncoderSettings = messageEncoderSettings;
_supportedFeature = supportedFeature;
}

// properties
Expand Down Expand Up @@ -455,10 +462,7 @@ private WriteCommandOperation<BsonDocument> CreateOperation(ICoreSessionHandle s

private void EnsureServerIsValid(int maxWireVersion)
{
if (_encryptedFields != null)
{
Feature.Csfle2QEv2.ThrowIfNotSupported(maxWireVersion);
}
_supportedFeature?.ThrowIfNotSupported(maxWireVersion);
}

[Flags]
Expand Down