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:
Udeesha Gautam
2020-08-09 19:17:16 -07:00
committed by GitHub
parent 81b4bb7753
commit 616a79c83d
3 changed files with 21 additions and 9 deletions

View File

@@ -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();
}
}
}