mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-01-13 17:23:02 -05:00
Enable empty passwords (#2021)
This commit is contained in:
@@ -1377,7 +1377,10 @@ namespace Microsoft.SqlTools.ServiceLayer.Connection
|
|||||||
break;
|
break;
|
||||||
case SqlLogin:
|
case SqlLogin:
|
||||||
connectionBuilder.UserID = connectionDetails.UserName;
|
connectionBuilder.UserID = connectionDetails.UserName;
|
||||||
connectionBuilder.Password = connectionDetails.Password;
|
if (!string.IsNullOrEmpty(connectionDetails.Password))
|
||||||
|
{
|
||||||
|
connectionBuilder.Password = connectionDetails.Password;
|
||||||
|
}
|
||||||
connectionBuilder.Authentication = SqlAuthenticationMethod.SqlPassword;
|
connectionBuilder.Authentication = SqlAuthenticationMethod.SqlPassword;
|
||||||
break;
|
break;
|
||||||
case AzureMFA:
|
case AzureMFA:
|
||||||
|
|||||||
@@ -469,8 +469,35 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Connection
|
|||||||
Assert.That(connectionResult.ErrorMessage, 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[] noPassword =
|
||||||
{
|
{
|
||||||
|
new object[] {"sa", null},
|
||||||
|
new object[] {"sa", ""},
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Verify that when using sql logins, the password can be empty.
|
||||||
|
/// </summary>
|
||||||
|
[Test, TestCaseSource(nameof(noPassword))]
|
||||||
|
public void ConnectingWithNoPasswordWorksForSqlLogin(string userName, string password)
|
||||||
|
{
|
||||||
|
// Connect
|
||||||
|
var connectionResult =
|
||||||
|
ConnectionService.CreateConnectionStringBuilder(new ConnectionDetails()
|
||||||
|
{
|
||||||
|
ServerName = "my-server",
|
||||||
|
DatabaseName = "test",
|
||||||
|
UserName = userName,
|
||||||
|
Password = password,
|
||||||
|
AuthenticationType = SqlLogin
|
||||||
|
});
|
||||||
|
|
||||||
|
Assert.That(connectionResult, Is.Not.Null.Or.Empty, "check that the connection was successful");
|
||||||
|
}
|
||||||
|
|
||||||
|
static readonly object[] noUserNameOrPassword =
|
||||||
|
{
|
||||||
new object[] {null, null},
|
new object[] {null, null},
|
||||||
new object[] {null, ""},
|
new object[] {null, ""},
|
||||||
new object[] {"", null},
|
new object[] {"", null},
|
||||||
@@ -480,7 +507,6 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Connection
|
|||||||
new object[] {null, "12345678"},
|
new object[] {null, "12345678"},
|
||||||
new object[] {"", "12345678"},
|
new object[] {"", "12345678"},
|
||||||
};
|
};
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Verify that when using integrated authentication, the username and/or password can be empty.
|
/// Verify that when using integrated authentication, the username and/or password can be empty.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
Reference in New Issue
Block a user