mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-02-17 02:51:45 -05:00
Changes to sqltoolsservice to allow empty password for SqlLogin (#333)
* Initial changes to allow empty passwords * Added in empty password test * Modifying test to work after my changes.
This commit is contained in:
@@ -78,7 +78,7 @@ namespace Microsoft.SqlTools.Credentials.Contracts
|
|||||||
public static void ValidateForSave(Credential credential)
|
public static void ValidateForSave(Credential credential)
|
||||||
{
|
{
|
||||||
ValidateForLookup(credential);
|
ValidateForLookup(credential);
|
||||||
Validate.IsNotNullOrEmptyString("credential.Password", credential.Password);
|
Validate.IsNotNull("credential.Password", credential.Password);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -35,15 +35,11 @@ namespace Microsoft.SqlTools.ServiceLayer.Connection.Contracts
|
|||||||
}
|
}
|
||||||
else if (string.IsNullOrEmpty(parameters.Connection.AuthenticationType) || parameters.Connection.AuthenticationType == "SqlLogin")
|
else if (string.IsNullOrEmpty(parameters.Connection.AuthenticationType) || parameters.Connection.AuthenticationType == "SqlLogin")
|
||||||
{
|
{
|
||||||
// For SqlLogin, username/password cannot be empty
|
// For SqlLogin, username cannot be empty
|
||||||
if (string.IsNullOrEmpty(parameters.Connection.UserName))
|
if (string.IsNullOrEmpty(parameters.Connection.UserName))
|
||||||
{
|
{
|
||||||
errorMessage = SR.ConnectionParamsValidateNullSqlAuth("UserName");
|
errorMessage = SR.ConnectionParamsValidateNullSqlAuth("UserName");
|
||||||
}
|
}
|
||||||
else if( string.IsNullOrEmpty(parameters.Connection.Password))
|
|
||||||
{
|
|
||||||
errorMessage = SR.ConnectionParamsValidateNullSqlAuth("Password");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return string.IsNullOrEmpty(errorMessage);
|
return string.IsNullOrEmpty(errorMessage);
|
||||||
|
|||||||
@@ -91,7 +91,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Credentials
|
|||||||
|
|
||||||
await service.HandleSaveCredentialRequest(new Credential(CredentialId), contextMock.Object);
|
await service.HandleSaveCredentialRequest(new Credential(CredentialId), contextMock.Object);
|
||||||
TestUtils.VerifyErrorSent(contextMock);
|
TestUtils.VerifyErrorSent(contextMock);
|
||||||
Assert.Contains("ArgumentException", errorResponse);
|
Assert.True(errorResponse.Contains("ArgumentException") || errorResponse.Contains("ArgumentNullException"));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
@@ -102,6 +102,14 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Credentials
|
|||||||
verify: Assert.True);
|
verify: Assert.True);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public async Task SaveCredentialWorksForEmptyPassword()
|
||||||
|
{
|
||||||
|
await TestUtils.RunAndVerify<bool>(
|
||||||
|
test: (requestContext) => service.HandleSaveCredentialRequest(new Credential(CredentialId, ""), requestContext),
|
||||||
|
verify: Assert.True);
|
||||||
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task SaveCredentialSupportsSavingCredentialMultipleTimes()
|
public async Task SaveCredentialSupportsSavingCredentialMultipleTimes()
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user