mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-01-14 01:25:40 -05:00
Add IncludePassword parameter to Get Connection String request (#670)
* Add IncludePassword flag to get connection string method * Override connection application name * Fix typo * Fix test break * Use ****** as password placeholder
This commit is contained in:
@@ -28,8 +28,9 @@ namespace Microsoft.SqlTools.ServiceLayer.Connection
|
||||
/// Main class for the Connection Management services
|
||||
/// </summary>
|
||||
public class ConnectionService
|
||||
{
|
||||
{
|
||||
public const string AdminConnectionPrefix = "ADMIN:";
|
||||
internal const string PasswordPlaceholder = "******";
|
||||
private const string SqlAzureEdition = "SQL Azure";
|
||||
|
||||
/// <summary>
|
||||
@@ -1268,6 +1269,13 @@ namespace Microsoft.SqlTools.ServiceLayer.Connection
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!connStringParams.IncludePassword)
|
||||
{
|
||||
info.ConnectionDetails.Password = ConnectionService.PasswordPlaceholder;
|
||||
}
|
||||
|
||||
info.ConnectionDetails.ApplicationName = "sqlops-connection-string";
|
||||
|
||||
connectionString = BuildConnectionString(info.ConnectionDetails);
|
||||
}
|
||||
catch (Exception e)
|
||||
|
||||
@@ -14,5 +14,10 @@ namespace Microsoft.SqlTools.ServiceLayer.Connection.Contracts
|
||||
/// URI of the owner of the connection
|
||||
/// </summary>
|
||||
public string OwnerUri { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether the password should be return in the connection string
|
||||
/// </summary>
|
||||
public bool IncludePassword { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
//
|
||||
using System.Data;
|
||||
using System.Data.Common;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.SqlTools.ServiceLayer.Connection;
|
||||
using Microsoft.SqlTools.ServiceLayer.Connection.Contracts;
|
||||
using Microsoft.SqlTools.ServiceLayer.IntegrationTests.Utility;
|
||||
@@ -115,9 +116,14 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Connection
|
||||
ConnectionService service = ConnectionService.Instance;
|
||||
var result = LiveConnectionHelper.InitLiveConnectionInfo();
|
||||
var requestContext = new Mock<SqlTools.Hosting.Protocol.RequestContext<string>>();
|
||||
|
||||
requestContext.Setup(x => x.SendResult(It.Is<string>((connectionString) => connectionString.Contains("Password=" + ConnectionService.PasswordPlaceholder))))
|
||||
.Returns(Task.FromResult(new object()));
|
||||
|
||||
var requestParams = new GetConnectionStringParams()
|
||||
{
|
||||
OwnerUri = result.ConnectionInfo.OwnerUri
|
||||
OwnerUri = result.ConnectionInfo.OwnerUri,
|
||||
IncludePassword = false
|
||||
};
|
||||
|
||||
await service.HandleGetConnectionStringRequest(requestParams, requestContext.Object);
|
||||
|
||||
Reference in New Issue
Block a user