mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-01-13 17:23:02 -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:
@@ -247,6 +247,27 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Connection
|
||||
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>
|
||||
/// Verify that we can connect to the default database when no database name is
|
||||
/// provided as a parameter.
|
||||
@@ -402,7 +423,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Connection
|
||||
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 =
|
||||
@@ -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", "", "my-server", "test", "sa", "123456"},
|
||||
new object[] {"Integrated", "file://my/sample/file.sql", "", "test", "sa", "123456"}
|
||||
};
|
||||
};
|
||||
/// <summary>
|
||||
/// Verify that when connecting with invalid parameters, an error is thrown.
|
||||
/// </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 =
|
||||
@@ -492,7 +513,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Connection
|
||||
TestObjects.GetTestConnectionService()
|
||||
.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