diff --git a/Directory.Packages.props b/Directory.Packages.props index c23e8ce94..4e34c62b0 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -11,14 +11,14 @@ - + - - + + @@ -30,7 +30,7 @@ - + diff --git a/src/SmiServices/Common/MongoDB/MongoClientHelpers.cs b/src/SmiServices/Common/MongoDB/MongoClientHelpers.cs index 05cc7dcae..7a1f23f41 100644 --- a/src/SmiServices/Common/MongoDB/MongoClientHelpers.cs +++ b/src/SmiServices/Common/MongoDB/MongoClientHelpers.cs @@ -4,6 +4,8 @@ using NLog; using SmiServices.Common.Options; using System; +using System.Collections.Concurrent; +using System.Collections.Generic; using System.Linq; namespace SmiServices.Common.MongoDB @@ -16,6 +18,8 @@ public static class MongoClientHelpers private static readonly ListCollectionNamesOptions _listOptions = new(); + private static readonly ConcurrentDictionary<(MongoDbOptions options, string applicationName, bool skipAuthentication, bool skipJournal), MongoClient> _clientCache = new(); + /// /// Creates a from the given options, and checks that the user has the "readWrite" role for the given database /// @@ -24,37 +28,42 @@ public static class MongoClientHelpers /// /// /// - public static MongoClient GetMongoClient(MongoDbOptions options, string applicationName, bool skipAuthentication = false, bool skipJournal = false) + public static MongoClient GetMongoClient(MongoDbOptions options, string applicationName, + bool skipAuthentication = false, bool skipJournal = false) + { + var args = (options, applicationName, skipAuthentication, skipJournal); + return _clientCache.GetOrAdd(args, static args => CreateMongoClient(args.options, args.applicationName, + args.skipAuthentication, args.skipJournal)); + } + + private static MongoClient CreateMongoClient(MongoDbOptions options, string applicationName, + bool skipAuthentication, bool skipJournal) { if (!options.AreValid(skipAuthentication)) throw new ApplicationException($"Invalid MongoDB options: {options}"); + var settings = new MongoClientSettings + { + ApplicationName = applicationName, + Servers = new List([new MongoServerAddress(options.HostName, options.Port)]), + WriteConcern = new WriteConcern(journal: !skipJournal), + DirectConnection = true, + HeartbeatInterval = TimeSpan.FromSeconds(10) + }; + if (skipAuthentication || options.UserName == string.Empty) - return new MongoClient(new MongoClientSettings - { - ApplicationName = applicationName, - Server = new MongoServerAddress(options.HostName, options.Port), - WriteConcern = new WriteConcern(journal: !skipJournal) - }); + return new MongoClient(settings); if (string.IsNullOrWhiteSpace(options.Password)) throw new ApplicationException($"MongoDB password must be set"); - MongoCredential credentials = MongoCredential.CreateCredential(AuthDatabase, options.UserName, options.Password); - - var mongoClientSettings = new MongoClientSettings - { - ApplicationName = applicationName, - Credential = credentials, - Server = new MongoServerAddress(options.HostName, options.Port), - WriteConcern = new WriteConcern(journal: !skipJournal) - }; + settings.Credential = MongoCredential.CreateCredential(AuthDatabase, options.UserName, options.Password); - var client = new MongoClient(mongoClientSettings); + var client = new MongoClient(settings); try { - IMongoDatabase db = client.GetDatabase(AuthDatabase); + var db = client.GetDatabase(AuthDatabase); var queryResult = db.RunCommand(new BsonDocument("usersInfo", options.UserName)); if (!(queryResult["ok"] == 1)) @@ -62,10 +71,8 @@ public static MongoClient GetMongoClient(MongoDbOptions options, string applicat var roles = (BsonArray)queryResult[0][0]["roles"]; - var hasReadWrite = false; - foreach (BsonDocument role in roles.Select(x => x.AsBsonDocument)) - if (role["db"].AsString == options.DatabaseName && role["role"].AsString == "readWrite") - hasReadWrite = true; + var hasReadWrite = roles.Select(static x => x.AsBsonDocument).Any(role => + role["db"].AsString == options.DatabaseName && role["role"].AsString == "readWrite"); if (!hasReadWrite) throw new ApplicationException($"User \"{options.UserName}\" does not have readWrite permissions on database \"{options.DatabaseName}\""); diff --git a/src/SmiServices/packages.lock.json b/src/SmiServices/packages.lock.json index 8178a5310..8d4e20843 100644 --- a/src/SmiServices/packages.lock.json +++ b/src/SmiServices/packages.lock.json @@ -61,21 +61,21 @@ }, "HIC.RDMP.Plugin": { "type": "Direct", - "requested": "[8.3.0, )", - "resolved": "8.3.0", - "contentHash": "iKM27C/qJoXECOtdyPmXRTxKvAcEx/EgXsg9D4kMRIZi0V4nlRh8a+PxAHTbfn+0BzfBrmKuEzikF4lyN8tmEQ==", - "dependencies": { - "AWSSDK.S3": "3.7.403.1", - "AWSSDK.SSO": "3.7.400.22", - "AWSSDK.SSOOIDC": "3.7.400.22", - "AWSSDK.SecurityToken": "3.7.400.22", + "requested": "[8.3.1, )", + "resolved": "8.3.1", + "contentHash": "o3iFnwBV+vdiAOq9JpQc7FHtzaUNGgWCBZgFIy2OE7HFGqXFUY/B8MD9FgY4VhJSHBe0T/rlSVmyHT/eqHG5uA==", + "dependencies": { + "AWSSDK.S3": "3.7.405", + "AWSSDK.SSO": "3.7.400.36", + "AWSSDK.SSOOIDC": "3.7.400.36", + "AWSSDK.SecurityToken": "3.7.400.36", "CommandLineParser": "2.9.1", "ExcelNumberFormat": "1.1.0", "FluentFTP": "51.1.0", - "HIC.FAnsiSql": "3.2.6", + "HIC.FAnsiSql": "3.2.7", "HIC.SynthEHR": "2.0.1", "LibArchive.Net": "0.1.5", - "MongoDB.Driver": "2.29.0", + "MongoDB.Driver": "3.0.0", "NLog": "5.3.4", "NPOI": "2.7.1", "Newtonsoft.Json": "13.0.3", @@ -85,7 +85,7 @@ "Spectre.Console": "0.49.1", "System.Resources.Extensions": "8.0.0", "Terminal.Gui": "1.17.1", - "YamlDotNet": "16.1.2" + "YamlDotNet": "16.1.3" } }, "IsIdentifiable": { @@ -152,9 +152,9 @@ }, "MongoDB.Bson": { "type": "Direct", - "requested": "[2.30.0, )", - "resolved": "2.30.0", - "contentHash": "Gg0TQUT3IEntcqdug5a9P6d8iwL5CqOpQjVBCq1hxTbkjxdGdY6a2CPv7II44AO9GYUnORYsS6dDME2b7aqYyg==", + "requested": "[3.0.0, )", + "resolved": "3.0.0", + "contentHash": "qnPRJ58HXDh7C4oxTf6YB7BJhlCGJIa6TMXhzImw6zk44lrAomQXTB6AtoQ5lNJbkyrgQcT7+smsKFMnXmLXhw==", "dependencies": { "System.Memory": "4.5.5", "System.Runtime.CompilerServices.Unsafe": "5.0.0" @@ -162,14 +162,17 @@ }, "MongoDB.Driver": { "type": "Direct", - "requested": "[2.30.0, )", - "resolved": "2.30.0", - "contentHash": "BCG8cNF0+U3h5f/O9fu3ktrYhoESBDems1w06PExfYrn2KjHBHCBdvBRY1cIbysnZVjQAJjGtFV9XgW+hXt7Hg==", + "requested": "[3.0.0, )", + "resolved": "3.0.0", + "contentHash": "udcP8rOhyuhLDn3sGVdNUgQSXfKGPaIP4w09XVKf4xdy66YSXinhkIuQSuOeZVHdTFsG2PpUbRx2wyFm7E0EMg==", "dependencies": { + "DnsClient": "1.6.1", "Microsoft.Extensions.Logging.Abstractions": "2.0.0", - "MongoDB.Bson": "2.30.0", - "MongoDB.Driver.Core": "2.30.0", - "MongoDB.Libmongocrypt": "1.12.0" + "MongoDB.Bson": "3.0.0", + "SharpCompress": "0.30.1", + "Snappier": "1.0.0", + "System.Buffers": "4.5.1", + "ZstdSharp.Port": "0.7.3" } }, "Newtonsoft.Json": { @@ -222,39 +225,39 @@ }, "AWSSDK.Core": { "type": "Transitive", - "resolved": "3.7.400.22", - "contentHash": "v1Pm6lFSkAufm7WtiwE+2laHSj330cVUzTRTXZ50YXNgT0jDu1OryJrTqxPxlbiv6jFEkTutvM9rImuvDSpaeg==" + "resolved": "3.7.400.36", + "contentHash": "K4iJjzwI8VfkjxvLhjpODiZvVk5frjqHJ69rWIxk6xPWglHBLYAN4DhSZO/GpKJpNWjtHB+VlCvgWGZA8JnEHQ==" }, "AWSSDK.S3": { "type": "Transitive", - "resolved": "3.7.403.1", - "contentHash": "5eVV+I7gHNz38WRvY8w2jEoHbQ+wIdOwSzS5MtD/I072vVJs/IL5lgjylgmA0t044JczLV9FmbPrPehKeEhHtQ==", + "resolved": "3.7.405", + "contentHash": "QW5lTOMGnPzjoP/3klZS5/ErTRrYcDz6s/smL0bBmpNSLTXJrp1vDC0AZZxDFxyI3GoLoYcgHfxDdDptzYEqVA==", "dependencies": { - "AWSSDK.Core": "[3.7.400.22, 4.0.0)" + "AWSSDK.Core": "[3.7.400.36, 4.0.0)" } }, "AWSSDK.SecurityToken": { "type": "Transitive", - "resolved": "3.7.400.22", - "contentHash": "R9laqYSFi3DCvVqSATDB1fTG7r1AApl2DLD97Nv3jO+oCd93whK9B/ZO7UVGfOfl+eMDMYC/0Ik+iaJYZy0Q+Q==", + "resolved": "3.7.400.36", + "contentHash": "0mEBp3RixKN/QWRpLimIvpHe97RtbD312G/le9ph0Jx8bEUeVkHbQms66VUnllj+yZwTWfm9ZP7xLJQt7QaydQ==", "dependencies": { - "AWSSDK.Core": "[3.7.400.22, 4.0.0)" + "AWSSDK.Core": "[3.7.400.36, 4.0.0)" } }, "AWSSDK.SSO": { "type": "Transitive", - "resolved": "3.7.400.22", - "contentHash": "YOMWgiief6tMn54GraNnrpUbjgPjM1a+Iq3M7Pf/zQUxkh4A/fIQedqBTJde4xaS/y/GcBf7t/3HZkNA9Xdxbw==", + "resolved": "3.7.400.36", + "contentHash": "8RLgfkYavYSonAC7B4k1qbatZHtSxHnB2ToG59uK1iGzjl4GvHgJTVbP6hFJsmI6d3v4wj3GQdNUtXfULfFpGA==", "dependencies": { - "AWSSDK.Core": "[3.7.400.22, 4.0.0)" + "AWSSDK.Core": "[3.7.400.36, 4.0.0)" } }, "AWSSDK.SSOOIDC": { "type": "Transitive", - "resolved": "3.7.400.22", - "contentHash": "vVRYOTQPsHarmxFTtAnnxVRNLteRVam1Ko/RyPjTdDAAxtxjqRL00DrLsyH5/EXycDVyRIw0Fp2I6EWUm6IhYw==", + "resolved": "3.7.400.36", + "contentHash": "BizxNQKLFaHChC4qzEDwTqVdR0sz6R2gEq3ZqmO5zHI/W/xuJypu3+eJ4qJGFuFnW0v/ngnR75flw9QYcvopjg==", "dependencies": { - "AWSSDK.Core": "[3.7.400.22, 4.0.0)" + "AWSSDK.Core": "[3.7.400.36, 4.0.0)" } }, "Azure.Core": { @@ -614,27 +617,6 @@ "System.Security.Principal.Windows": "5.0.0" } }, - "MongoDB.Driver.Core": { - "type": "Transitive", - "resolved": "2.30.0", - "contentHash": "oepDgu24lo44SljuHmIQ99x6jHISnMC4tLfzQGniQg39xiMD8nxalm1HM9RDZcuZbbWa4F6YLt2AIhWkny3XWA==", - "dependencies": { - "AWSSDK.SecurityToken": "3.7.100.14", - "DnsClient": "1.6.1", - "Microsoft.Extensions.Logging.Abstractions": "2.0.0", - "MongoDB.Bson": "2.30.0", - "MongoDB.Libmongocrypt": "1.12.0", - "SharpCompress": "0.30.1", - "Snappier": "1.0.0", - "System.Buffers": "4.5.1", - "ZstdSharp.Port": "0.7.3" - } - }, - "MongoDB.Libmongocrypt": { - "type": "Transitive", - "resolved": "1.12.0", - "contentHash": "B1X51jrtNacKvxKoaqWeknYeJfQS5aWf6BmVLT5JZerz3AUXFzv8edPskJYqBc3kLy1J2PWzMqqsnyb9g8FtcA==" - }, "MySqlConnector": { "type": "Transitive", "resolved": "2.3.7", @@ -1099,11 +1081,6 @@ "System.Security.Principal.Windows": "5.0.0" } }, - "MongoDB.Libmongocrypt": { - "type": "Transitive", - "resolved": "1.12.0", - "contentHash": "B1X51jrtNacKvxKoaqWeknYeJfQS5aWf6BmVLT5JZerz3AUXFzv8edPskJYqBc3kLy1J2PWzMqqsnyb9g8FtcA==" - }, "runtime.any.System.Collections": { "type": "Transitive", "resolved": "4.3.0", @@ -1605,11 +1582,6 @@ "System.Security.Principal.Windows": "5.0.0" } }, - "MongoDB.Libmongocrypt": { - "type": "Transitive", - "resolved": "1.12.0", - "contentHash": "B1X51jrtNacKvxKoaqWeknYeJfQS5aWf6BmVLT5JZerz3AUXFzv8edPskJYqBc3kLy1J2PWzMqqsnyb9g8FtcA==" - }, "runtime.any.System.Collections": { "type": "Transitive", "resolved": "4.3.0", @@ -2111,11 +2083,6 @@ "System.Security.Principal.Windows": "5.0.0" } }, - "MongoDB.Libmongocrypt": { - "type": "Transitive", - "resolved": "1.12.0", - "contentHash": "B1X51jrtNacKvxKoaqWeknYeJfQS5aWf6BmVLT5JZerz3AUXFzv8edPskJYqBc3kLy1J2PWzMqqsnyb9g8FtcA==" - }, "runtime.any.System.Collections": { "type": "Transitive", "resolved": "4.3.0", diff --git a/tests/SmiServices.IntegrationTests/packages.lock.json b/tests/SmiServices.IntegrationTests/packages.lock.json index 530b893b1..861a183dc 100644 --- a/tests/SmiServices.IntegrationTests/packages.lock.json +++ b/tests/SmiServices.IntegrationTests/packages.lock.json @@ -16,11 +16,11 @@ }, "HIC.RDMP.Plugin.Test": { "type": "Direct", - "requested": "[8.3.0, )", - "resolved": "8.3.0", - "contentHash": "ja3E1a+r0Hlvt0zCLzekhNses+dydzzwRw+kYW99MPIYgEbcwGVweLoiEfAH5CPo79qSCZcyUDnMzWv+9EOrqw==", + "requested": "[8.3.1, )", + "resolved": "8.3.1", + "contentHash": "LD2av0SSAWEUpmZawMwVjqzRxzk2QE/73dmCsXVr5icW4t+Qb+ccF7XnvfGqDbKW47KWU9BTdzzQUd8J/3mIIg==", "dependencies": { - "HIC.RDMP.Plugin": "8.3.0", + "HIC.RDMP.Plugin": "8.3.1", "Microsoft.NET.Test.Sdk": "17.11.1", "NSubstitute": "5.1.0", "NUnit": "4.2.2" @@ -92,39 +92,39 @@ }, "AWSSDK.Core": { "type": "Transitive", - "resolved": "3.7.400.22", - "contentHash": "v1Pm6lFSkAufm7WtiwE+2laHSj330cVUzTRTXZ50YXNgT0jDu1OryJrTqxPxlbiv6jFEkTutvM9rImuvDSpaeg==" + "resolved": "3.7.400.36", + "contentHash": "K4iJjzwI8VfkjxvLhjpODiZvVk5frjqHJ69rWIxk6xPWglHBLYAN4DhSZO/GpKJpNWjtHB+VlCvgWGZA8JnEHQ==" }, "AWSSDK.S3": { "type": "Transitive", - "resolved": "3.7.403.1", - "contentHash": "5eVV+I7gHNz38WRvY8w2jEoHbQ+wIdOwSzS5MtD/I072vVJs/IL5lgjylgmA0t044JczLV9FmbPrPehKeEhHtQ==", + "resolved": "3.7.405", + "contentHash": "QW5lTOMGnPzjoP/3klZS5/ErTRrYcDz6s/smL0bBmpNSLTXJrp1vDC0AZZxDFxyI3GoLoYcgHfxDdDptzYEqVA==", "dependencies": { - "AWSSDK.Core": "[3.7.400.22, 4.0.0)" + "AWSSDK.Core": "[3.7.400.36, 4.0.0)" } }, "AWSSDK.SecurityToken": { "type": "Transitive", - "resolved": "3.7.400.22", - "contentHash": "R9laqYSFi3DCvVqSATDB1fTG7r1AApl2DLD97Nv3jO+oCd93whK9B/ZO7UVGfOfl+eMDMYC/0Ik+iaJYZy0Q+Q==", + "resolved": "3.7.400.36", + "contentHash": "0mEBp3RixKN/QWRpLimIvpHe97RtbD312G/le9ph0Jx8bEUeVkHbQms66VUnllj+yZwTWfm9ZP7xLJQt7QaydQ==", "dependencies": { - "AWSSDK.Core": "[3.7.400.22, 4.0.0)" + "AWSSDK.Core": "[3.7.400.36, 4.0.0)" } }, "AWSSDK.SSO": { "type": "Transitive", - "resolved": "3.7.400.22", - "contentHash": "YOMWgiief6tMn54GraNnrpUbjgPjM1a+Iq3M7Pf/zQUxkh4A/fIQedqBTJde4xaS/y/GcBf7t/3HZkNA9Xdxbw==", + "resolved": "3.7.400.36", + "contentHash": "8RLgfkYavYSonAC7B4k1qbatZHtSxHnB2ToG59uK1iGzjl4GvHgJTVbP6hFJsmI6d3v4wj3GQdNUtXfULfFpGA==", "dependencies": { - "AWSSDK.Core": "[3.7.400.22, 4.0.0)" + "AWSSDK.Core": "[3.7.400.36, 4.0.0)" } }, "AWSSDK.SSOOIDC": { "type": "Transitive", - "resolved": "3.7.400.22", - "contentHash": "vVRYOTQPsHarmxFTtAnnxVRNLteRVam1Ko/RyPjTdDAAxtxjqRL00DrLsyH5/EXycDVyRIw0Fp2I6EWUm6IhYw==", + "resolved": "3.7.400.36", + "contentHash": "BizxNQKLFaHChC4qzEDwTqVdR0sz6R2gEq3ZqmO5zHI/W/xuJypu3+eJ4qJGFuFnW0v/ngnR75flw9QYcvopjg==", "dependencies": { - "AWSSDK.Core": "[3.7.400.22, 4.0.0)" + "AWSSDK.Core": "[3.7.400.36, 4.0.0)" } }, "Azure.Core": { @@ -509,27 +509,6 @@ "System.Security.Principal.Windows": "5.0.0" } }, - "MongoDB.Driver.Core": { - "type": "Transitive", - "resolved": "2.30.0", - "contentHash": "oepDgu24lo44SljuHmIQ99x6jHISnMC4tLfzQGniQg39xiMD8nxalm1HM9RDZcuZbbWa4F6YLt2AIhWkny3XWA==", - "dependencies": { - "AWSSDK.SecurityToken": "3.7.100.14", - "DnsClient": "1.6.1", - "Microsoft.Extensions.Logging.Abstractions": "2.0.0", - "MongoDB.Bson": "2.30.0", - "MongoDB.Libmongocrypt": "1.12.0", - "SharpCompress": "0.30.1", - "Snappier": "1.0.0", - "System.Buffers": "4.5.1", - "ZstdSharp.Port": "0.7.3" - } - }, - "MongoDB.Libmongocrypt": { - "type": "Transitive", - "resolved": "1.12.0", - "contentHash": "B1X51jrtNacKvxKoaqWeknYeJfQS5aWf6BmVLT5JZerz3AUXFzv8edPskJYqBc3kLy1J2PWzMqqsnyb9g8FtcA==" - }, "MySqlConnector": { "type": "Transitive", "resolved": "2.3.7", @@ -949,14 +928,14 @@ "HIC.DicomTypeTranslation": "[4.1.3, )", "HIC.FAnsiSql": "[3.2.7, )", "HIC.RDMP.Dicom": "[7.1.0, )", - "HIC.RDMP.Plugin": "[8.3.0, )", + "HIC.RDMP.Plugin": "[8.3.1, )", "IsIdentifiable": "[0.4.0, )", "LibArchive.Net": "[0.1.5, )", "LineReader": "[0.1.0, )", "Microsoft.CodeAnalysis.CSharp.Scripting": "[4.11.0, )", "Microsoft.Extensions.Caching.Memory": "[8.0.1, )", - "MongoDB.Bson": "[2.30.0, )", - "MongoDB.Driver": "[2.30.0, )", + "MongoDB.Bson": "[3.0.0, )", + "MongoDB.Driver": "[3.0.0, )", "NLog": "[5.3.4, )", "Newtonsoft.Json": "[13.0.3, )", "RabbitMQ.Client": "[6.8.1, )", @@ -969,7 +948,7 @@ "type": "Project", "dependencies": { "HIC.BadMedicine.Dicom": "[0.1.1, )", - "HIC.RDMP.Plugin.Test": "[8.3.0, )", + "HIC.RDMP.Plugin.Test": "[8.3.1, )", "Microsoft.CodeCoverage": "[17.11.1, )", "Microsoft.NET.Test.Sdk": "[17.11.1, )", "Moq": "[4.20.72, )", @@ -1039,21 +1018,21 @@ }, "HIC.RDMP.Plugin": { "type": "CentralTransitive", - "requested": "[8.3.0, )", - "resolved": "8.3.0", - "contentHash": "iKM27C/qJoXECOtdyPmXRTxKvAcEx/EgXsg9D4kMRIZi0V4nlRh8a+PxAHTbfn+0BzfBrmKuEzikF4lyN8tmEQ==", - "dependencies": { - "AWSSDK.S3": "3.7.403.1", - "AWSSDK.SSO": "3.7.400.22", - "AWSSDK.SSOOIDC": "3.7.400.22", - "AWSSDK.SecurityToken": "3.7.400.22", + "requested": "[8.3.1, )", + "resolved": "8.3.1", + "contentHash": "o3iFnwBV+vdiAOq9JpQc7FHtzaUNGgWCBZgFIy2OE7HFGqXFUY/B8MD9FgY4VhJSHBe0T/rlSVmyHT/eqHG5uA==", + "dependencies": { + "AWSSDK.S3": "3.7.405", + "AWSSDK.SSO": "3.7.400.36", + "AWSSDK.SSOOIDC": "3.7.400.36", + "AWSSDK.SecurityToken": "3.7.400.36", "CommandLineParser": "2.9.1", "ExcelNumberFormat": "1.1.0", "FluentFTP": "51.1.0", - "HIC.FAnsiSql": "3.2.6", + "HIC.FAnsiSql": "3.2.7", "HIC.SynthEHR": "2.0.1", "LibArchive.Net": "0.1.5", - "MongoDB.Driver": "2.29.0", + "MongoDB.Driver": "3.0.0", "NLog": "5.3.4", "NPOI": "2.7.1", "Newtonsoft.Json": "13.0.3", @@ -1063,7 +1042,7 @@ "Spectre.Console": "0.49.1", "System.Resources.Extensions": "8.0.0", "Terminal.Gui": "1.17.1", - "YamlDotNet": "16.1.2" + "YamlDotNet": "16.1.3" } }, "IsIdentifiable": { @@ -1130,9 +1109,9 @@ }, "MongoDB.Bson": { "type": "CentralTransitive", - "requested": "[2.30.0, )", - "resolved": "2.30.0", - "contentHash": "Gg0TQUT3IEntcqdug5a9P6d8iwL5CqOpQjVBCq1hxTbkjxdGdY6a2CPv7II44AO9GYUnORYsS6dDME2b7aqYyg==", + "requested": "[3.0.0, )", + "resolved": "3.0.0", + "contentHash": "qnPRJ58HXDh7C4oxTf6YB7BJhlCGJIa6TMXhzImw6zk44lrAomQXTB6AtoQ5lNJbkyrgQcT7+smsKFMnXmLXhw==", "dependencies": { "System.Memory": "4.5.5", "System.Runtime.CompilerServices.Unsafe": "5.0.0" @@ -1140,14 +1119,17 @@ }, "MongoDB.Driver": { "type": "CentralTransitive", - "requested": "[2.30.0, )", - "resolved": "2.30.0", - "contentHash": "BCG8cNF0+U3h5f/O9fu3ktrYhoESBDems1w06PExfYrn2KjHBHCBdvBRY1cIbysnZVjQAJjGtFV9XgW+hXt7Hg==", + "requested": "[3.0.0, )", + "resolved": "3.0.0", + "contentHash": "udcP8rOhyuhLDn3sGVdNUgQSXfKGPaIP4w09XVKf4xdy66YSXinhkIuQSuOeZVHdTFsG2PpUbRx2wyFm7E0EMg==", "dependencies": { + "DnsClient": "1.6.1", "Microsoft.Extensions.Logging.Abstractions": "2.0.0", - "MongoDB.Bson": "2.30.0", - "MongoDB.Driver.Core": "2.30.0", - "MongoDB.Libmongocrypt": "1.12.0" + "MongoDB.Bson": "3.0.0", + "SharpCompress": "0.30.1", + "Snappier": "1.0.0", + "System.Buffers": "4.5.1", + "ZstdSharp.Port": "0.7.3" } }, "Newtonsoft.Json": { @@ -1263,11 +1245,6 @@ "System.Security.Principal.Windows": "5.0.0" } }, - "MongoDB.Libmongocrypt": { - "type": "Transitive", - "resolved": "1.12.0", - "contentHash": "B1X51jrtNacKvxKoaqWeknYeJfQS5aWf6BmVLT5JZerz3AUXFzv8edPskJYqBc3kLy1J2PWzMqqsnyb9g8FtcA==" - }, "runtime.any.System.Collections": { "type": "Transitive", "resolved": "4.3.0", @@ -1769,11 +1746,6 @@ "System.Security.Principal.Windows": "5.0.0" } }, - "MongoDB.Libmongocrypt": { - "type": "Transitive", - "resolved": "1.12.0", - "contentHash": "B1X51jrtNacKvxKoaqWeknYeJfQS5aWf6BmVLT5JZerz3AUXFzv8edPskJYqBc3kLy1J2PWzMqqsnyb9g8FtcA==" - }, "runtime.any.System.Collections": { "type": "Transitive", "resolved": "4.3.0", @@ -2275,11 +2247,6 @@ "System.Security.Principal.Windows": "5.0.0" } }, - "MongoDB.Libmongocrypt": { - "type": "Transitive", - "resolved": "1.12.0", - "contentHash": "B1X51jrtNacKvxKoaqWeknYeJfQS5aWf6BmVLT5JZerz3AUXFzv8edPskJYqBc3kLy1J2PWzMqqsnyb9g8FtcA==" - }, "runtime.any.System.Collections": { "type": "Transitive", "resolved": "4.3.0", diff --git a/tests/SmiServices.UnitTests/Common/MongoDB/StubMongoClient.cs b/tests/SmiServices.UnitTests/Common/MongoDB/StubMongoClient.cs index cf213dc2f..c810ae2d8 100644 --- a/tests/SmiServices.UnitTests/Common/MongoDB/StubMongoClient.cs +++ b/tests/SmiServices.UnitTests/Common/MongoDB/StubMongoClient.cs @@ -2,9 +2,12 @@ using MongoDB.Driver; using MongoDB.Driver.Core.Clusters; using System; +using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; +// JS 2024-11-05: Disable nullable for this stub to match upstream interface declaration +#nullable disable namespace SmiServices.UnitTests.Common.MongoDB { @@ -15,11 +18,28 @@ public abstract class StubMongoClient : IMongoClient { public ICluster Cluster { get; } = null!; public MongoClientSettings Settings { get; } = null!; + + public ClientBulkWriteResult BulkWrite(IReadOnlyList models, ClientBulkWriteOptions options = null, + CancellationToken cancellationToken = new CancellationToken()) => + throw new NotImplementedException(); + + public ClientBulkWriteResult BulkWrite(IClientSessionHandle session, IReadOnlyList models, + ClientBulkWriteOptions options = null, CancellationToken cancellationToken = new CancellationToken()) => + throw new NotImplementedException(); + + public Task BulkWriteAsync(IReadOnlyList models, ClientBulkWriteOptions options = null, + CancellationToken cancellationToken = new CancellationToken()) => + throw new NotImplementedException(); + + public Task BulkWriteAsync(IClientSessionHandle session, IReadOnlyList models, ClientBulkWriteOptions options = null, + CancellationToken cancellationToken = new CancellationToken()) => + throw new NotImplementedException(); + public virtual void DropDatabase(string name, CancellationToken cancellationToken = new CancellationToken()) => throw new NotImplementedException(); public virtual void DropDatabase(IClientSessionHandle session, string name, CancellationToken cancellationToken = new CancellationToken()) => throw new NotImplementedException(); public virtual Task DropDatabaseAsync(string name, CancellationToken cancellationToken = new CancellationToken()) => throw new NotImplementedException(); public virtual Task DropDatabaseAsync(IClientSessionHandle session, string name, CancellationToken cancellationToken = new CancellationToken()) => throw new NotImplementedException(); - public virtual IMongoDatabase GetDatabase(string name, MongoDatabaseSettings? settings = null) => throw new NotImplementedException(); + public virtual IMongoDatabase GetDatabase(string name, MongoDatabaseSettings settings = null) => throw new NotImplementedException(); public virtual IAsyncCursor ListDatabaseNames(CancellationToken cancellationToken = new CancellationToken()) => throw new NotImplementedException(); public virtual IAsyncCursor ListDatabaseNames(IClientSessionHandle session, CancellationToken cancellationToken = new CancellationToken()) => throw new NotImplementedException(); public IAsyncCursor ListDatabaseNames(ListDatabaseNamesOptions options, CancellationToken cancellationToken = default) => throw new NotImplementedException(); @@ -36,14 +56,19 @@ public abstract class StubMongoClient : IMongoClient public virtual Task> ListDatabasesAsync(ListDatabasesOptions options, CancellationToken cancellationToken = new CancellationToken()) => throw new NotImplementedException(); public virtual Task> ListDatabasesAsync(IClientSessionHandle session, CancellationToken cancellationToken = new CancellationToken()) => throw new NotImplementedException(); public virtual Task> ListDatabasesAsync(IClientSessionHandle session, ListDatabasesOptions options, CancellationToken cancellationToken = new CancellationToken()) => throw new NotImplementedException(); - public virtual IClientSessionHandle StartSession(ClientSessionOptions? options = null, CancellationToken cancellationToken = new CancellationToken()) => throw new NotImplementedException(); - public virtual Task StartSessionAsync(ClientSessionOptions? options = null, CancellationToken cancellationToken = new CancellationToken()) => throw new NotImplementedException(); - public virtual IChangeStreamCursor Watch(PipelineDefinition, TResult> pipeline, ChangeStreamOptions? options = null, CancellationToken cancellationToken = new CancellationToken()) => throw new NotImplementedException(); - public virtual IChangeStreamCursor Watch(IClientSessionHandle session, PipelineDefinition, TResult> pipeline, ChangeStreamOptions? options = null, CancellationToken cancellationToken = new CancellationToken()) => throw new NotImplementedException(); - public virtual Task> WatchAsync(PipelineDefinition, TResult> pipeline, ChangeStreamOptions? options = null, CancellationToken cancellationToken = new CancellationToken()) => throw new NotImplementedException(); - public virtual Task> WatchAsync(IClientSessionHandle session, PipelineDefinition, TResult> pipeline, ChangeStreamOptions? options = null, CancellationToken cancellationToken = new CancellationToken()) => throw new NotImplementedException(); + public virtual IClientSessionHandle StartSession(ClientSessionOptions options = null, CancellationToken cancellationToken = new CancellationToken()) => throw new NotImplementedException(); + public virtual Task StartSessionAsync(ClientSessionOptions options = null, CancellationToken cancellationToken = new CancellationToken()) => throw new NotImplementedException(); + public virtual IChangeStreamCursor Watch(PipelineDefinition, TResult> pipeline, ChangeStreamOptions options = null, CancellationToken cancellationToken = new CancellationToken()) => throw new NotImplementedException(); + public virtual IChangeStreamCursor Watch(IClientSessionHandle session, PipelineDefinition, TResult> pipeline, ChangeStreamOptions options = null, CancellationToken cancellationToken = new CancellationToken()) => throw new NotImplementedException(); + public virtual Task> WatchAsync(PipelineDefinition, TResult> pipeline, ChangeStreamOptions options = null, CancellationToken cancellationToken = new CancellationToken()) => throw new NotImplementedException(); + public virtual Task> WatchAsync(IClientSessionHandle session, PipelineDefinition, TResult> pipeline, ChangeStreamOptions options = null, CancellationToken cancellationToken = new CancellationToken()) => throw new NotImplementedException(); public virtual IMongoClient WithReadConcern(ReadConcern readConcern) => throw new NotImplementedException(); public virtual IMongoClient WithReadPreference(ReadPreference readPreference) => throw new NotImplementedException(); public virtual IMongoClient WithWriteConcern(WriteConcern writeConcern) => throw new NotImplementedException(); + + public void Dispose() + { + GC.SuppressFinalize(this); + } } } diff --git a/tests/SmiServices.UnitTests/packages.lock.json b/tests/SmiServices.UnitTests/packages.lock.json index 79960c2cd..e5c00770e 100644 --- a/tests/SmiServices.UnitTests/packages.lock.json +++ b/tests/SmiServices.UnitTests/packages.lock.json @@ -16,11 +16,11 @@ }, "HIC.RDMP.Plugin.Test": { "type": "Direct", - "requested": "[8.3.0, )", - "resolved": "8.3.0", - "contentHash": "ja3E1a+r0Hlvt0zCLzekhNses+dydzzwRw+kYW99MPIYgEbcwGVweLoiEfAH5CPo79qSCZcyUDnMzWv+9EOrqw==", + "requested": "[8.3.1, )", + "resolved": "8.3.1", + "contentHash": "LD2av0SSAWEUpmZawMwVjqzRxzk2QE/73dmCsXVr5icW4t+Qb+ccF7XnvfGqDbKW47KWU9BTdzzQUd8J/3mIIg==", "dependencies": { - "HIC.RDMP.Plugin": "8.3.0", + "HIC.RDMP.Plugin": "8.3.1", "Microsoft.NET.Test.Sdk": "17.11.1", "NSubstitute": "5.1.0", "NUnit": "4.2.2" @@ -92,39 +92,39 @@ }, "AWSSDK.Core": { "type": "Transitive", - "resolved": "3.7.400.22", - "contentHash": "v1Pm6lFSkAufm7WtiwE+2laHSj330cVUzTRTXZ50YXNgT0jDu1OryJrTqxPxlbiv6jFEkTutvM9rImuvDSpaeg==" + "resolved": "3.7.400.36", + "contentHash": "K4iJjzwI8VfkjxvLhjpODiZvVk5frjqHJ69rWIxk6xPWglHBLYAN4DhSZO/GpKJpNWjtHB+VlCvgWGZA8JnEHQ==" }, "AWSSDK.S3": { "type": "Transitive", - "resolved": "3.7.403.1", - "contentHash": "5eVV+I7gHNz38WRvY8w2jEoHbQ+wIdOwSzS5MtD/I072vVJs/IL5lgjylgmA0t044JczLV9FmbPrPehKeEhHtQ==", + "resolved": "3.7.405", + "contentHash": "QW5lTOMGnPzjoP/3klZS5/ErTRrYcDz6s/smL0bBmpNSLTXJrp1vDC0AZZxDFxyI3GoLoYcgHfxDdDptzYEqVA==", "dependencies": { - "AWSSDK.Core": "[3.7.400.22, 4.0.0)" + "AWSSDK.Core": "[3.7.400.36, 4.0.0)" } }, "AWSSDK.SecurityToken": { "type": "Transitive", - "resolved": "3.7.400.22", - "contentHash": "R9laqYSFi3DCvVqSATDB1fTG7r1AApl2DLD97Nv3jO+oCd93whK9B/ZO7UVGfOfl+eMDMYC/0Ik+iaJYZy0Q+Q==", + "resolved": "3.7.400.36", + "contentHash": "0mEBp3RixKN/QWRpLimIvpHe97RtbD312G/le9ph0Jx8bEUeVkHbQms66VUnllj+yZwTWfm9ZP7xLJQt7QaydQ==", "dependencies": { - "AWSSDK.Core": "[3.7.400.22, 4.0.0)" + "AWSSDK.Core": "[3.7.400.36, 4.0.0)" } }, "AWSSDK.SSO": { "type": "Transitive", - "resolved": "3.7.400.22", - "contentHash": "YOMWgiief6tMn54GraNnrpUbjgPjM1a+Iq3M7Pf/zQUxkh4A/fIQedqBTJde4xaS/y/GcBf7t/3HZkNA9Xdxbw==", + "resolved": "3.7.400.36", + "contentHash": "8RLgfkYavYSonAC7B4k1qbatZHtSxHnB2ToG59uK1iGzjl4GvHgJTVbP6hFJsmI6d3v4wj3GQdNUtXfULfFpGA==", "dependencies": { - "AWSSDK.Core": "[3.7.400.22, 4.0.0)" + "AWSSDK.Core": "[3.7.400.36, 4.0.0)" } }, "AWSSDK.SSOOIDC": { "type": "Transitive", - "resolved": "3.7.400.22", - "contentHash": "vVRYOTQPsHarmxFTtAnnxVRNLteRVam1Ko/RyPjTdDAAxtxjqRL00DrLsyH5/EXycDVyRIw0Fp2I6EWUm6IhYw==", + "resolved": "3.7.400.36", + "contentHash": "BizxNQKLFaHChC4qzEDwTqVdR0sz6R2gEq3ZqmO5zHI/W/xuJypu3+eJ4qJGFuFnW0v/ngnR75flw9QYcvopjg==", "dependencies": { - "AWSSDK.Core": "[3.7.400.22, 4.0.0)" + "AWSSDK.Core": "[3.7.400.36, 4.0.0)" } }, "Azure.Core": { @@ -509,27 +509,6 @@ "System.Security.Principal.Windows": "5.0.0" } }, - "MongoDB.Driver.Core": { - "type": "Transitive", - "resolved": "2.30.0", - "contentHash": "oepDgu24lo44SljuHmIQ99x6jHISnMC4tLfzQGniQg39xiMD8nxalm1HM9RDZcuZbbWa4F6YLt2AIhWkny3XWA==", - "dependencies": { - "AWSSDK.SecurityToken": "3.7.100.14", - "DnsClient": "1.6.1", - "Microsoft.Extensions.Logging.Abstractions": "2.0.0", - "MongoDB.Bson": "2.30.0", - "MongoDB.Libmongocrypt": "1.12.0", - "SharpCompress": "0.30.1", - "Snappier": "1.0.0", - "System.Buffers": "4.5.1", - "ZstdSharp.Port": "0.7.3" - } - }, - "MongoDB.Libmongocrypt": { - "type": "Transitive", - "resolved": "1.12.0", - "contentHash": "B1X51jrtNacKvxKoaqWeknYeJfQS5aWf6BmVLT5JZerz3AUXFzv8edPskJYqBc3kLy1J2PWzMqqsnyb9g8FtcA==" - }, "MySqlConnector": { "type": "Transitive", "resolved": "2.3.7", @@ -949,14 +928,14 @@ "HIC.DicomTypeTranslation": "[4.1.3, )", "HIC.FAnsiSql": "[3.2.7, )", "HIC.RDMP.Dicom": "[7.1.0, )", - "HIC.RDMP.Plugin": "[8.3.0, )", + "HIC.RDMP.Plugin": "[8.3.1, )", "IsIdentifiable": "[0.4.0, )", "LibArchive.Net": "[0.1.5, )", "LineReader": "[0.1.0, )", "Microsoft.CodeAnalysis.CSharp.Scripting": "[4.11.0, )", "Microsoft.Extensions.Caching.Memory": "[8.0.1, )", - "MongoDB.Bson": "[2.30.0, )", - "MongoDB.Driver": "[2.30.0, )", + "MongoDB.Bson": "[3.0.0, )", + "MongoDB.Driver": "[3.0.0, )", "NLog": "[5.3.4, )", "Newtonsoft.Json": "[13.0.3, )", "RabbitMQ.Client": "[6.8.1, )", @@ -1024,21 +1003,21 @@ }, "HIC.RDMP.Plugin": { "type": "CentralTransitive", - "requested": "[8.3.0, )", - "resolved": "8.3.0", - "contentHash": "iKM27C/qJoXECOtdyPmXRTxKvAcEx/EgXsg9D4kMRIZi0V4nlRh8a+PxAHTbfn+0BzfBrmKuEzikF4lyN8tmEQ==", - "dependencies": { - "AWSSDK.S3": "3.7.403.1", - "AWSSDK.SSO": "3.7.400.22", - "AWSSDK.SSOOIDC": "3.7.400.22", - "AWSSDK.SecurityToken": "3.7.400.22", + "requested": "[8.3.1, )", + "resolved": "8.3.1", + "contentHash": "o3iFnwBV+vdiAOq9JpQc7FHtzaUNGgWCBZgFIy2OE7HFGqXFUY/B8MD9FgY4VhJSHBe0T/rlSVmyHT/eqHG5uA==", + "dependencies": { + "AWSSDK.S3": "3.7.405", + "AWSSDK.SSO": "3.7.400.36", + "AWSSDK.SSOOIDC": "3.7.400.36", + "AWSSDK.SecurityToken": "3.7.400.36", "CommandLineParser": "2.9.1", "ExcelNumberFormat": "1.1.0", "FluentFTP": "51.1.0", - "HIC.FAnsiSql": "3.2.6", + "HIC.FAnsiSql": "3.2.7", "HIC.SynthEHR": "2.0.1", "LibArchive.Net": "0.1.5", - "MongoDB.Driver": "2.29.0", + "MongoDB.Driver": "3.0.0", "NLog": "5.3.4", "NPOI": "2.7.1", "Newtonsoft.Json": "13.0.3", @@ -1048,7 +1027,7 @@ "Spectre.Console": "0.49.1", "System.Resources.Extensions": "8.0.0", "Terminal.Gui": "1.17.1", - "YamlDotNet": "16.1.2" + "YamlDotNet": "16.1.3" } }, "IsIdentifiable": { @@ -1115,9 +1094,9 @@ }, "MongoDB.Bson": { "type": "CentralTransitive", - "requested": "[2.30.0, )", - "resolved": "2.30.0", - "contentHash": "Gg0TQUT3IEntcqdug5a9P6d8iwL5CqOpQjVBCq1hxTbkjxdGdY6a2CPv7II44AO9GYUnORYsS6dDME2b7aqYyg==", + "requested": "[3.0.0, )", + "resolved": "3.0.0", + "contentHash": "qnPRJ58HXDh7C4oxTf6YB7BJhlCGJIa6TMXhzImw6zk44lrAomQXTB6AtoQ5lNJbkyrgQcT7+smsKFMnXmLXhw==", "dependencies": { "System.Memory": "4.5.5", "System.Runtime.CompilerServices.Unsafe": "5.0.0" @@ -1125,14 +1104,17 @@ }, "MongoDB.Driver": { "type": "CentralTransitive", - "requested": "[2.30.0, )", - "resolved": "2.30.0", - "contentHash": "BCG8cNF0+U3h5f/O9fu3ktrYhoESBDems1w06PExfYrn2KjHBHCBdvBRY1cIbysnZVjQAJjGtFV9XgW+hXt7Hg==", + "requested": "[3.0.0, )", + "resolved": "3.0.0", + "contentHash": "udcP8rOhyuhLDn3sGVdNUgQSXfKGPaIP4w09XVKf4xdy66YSXinhkIuQSuOeZVHdTFsG2PpUbRx2wyFm7E0EMg==", "dependencies": { + "DnsClient": "1.6.1", "Microsoft.Extensions.Logging.Abstractions": "2.0.0", - "MongoDB.Bson": "2.30.0", - "MongoDB.Driver.Core": "2.30.0", - "MongoDB.Libmongocrypt": "1.12.0" + "MongoDB.Bson": "3.0.0", + "SharpCompress": "0.30.1", + "Snappier": "1.0.0", + "System.Buffers": "4.5.1", + "ZstdSharp.Port": "0.7.3" } }, "Newtonsoft.Json": { @@ -1248,11 +1230,6 @@ "System.Security.Principal.Windows": "5.0.0" } }, - "MongoDB.Libmongocrypt": { - "type": "Transitive", - "resolved": "1.12.0", - "contentHash": "B1X51jrtNacKvxKoaqWeknYeJfQS5aWf6BmVLT5JZerz3AUXFzv8edPskJYqBc3kLy1J2PWzMqqsnyb9g8FtcA==" - }, "runtime.any.System.Collections": { "type": "Transitive", "resolved": "4.3.0", @@ -1754,11 +1731,6 @@ "System.Security.Principal.Windows": "5.0.0" } }, - "MongoDB.Libmongocrypt": { - "type": "Transitive", - "resolved": "1.12.0", - "contentHash": "B1X51jrtNacKvxKoaqWeknYeJfQS5aWf6BmVLT5JZerz3AUXFzv8edPskJYqBc3kLy1J2PWzMqqsnyb9g8FtcA==" - }, "runtime.any.System.Collections": { "type": "Transitive", "resolved": "4.3.0", @@ -2260,11 +2232,6 @@ "System.Security.Principal.Windows": "5.0.0" } }, - "MongoDB.Libmongocrypt": { - "type": "Transitive", - "resolved": "1.12.0", - "contentHash": "B1X51jrtNacKvxKoaqWeknYeJfQS5aWf6BmVLT5JZerz3AUXFzv8edPskJYqBc3kLy1J2PWzMqqsnyb9g8FtcA==" - }, "runtime.any.System.Collections": { "type": "Transitive", "resolved": "4.3.0",