mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-02-16 10:58:30 -05:00
Added error message to validate connect params. (#1660)
* Added error message to validate connect params. * removed connectionParam == null as ConnnectionCompleteParams cannot be nulled. * Added ValidateConnectParams to other connection services * removed message from error * reverted change to connectionServiceCore * added updated message * restore null and added errormessage to GetConnectionCompleteParams * fix for sr.xlf * fix for tab * another fix to tabs * added message to connection complete error * small fix
This commit is contained in:
@@ -139,7 +139,7 @@ namespace Microsoft.Kusto.ServiceLayer.Connection
|
|||||||
return new ConnectionCompleteParams
|
return new ConnectionCompleteParams
|
||||||
{
|
{
|
||||||
OwnerUri = connectionParams.OwnerUri,
|
OwnerUri = connectionParams.OwnerUri,
|
||||||
Messages = paramValidationErrorMessage
|
ErrorMessage = paramValidationErrorMessage,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -371,6 +371,7 @@ namespace Microsoft.Kusto.ServiceLayer.Connection
|
|||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
response.Messages = ex.ToString();
|
response.Messages = ex.ToString();
|
||||||
|
response.ErrorMessage = ex.Message;
|
||||||
}
|
}
|
||||||
|
|
||||||
return response;
|
return response;
|
||||||
|
|||||||
@@ -319,20 +319,19 @@ namespace Microsoft.SqlTools.ServiceLayer.Connection
|
|||||||
/// null upon validation success</returns>
|
/// null upon validation success</returns>
|
||||||
public ConnectionCompleteParams ValidateConnectParams(ConnectParams connectionParams)
|
public ConnectionCompleteParams ValidateConnectParams(ConnectParams connectionParams)
|
||||||
{
|
{
|
||||||
string paramValidationErrorMessage;
|
|
||||||
if (connectionParams == null)
|
if (connectionParams == null)
|
||||||
{
|
{
|
||||||
return new ConnectionCompleteParams
|
return new ConnectionCompleteParams
|
||||||
{
|
{
|
||||||
Messages = SR.ConnectionServiceConnectErrorNullParams
|
ErrorMessage = SR.ConnectionServiceConnectErrorNullParams
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
if (!connectionParams.IsValid(out paramValidationErrorMessage))
|
if (!connectionParams.IsValid(out string paramValidationErrorMessage))
|
||||||
{
|
{
|
||||||
return new ConnectionCompleteParams
|
return new ConnectionCompleteParams
|
||||||
{
|
{
|
||||||
OwnerUri = connectionParams.OwnerUri,
|
OwnerUri = connectionParams.OwnerUri,
|
||||||
Messages = paramValidationErrorMessage
|
ErrorMessage = paramValidationErrorMessage
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -569,6 +568,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Connection
|
|||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
response.Messages = ex.ToString();
|
response.Messages = ex.ToString();
|
||||||
|
response.ErrorMessage = ex.Message;
|
||||||
}
|
}
|
||||||
|
|
||||||
return response;
|
return response;
|
||||||
|
|||||||
@@ -247,6 +247,27 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Connection
|
|||||||
Assert.False(disconnectResult);
|
Assert.False(disconnectResult);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Verify that we cannot connect to the default database when no username
|
||||||
|
/// is provided and the authentication type is basic auth.
|
||||||
|
/// </summary>
|
||||||
|
[Test]
|
||||||
|
public async Task CantConnectWithoutUsername()
|
||||||
|
{
|
||||||
|
// Connect
|
||||||
|
var connectionDetails = TestObjects.GetTestConnectionDetails();
|
||||||
|
connectionDetails.UserName = "";
|
||||||
|
var connectionResult = await
|
||||||
|
TestObjects.GetTestConnectionService()
|
||||||
|
.Connect(new ConnectParams()
|
||||||
|
{
|
||||||
|
OwnerUri = "file:///my/test/file.sql",
|
||||||
|
Connection = connectionDetails
|
||||||
|
});
|
||||||
|
|
||||||
|
Assert.That(connectionResult.ErrorMessage, Is.EqualTo(SR.ConnectionParamsValidateNullSqlAuth("UserName")));
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Verify that we can connect to the default database when no database name is
|
/// Verify that we can connect to the default database when no database name is
|
||||||
/// provided as a parameter.
|
/// provided as a parameter.
|
||||||
@@ -402,7 +423,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Connection
|
|||||||
Connection = invalidConnectionDetails
|
Connection = invalidConnectionDetails
|
||||||
});
|
});
|
||||||
|
|
||||||
Assert.That(connectionResult.Messages, Is.Not.Null.Or.Empty, "check that an error was caught");
|
Assert.That(connectionResult.ErrorMessage, Is.Not.Null.Or.Empty, "check that an error was caught");
|
||||||
}
|
}
|
||||||
|
|
||||||
static readonly object[] invalidParameters =
|
static readonly object[] invalidParameters =
|
||||||
@@ -419,7 +440,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Connection
|
|||||||
new object[] {"Integrated", "file://my/sample/file.sql", null, "test", "sa", "123456"},
|
new object[] {"Integrated", "file://my/sample/file.sql", null, "test", "sa", "123456"},
|
||||||
new object[] {"Integrated", "", "my-server", "test", "sa", "123456"},
|
new object[] {"Integrated", "", "my-server", "test", "sa", "123456"},
|
||||||
new object[] {"Integrated", "file://my/sample/file.sql", "", "test", "sa", "123456"}
|
new object[] {"Integrated", "file://my/sample/file.sql", "", "test", "sa", "123456"}
|
||||||
};
|
};
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Verify that when connecting with invalid parameters, an error is thrown.
|
/// Verify that when connecting with invalid parameters, an error is thrown.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -442,7 +463,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Connection
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Assert.That(connectionResult.Messages, Is.Not.Null.Or.Empty, "check that an error was caught");
|
Assert.That(connectionResult.ErrorMessage, Is.Not.Null.Or.Empty, "check that an error was caught");
|
||||||
}
|
}
|
||||||
|
|
||||||
static readonly object[] noUserNameOrPassword =
|
static readonly object[] noUserNameOrPassword =
|
||||||
@@ -492,7 +513,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Connection
|
|||||||
TestObjects.GetTestConnectionService()
|
TestObjects.GetTestConnectionService()
|
||||||
.Connect(null);
|
.Connect(null);
|
||||||
|
|
||||||
Assert.That(connectionResult.Messages, Is.Not.Null.Or.Empty, "check that an error was caught");
|
Assert.That(connectionResult.ErrorMessage, Is.Not.Null.Or.Empty, "check that an error was caught");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user