-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CSHARP-4255: Fix bug and some tests. (#993)
- Loading branch information
1 parent
c0c521e
commit 0bb42fa
Showing
9 changed files
with
425 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
src/MongoDB.Driver/Encryption/CreateEncryptedCollectionResult.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* Copyright 2010-present MongoDB Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
using MongoDB.Bson; | ||
|
||
namespace MongoDB.Driver.Encryption | ||
{ | ||
/// <summary> | ||
/// Represents the result of a create encrypted collection. | ||
/// </summary> | ||
public sealed class CreateEncryptedCollectionResult | ||
{ | ||
private readonly BsonDocument _encryptedFields; | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="CreateEncryptedCollectionResult"/> class. | ||
/// </summary> | ||
/// <param name="encryptedFields">The encrypted fields document.</param> | ||
public CreateEncryptedCollectionResult(BsonDocument encryptedFields) => _encryptedFields = encryptedFields; | ||
|
||
/// <summary> | ||
/// The encrypted fields document. | ||
/// </summary> | ||
public BsonDocument EncryptedFields => _encryptedFields; | ||
} | ||
} |
69 changes: 69 additions & 0 deletions
69
src/MongoDB.Driver/Encryption/MongoEncryptionCreateCollectionException.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
/* Copyright 2010-present MongoDB Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
using System; | ||
using System.Runtime.Serialization; | ||
using MongoDB.Bson; | ||
|
||
namespace MongoDB.Driver.Encryption | ||
{ | ||
/// <summary> | ||
/// Represents an encryption exception. | ||
/// </summary> | ||
[Serializable] | ||
public class MongoEncryptionCreateCollectionException : MongoEncryptionException | ||
{ | ||
private readonly BsonDocument _encryptedFields; | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="MongoEncryptionException"/> class. | ||
/// </summary> | ||
/// <param name="innerException">The inner exception.</param> | ||
/// <param name="encryptedFields">The encrypted fields.</param> | ||
public MongoEncryptionCreateCollectionException(Exception innerException, BsonDocument encryptedFields) | ||
: base(innerException) | ||
{ | ||
_encryptedFields = encryptedFields; | ||
} | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="MongoEncryptionCreateCollectionException"/> class (this overload used by deserialization). | ||
/// </summary> | ||
/// <param name="info">The SerializationInfo.</param> | ||
/// <param name="context">The StreamingContext.</param> | ||
protected MongoEncryptionCreateCollectionException(SerializationInfo info, StreamingContext context) | ||
: base(info, context) | ||
{ | ||
_encryptedFields = (BsonDocument)info.GetValue(nameof(_encryptedFields), typeof(BsonDocument)); | ||
} | ||
|
||
/// <summary> | ||
/// The encrypted fields. | ||
/// </summary> | ||
public BsonDocument EncryptedFields => _encryptedFields; | ||
|
||
// public methods | ||
/// <summary> | ||
/// Gets the object data. | ||
/// </summary> | ||
/// <param name="info">The information.</param> | ||
/// <param name="context">The context.</param> | ||
public override void GetObjectData(SerializationInfo info, StreamingContext context) | ||
{ | ||
base.GetObjectData(info, context); | ||
info.AddValue(nameof(_encryptedFields), _encryptedFields); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.