Fix tests to capture encrypt 'null' by default (#1738)

This commit is contained in:
Cheena Malhotra
2022-10-28 12:39:34 -07:00
committed by GitHub
parent faaec187a7
commit 2f2f65c89f
2 changed files with 5 additions and 6 deletions

View File

@@ -150,15 +150,15 @@ namespace Microsoft.SqlTools.ServiceLayer.Connection.Contracts
/// 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. /// 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. /// Boolean 'true' and 'false' will also continue to be supported for backwards compatibility.
/// </summary> /// </summary>
public string Encrypt public string? Encrypt
{ {
get get
{ {
string value = GetOptionValue<string>("encrypt"); string? value = GetOptionValue<string?>("encrypt");
if(string.IsNullOrEmpty(value)) if(string.IsNullOrEmpty(value))
{ {
// Accept boolean values for backwards compatibility. // Accept boolean values for backwards compatibility.
value = GetOptionValue<bool>("encrypt").ToString(); value = GetOptionValue<bool?>("encrypt")?.ToString();
} }
return value; return value;
} }

View File

@@ -25,7 +25,6 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Connection
var expectedForStrings = default(string); var expectedForStrings = default(string);
var expectedForInt = default(int?); var expectedForInt = default(int?);
var expectedForBoolean = default(bool?); var expectedForBoolean = default(bool?);
var expectedEncryptOption = default(string?);
Assert.AreEqual(details.ApplicationIntent, expectedForStrings); Assert.AreEqual(details.ApplicationIntent, expectedForStrings);
Assert.AreEqual(details.ApplicationName, expectedForStrings); Assert.AreEqual(details.ApplicationName, expectedForStrings);
@@ -49,7 +48,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Connection
Assert.AreEqual(details.ColumnEncryptionSetting, expectedForStrings); Assert.AreEqual(details.ColumnEncryptionSetting, expectedForStrings);
Assert.AreEqual(details.EnclaveAttestationUrl, expectedForStrings); Assert.AreEqual(details.EnclaveAttestationUrl, expectedForStrings);
Assert.AreEqual(details.EnclaveAttestationProtocol, expectedForStrings); Assert.AreEqual(details.EnclaveAttestationProtocol, expectedForStrings);
Assert.AreEqual(details.Encrypt, expectedEncryptOption); Assert.AreEqual(details.Encrypt, expectedForStrings);
Assert.AreEqual(details.MultipleActiveResultSets, expectedForBoolean); Assert.AreEqual(details.MultipleActiveResultSets, expectedForBoolean);
Assert.AreEqual(details.MultiSubnetFailover, expectedForBoolean); Assert.AreEqual(details.MultiSubnetFailover, expectedForBoolean);
Assert.AreEqual(details.PersistSecurityInfo, expectedForBoolean); Assert.AreEqual(details.PersistSecurityInfo, expectedForBoolean);
@@ -242,7 +241,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Connection
} }
[Test] [Test]
public void EncryptShouldReturnMandatoryIfNotSet() public void EncryptShouldReturnNullIfNotSet()
{ {
ConnectionDetails details = new ConnectionDetails(); ConnectionDetails details = new ConnectionDetails();
Assert.That(details.Encrypt, Is.Null, "Encrypt should be null when set to null"); Assert.That(details.Encrypt, Is.Null, "Encrypt should be null when set to null");