mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-02-12 19:18:33 -05:00
Support Boolean type for Encrypt option value (#1737)
This commit is contained in:
@@ -147,13 +147,20 @@ namespace Microsoft.SqlTools.ServiceLayer.Connection.Contracts
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets a <see cref="string"/> value that indicates encryption mode that SQL Server should use to perform SSL encryption for all the data sent between the client and server. Supported values are: Optional, Mandatory, Strict.
|
/// Gets or sets a <see cref="string"/> value that indicates encryption mode that SQL Server should use to perform SSL encryption for all the data sent between the client and server. Supported values are: Optional, Mandatory, Strict, True, False, Yes and No.
|
||||||
|
/// Boolean 'true' and 'false' will also continue to be supported for backwards compatibility.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string Encrypt
|
public string Encrypt
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return GetOptionValue<string>("encrypt");
|
string value = GetOptionValue<string>("encrypt");
|
||||||
|
if(string.IsNullOrEmpty(value))
|
||||||
|
{
|
||||||
|
// Accept boolean values for backwards compatibility.
|
||||||
|
value = GetOptionValue<bool>("encrypt").ToString();
|
||||||
|
}
|
||||||
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
set
|
set
|
||||||
|
|||||||
@@ -673,6 +673,24 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Connection
|
|||||||
Assert.That(connectionString, Contains.Substring("Encrypt=" + expected.ToString()), "Encrypt not as expected.");
|
Assert.That(connectionString, Contains.Substring("Encrypt=" + expected.ToString()), "Encrypt not as expected.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Verify that Strict Encryption parameters can be built into a connection string for connecting.
|
||||||
|
/// </summary>
|
||||||
|
[Test]
|
||||||
|
[TestCase(true, "True")]
|
||||||
|
[TestCase(false, "False")]
|
||||||
|
public void ConnectingWithBoolEncryptBuildsConnectionString(bool encryptValue, string expected)
|
||||||
|
{
|
||||||
|
// Create a test connection details object and set the property to a specific value
|
||||||
|
ConnectionDetails details = TestObjects.GetTestConnectionDetails();
|
||||||
|
details.Options["encrypt"] = encryptValue;
|
||||||
|
|
||||||
|
// Test that a connection string can be created without exceptions
|
||||||
|
string connectionString = ConnectionService.BuildConnectionString(details);
|
||||||
|
|
||||||
|
Assert.That(connectionString, Contains.Substring("Encrypt=" + expected), "Encrypt not as expected.");
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Build connection string with an invalid property combinations
|
/// Build connection string with an invalid property combinations
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
Reference in New Issue
Block a user