mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-01-13 17:23:02 -05:00
GetConnectionString API fix to not change the cache only return the value (#1040)
* Get connection string call was changing the connection info (ref object) received from cache. Changing it to just get and make changes to only the returned string.. * Change to ensure PR validation works
This commit is contained in:
@@ -99,7 +99,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Connection
|
||||
// All open DbConnections (Query and Default) should have newDatabaseName as their database
|
||||
foreach (DbConnection connection in connectionInfo.AllConnections)
|
||||
{
|
||||
if (connection != null && connection.State == ConnectionState.Open)
|
||||
if (connection != null && connection.State == ConnectionState.Open)
|
||||
{
|
||||
Assert.AreEqual(connection.Database, newDatabaseName);
|
||||
}
|
||||
@@ -115,6 +115,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Connection
|
||||
// If we make a connection to a live database
|
||||
ConnectionService service = ConnectionService.Instance;
|
||||
var result = LiveConnectionHelper.InitLiveConnectionInfo();
|
||||
var resultPassword = result.ConnectionInfo.ConnectionDetails.Password;
|
||||
var requestContext = new Mock<SqlTools.Hosting.Protocol.RequestContext<string>>();
|
||||
|
||||
requestContext.Setup(x => x.SendResult(It.Is<string>((connectionString) => connectionString.Contains("Password=" + ConnectionService.PasswordPlaceholder))))
|
||||
@@ -128,6 +129,15 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Connection
|
||||
|
||||
await service.HandleGetConnectionStringRequest(requestParams, requestContext.Object);
|
||||
requestContext.VerifyAll();
|
||||
|
||||
// validate that the get command doesn't change any connection property and the following get commands work as expected
|
||||
requestParams.IncludePassword = true;
|
||||
|
||||
requestContext.Setup(x => x.SendResult(It.Is<string>((connectionString) => connectionString.Contains("Password=" + resultPassword))))
|
||||
.Returns(Task.FromResult(new object()));
|
||||
|
||||
await service.HandleGetConnectionStringRequest(requestParams, requestContext.Object);
|
||||
requestContext.VerifyAll();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user