Skip to content

Commit 6098c29

Browse files
committed
Small fix
1 parent 134622e commit 6098c29

File tree

1 file changed

+35
-35
lines changed

1 file changed

+35
-35
lines changed

tests/MongoDB.Driver.Tests/Encryption/CsfleSchemaBuilderTests.cs

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,16 @@ namespace MongoDB.Driver.Tests.Encryption
2525
{
2626
public class CsfleSchemaBuilderTests
2727
{
28+
private readonly CollectionNamespace _collectionNamespace = CollectionNamespace.FromFullName("medicalRecords.patients");
2829
private const string _keyIdString = "6f4af470-00d1-401f-ac39-f45902a0c0c8";
2930
private static Guid _keyId = Guid.Parse(_keyIdString);
3031

3132
[Fact]
3233
public void CsfleSchemaBuilder_works_as_expected()
3334
{
34-
const string collectionName = "medicalRecords.patients";
35-
3635
var builder = CsfleSchemaBuilder.Create(schemaBuilder =>
3736
{
38-
schemaBuilder.Encrypt<Patient>(collectionName, builder =>
37+
schemaBuilder.Encrypt<Patient>(_collectionNamespace, builder =>
3938
{
4039
builder
4140
.EncryptMetadata(keyId: _keyId)
@@ -67,7 +66,7 @@ public void CsfleSchemaBuilder_works_as_expected()
6766

6867
var expected = new Dictionary<string, string>
6968
{
70-
[collectionName] = """
69+
[_collectionNamespace.FullName] = """
7170
{
7271
"bsonType": "object",
7372
"encryptMetadata": {
@@ -145,55 +144,54 @@ public void CsfleSchemaBuilder_works_as_expected()
145144
[Fact]
146145
public void CsfleSchemaBuilder_with_multiple_types_works_as_expected()
147146
{
148-
const string patientCollectionName = "medicalRecords.patients";
149-
const string testClassCollectionName = "test.class";
147+
var testCollectionNamespace = CollectionNamespace.FromFullName("test.class");
150148

151149
var builder = CsfleSchemaBuilder.Create(schemaBuilder =>
152150
{
153-
schemaBuilder.Encrypt<Patient>(patientCollectionName, builder =>
151+
schemaBuilder.Encrypt<Patient>(_collectionNamespace, builder =>
154152
{
155153
builder
156154
.EncryptMetadata(keyId: _keyId)
157155
.Property(p => p.MedicalRecords, BsonType.Array,
158156
EncryptionAlgorithm.AEAD_AES_256_CBC_HMAC_SHA_512_Random);
159157
});
160158

161-
schemaBuilder.Encrypt<TestClass>(testClassCollectionName, builder =>
159+
schemaBuilder.Encrypt<TestClass>(_collectionNamespace, builder =>
162160
{
163161
builder.Property(t => t.TestString, BsonType.String);
164162
});
165163
});
166164

167165
var expected = new Dictionary<string, string>
168166
{
169-
[patientCollectionName] = """
170-
{
171-
"bsonType": "object",
172-
"encryptMetadata": {
173-
"keyId": [{ "$binary" : { "base64" : "b0r0cADRQB+sOfRZAqDAyA==", "subType" : "04" } }]
174-
},
175-
"properties": {
176-
"medicalRecords": {
177-
"encrypt": {
178-
"bsonType": "array",
179-
"algorithm": "AEAD_AES_256_CBC_HMAC_SHA_512-Random"
180-
}
181-
},
182-
},
183-
}
184-
""",
185-
[testClassCollectionName] = """
186-
{
187-
"bsonType": "object",
188-
"properties": {
189-
"TestString": {
190-
"encrypt": {
191-
"bsonType": "string",
192-
}
193-
},
167+
[_collectionNamespace.FullName] = """
168+
{
169+
"bsonType": "object",
170+
"encryptMetadata": {
171+
"keyId": [{ "$binary" : { "base64" : "b0r0cADRQB+sOfRZAqDAyA==", "subType" : "04" } }]
172+
},
173+
"properties": {
174+
"medicalRecords": {
175+
"encrypt": {
176+
"bsonType": "array",
177+
"algorithm": "AEAD_AES_256_CBC_HMAC_SHA_512-Random"
178+
}
179+
},
180+
},
181+
}
182+
""",
183+
[testCollectionNamespace.FullName] = """
184+
{
185+
"bsonType": "object",
186+
"properties": {
187+
"TestString": {
188+
"encrypt": {
189+
"bsonType": "string",
190+
}
191+
},
192+
}
194193
}
195-
}
196-
"""
194+
"""
197195
};
198196

199197
AssertOutcomeCsfleSchemaBuilder(builder, expected);
@@ -277,6 +275,8 @@ public void EncryptedCollection_PatternProperty_works_as_expected(BsonType bsonT
277275
AssertOutcomeCollectionBuilder(builder, expected);
278276
}
279277

278+
//TODO Remember about using the same algorithm...
279+
280280
[Theory]
281281
[InlineData(null,
282282
null,

0 commit comments

Comments
 (0)