mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-02-16 10:58:30 -05:00
Merge branch 'dev' of github.com:Microsoft/sqltoolsservice into dev
This commit is contained in:
@@ -143,7 +143,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Connection
|
|||||||
}
|
}
|
||||||
catch(Exception ex)
|
catch(Exception ex)
|
||||||
{
|
{
|
||||||
response.Messages = ex.Message;
|
response.Messages = ex.ToString();
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -241,7 +241,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Connection
|
|||||||
}
|
}
|
||||||
catch(Exception ex)
|
catch(Exception ex)
|
||||||
{
|
{
|
||||||
await requestContext.SendError(ex.Message);
|
await requestContext.SendError(ex.ToString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -261,7 +261,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Connection
|
|||||||
}
|
}
|
||||||
catch(Exception ex)
|
catch(Exception ex)
|
||||||
{
|
{
|
||||||
await requestContext.SendError(ex.Message);
|
await requestContext.SendError(ex.ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -285,7 +285,10 @@ namespace Microsoft.SqlTools.ServiceLayer.Connection
|
|||||||
connectionBuilder["Integrated Security"] = false;
|
connectionBuilder["Integrated Security"] = false;
|
||||||
connectionBuilder["User Id"] = connectionDetails.UserName;
|
connectionBuilder["User Id"] = connectionDetails.UserName;
|
||||||
connectionBuilder["Password"] = connectionDetails.Password;
|
connectionBuilder["Password"] = connectionDetails.Password;
|
||||||
connectionBuilder["Initial Catalog"] = connectionDetails.DatabaseName;
|
if( !String.IsNullOrEmpty(connectionDetails.DatabaseName) )
|
||||||
|
{
|
||||||
|
connectionBuilder["Initial Catalog"] = connectionDetails.DatabaseName;
|
||||||
|
}
|
||||||
return connectionBuilder.ToString();
|
return connectionBuilder.ToString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,7 +20,6 @@ namespace Microsoft.SqlTools.ServiceLayer.Connection.Contracts
|
|||||||
return !(
|
return !(
|
||||||
String.IsNullOrEmpty(parameters.OwnerUri) ||
|
String.IsNullOrEmpty(parameters.OwnerUri) ||
|
||||||
parameters.Connection == null ||
|
parameters.Connection == null ||
|
||||||
String.IsNullOrEmpty(parameters.Connection.DatabaseName) ||
|
|
||||||
String.IsNullOrEmpty(parameters.Connection.Password) ||
|
String.IsNullOrEmpty(parameters.Connection.Password) ||
|
||||||
String.IsNullOrEmpty(parameters.Connection.ServerName) ||
|
String.IsNullOrEmpty(parameters.Connection.ServerName) ||
|
||||||
String.IsNullOrEmpty(parameters.Connection.UserName)
|
String.IsNullOrEmpty(parameters.Connection.UserName)
|
||||||
|
|||||||
@@ -0,0 +1,20 @@
|
|||||||
|
//
|
||||||
|
// Copyright (c) Microsoft. All rights reserved.
|
||||||
|
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||||
|
//
|
||||||
|
|
||||||
|
using Microsoft.SqlTools.ServiceLayer.Hosting.Protocol.Contracts;
|
||||||
|
|
||||||
|
namespace Microsoft.SqlTools.ServiceLayer.Hosting.Contracts
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Defines a message that is sent from the client to request
|
||||||
|
/// the version of the server.
|
||||||
|
/// </summary>
|
||||||
|
public class VersionRequest
|
||||||
|
{
|
||||||
|
public static readonly
|
||||||
|
RequestType<object, string> Type =
|
||||||
|
RequestType<object, string>.Create("version");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -11,6 +11,7 @@ using Microsoft.SqlTools.EditorServices.Utility;
|
|||||||
using Microsoft.SqlTools.ServiceLayer.Hosting.Contracts;
|
using Microsoft.SqlTools.ServiceLayer.Hosting.Contracts;
|
||||||
using Microsoft.SqlTools.ServiceLayer.Hosting.Protocol;
|
using Microsoft.SqlTools.ServiceLayer.Hosting.Protocol;
|
||||||
using Microsoft.SqlTools.ServiceLayer.Hosting.Protocol.Channel;
|
using Microsoft.SqlTools.ServiceLayer.Hosting.Protocol.Channel;
|
||||||
|
using System.Reflection;
|
||||||
|
|
||||||
namespace Microsoft.SqlTools.ServiceLayer.Hosting
|
namespace Microsoft.SqlTools.ServiceLayer.Hosting
|
||||||
{
|
{
|
||||||
@@ -55,6 +56,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Hosting
|
|||||||
// Register the requests that this service host will handle
|
// Register the requests that this service host will handle
|
||||||
this.SetRequestHandler(InitializeRequest.Type, this.HandleInitializeRequest);
|
this.SetRequestHandler(InitializeRequest.Type, this.HandleInitializeRequest);
|
||||||
this.SetRequestHandler(ShutdownRequest.Type, this.HandleShutdownRequest);
|
this.SetRequestHandler(ShutdownRequest.Type, this.HandleShutdownRequest);
|
||||||
|
this.SetRequestHandler(VersionRequest.Type, HandleVersionRequest);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
@@ -69,6 +71,8 @@ namespace Microsoft.SqlTools.ServiceLayer.Hosting
|
|||||||
|
|
||||||
private readonly List<InitializeCallback> initializeCallbacks;
|
private readonly List<InitializeCallback> initializeCallbacks;
|
||||||
|
|
||||||
|
private static readonly Version serviceVersion = Assembly.GetEntryAssembly().GetName().Version;
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Public Methods
|
#region Public Methods
|
||||||
@@ -149,6 +153,17 @@ namespace Microsoft.SqlTools.ServiceLayer.Hosting
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Handles the version request. Sends back the server version as result.
|
||||||
|
/// </summary>
|
||||||
|
private static async Task HandleVersionRequest(
|
||||||
|
object versionRequestParams,
|
||||||
|
RequestContext<string> requestContext)
|
||||||
|
{
|
||||||
|
Logger.Write(LogLevel.Verbose, "HandleVersionRequest");
|
||||||
|
await requestContext.SendResult(serviceVersion.ToString());
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,6 +19,30 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.Connection
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class ConnectionServiceTests
|
public class ConnectionServiceTests
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Verify that we can connect to the default database when no database name is
|
||||||
|
/// provided as a parameter.
|
||||||
|
/// </summary>
|
||||||
|
[Theory]
|
||||||
|
[InlineDataAttribute(null)]
|
||||||
|
[InlineDataAttribute("")]
|
||||||
|
public void CanConnectWithEmptyDatabaseName(string databaseName)
|
||||||
|
{
|
||||||
|
// Connect
|
||||||
|
var connectionDetails = TestObjects.GetTestConnectionDetails();
|
||||||
|
connectionDetails.DatabaseName = databaseName;
|
||||||
|
var connectionResult =
|
||||||
|
TestObjects.GetTestConnectionService()
|
||||||
|
.Connect(new ConnectParams()
|
||||||
|
{
|
||||||
|
OwnerUri = "file:///my/test/file.sql",
|
||||||
|
Connection = connectionDetails
|
||||||
|
});
|
||||||
|
|
||||||
|
// check that a connection was created
|
||||||
|
Assert.NotEmpty(connectionResult.ConnectionId);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Verify that when a connection is started for a URI with an already existing
|
/// Verify that when a connection is started for a URI with an already existing
|
||||||
/// connection, we disconnect first before connecting.
|
/// connection, we disconnect first before connecting.
|
||||||
@@ -99,12 +123,10 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.Connection
|
|||||||
[Theory]
|
[Theory]
|
||||||
[InlineDataAttribute(null, "my-server", "test", "sa", "123456")]
|
[InlineDataAttribute(null, "my-server", "test", "sa", "123456")]
|
||||||
[InlineDataAttribute("file://my/sample/file.sql", null, "test", "sa", "123456")]
|
[InlineDataAttribute("file://my/sample/file.sql", null, "test", "sa", "123456")]
|
||||||
[InlineDataAttribute("file://my/sample/file.sql", "my-server", null, "sa", "123456")]
|
|
||||||
[InlineDataAttribute("file://my/sample/file.sql", "my-server", "test", null, "123456")]
|
[InlineDataAttribute("file://my/sample/file.sql", "my-server", "test", null, "123456")]
|
||||||
[InlineDataAttribute("file://my/sample/file.sql", "my-server", "test", "sa", null)]
|
[InlineDataAttribute("file://my/sample/file.sql", "my-server", "test", "sa", null)]
|
||||||
[InlineDataAttribute("", "my-server", "test", "sa", "123456")]
|
[InlineDataAttribute("", "my-server", "test", "sa", "123456")]
|
||||||
[InlineDataAttribute("file://my/sample/file.sql", "", "test", "sa", "123456")]
|
[InlineDataAttribute("file://my/sample/file.sql", "", "test", "sa", "123456")]
|
||||||
[InlineDataAttribute("file://my/sample/file.sql", "my-server", "", "sa", "123456")]
|
|
||||||
[InlineDataAttribute("file://my/sample/file.sql", "my-server", "test", "", "123456")]
|
[InlineDataAttribute("file://my/sample/file.sql", "my-server", "test", "", "123456")]
|
||||||
[InlineDataAttribute("file://my/sample/file.sql", "my-server", "test", "sa", "")]
|
[InlineDataAttribute("file://my/sample/file.sql", "my-server", "test", "sa", "")]
|
||||||
public void ConnectingWithInvalidParametersYieldsErrorMessage(string ownerUri, string server, string database, string userName, string password)
|
public void ConnectingWithInvalidParametersYieldsErrorMessage(string ownerUri, string server, string database, string userName, string password)
|
||||||
|
|||||||
Reference in New Issue
Block a user