Skip to content

Commit bb9b5d7

Browse files
committed
🤖 🔨
1 parent 992fb31 commit bb9b5d7

5 files changed

Lines changed: 100 additions & 4 deletions

File tree

eng/pipelines/common/templates/steps/update-config-file-step.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,8 +188,6 @@ steps:
188188
189189
$p.DNSCachingConnString="${{parameters.DNSCachingConnString }}"
190190
191-
$p.SupportsFileStream="${{parameters.SupportsFileStream }}"
192-
193191
$p.LocalDbAppName="${{parameters.LocalDbAppName }}"
194192
195193
$p.TCPConnectionStringAASSGX="${{parameters.TCPConnectionStringAASSGX }}"
@@ -200,6 +198,7 @@ steps:
200198
201199
$p.UseManagedSNIOnWindows=[System.Convert]::ToBoolean("${{parameters.UseManagedSNIOnWindows }}")
202200
$p.SupportsIntegratedSecurity=[System.Convert]::ToBoolean("${{parameters.SupportsIntegratedSecurity }}")
201+
$p.SupportsFileStream=[System.Convert]::ToBoolean("${{parameters.SupportsFileStream }}")
203202
$p.ManagedIdentitySupported=[System.Convert]::ToBoolean("${{parameters.ManagedIdentitySupported }}")
204203
$p.IsAzureSynapse=[System.Convert]::ToBoolean("${{parameters.IsAzureSynapse }}")
205204
$p.IsDNSCachingSupportedTR=[System.Convert]::ToBoolean("${{parameters.IsDNSCachingSupportedTR }}")
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
// See the LICENSE file in the project root for more information.
4+
5+
using System;
6+
using System.IO;
7+
using Microsoft.Data.SqlClient.TestUtilities;
8+
using Xunit;
9+
10+
namespace Microsoft.Data.SqlClient.Tests
11+
{
12+
public class ConfigTests
13+
{
14+
[Fact]
15+
public void Load_WithJsoncAndCaseDifferences_PopulatesPublicFields()
16+
{
17+
string configPath = Path.GetTempFileName();
18+
19+
try
20+
{
21+
File.WriteAllText(
22+
configPath,
23+
"""
24+
{
25+
// Verify JSONC comments and trailing commas are accepted.
26+
"TCPConnectionString": "Server=tcp:localhost;Database=Northwind;",
27+
"SupportsFileStream": true,
28+
"IsAzureSynapse": true,
29+
"WorkloadIdentityFederationServiceConnectionId": "service-connection-id",
30+
"KerberosDomainuser": "domain-user",
31+
}
32+
""");
33+
34+
Config config = Config.Load(configPath);
35+
36+
Assert.Equal("Server=tcp:localhost;Database=Northwind;", config.TCPConnectionString);
37+
Assert.True(config.SupportsFileStream);
38+
Assert.True(config.IsAzureSynapse);
39+
Assert.Equal("service-connection-id", config.WorkloadIdentityFederationServiceConnectionId);
40+
Assert.Equal("domain-user", config.KerberosDomainUser);
41+
}
42+
finally
43+
{
44+
File.Delete(configPath);
45+
}
46+
}
47+
48+
[Fact]
49+
public void UpdateConfig_RoundTripsPipelineConfigFields()
50+
{
51+
string configPath = Path.GetTempFileName();
52+
53+
try
54+
{
55+
Config expected = new()
56+
{
57+
TCPConnectionString = "Server=tcp:localhost;Database=Northwind;",
58+
SupportsFileStream = true,
59+
IsAzureSynapse = true,
60+
WorkloadIdentityFederationServiceConnectionId = "service-connection-id",
61+
KerberosDomainUser = "domain-user",
62+
};
63+
64+
Config.UpdateConfig(expected, configPath);
65+
66+
string writtenConfig = File.ReadAllText(configPath);
67+
Assert.Contains("\"SupportsFileStream\":true", writtenConfig, StringComparison.Ordinal);
68+
Assert.Contains("\"IsAzureSynapse\":true", writtenConfig, StringComparison.Ordinal);
69+
Assert.Contains(
70+
"\"WorkloadIdentityFederationServiceConnectionId\":\"service-connection-id\"",
71+
writtenConfig,
72+
StringComparison.Ordinal);
73+
74+
Config actual = Config.Load(configPath);
75+
Assert.Equal(expected.TCPConnectionString, actual.TCPConnectionString);
76+
Assert.Equal(expected.SupportsFileStream, actual.SupportsFileStream);
77+
Assert.Equal(expected.IsAzureSynapse, actual.IsAzureSynapse);
78+
Assert.Equal(
79+
expected.WorkloadIdentityFederationServiceConnectionId,
80+
actual.WorkloadIdentityFederationServiceConnectionId);
81+
Assert.Equal(expected.KerberosDomainUser, actual.KerberosDomainUser);
82+
}
83+
finally
84+
{
85+
File.Delete(configPath);
86+
}
87+
}
88+
}
89+
}

src/Microsoft.Data.SqlClient/tests/UnitTests/Microsoft.Data.SqlClient.UnitTests.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
<!-- Test target reference -->
4141
<ItemGroup>
4242
<ProjectReference Include="$(RepoRoot)src/Microsoft.Data.SqlClient/src/Microsoft.Data.SqlClient.csproj" />
43+
<ProjectReference Include="$(RepoRoot)src/Microsoft.Data.SqlClient/tests/tools/Microsoft.Data.SqlClient.TestUtilities/Microsoft.Data.SqlClient.TestUtilities.csproj" />
4344
</ItemGroup>
4445

4546
<!-- References for netframework -->

src/Microsoft.Data.SqlClient/tests/tools/Microsoft.Data.SqlClient.TestUtilities/Config.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ public class Config
1515
private static readonly JsonSerializerOptions JsonSerializerOptions = new()
1616
{
1717
AllowTrailingCommas = true,
18+
IncludeFields = true,
19+
PropertyNameCaseInsensitive = true,
1820
ReadCommentHandling = JsonCommentHandling.Skip,
1921
};
2022

@@ -32,6 +34,7 @@ public class Config
3234
public string? AzureKeyVaultURL = null;
3335
public string? AzureKeyVaultTenantId = null;
3436
public bool SupportsIntegratedSecurity = false;
37+
public bool SupportsFileStream = false;
3538
public string? LocalDbAppName = null;
3639
public string? LocalDbSharedInstanceName = null;
3740
public string? FileStreamDirectory = null;
@@ -42,8 +45,10 @@ public class Config
4245
public bool IsDNSCachingSupportedCR = false; // this is for the control ring
4346
public bool IsDNSCachingSupportedTR = false; // this is for the tenant ring
4447
public string? EnclaveAzureDatabaseConnString = null;
48+
public bool IsAzureSynapse = false;
4549
public bool ManagedIdentitySupported = true;
4650
public string? UserManagedIdentityClientId = null;
51+
public string? WorkloadIdentityFederationServiceConnectionId = null;
4752
public string? PowerShellPath = null;
4853
public string? AliasName = null;
4954
public string? KerberosDomainPassword = null;
@@ -78,7 +83,7 @@ public static Config Load()
7883

7984
public static void UpdateConfig(Config updatedConfig, string configPath = @"config.jsonc")
8085
{
81-
string config = JsonSerializer.Serialize(updatedConfig);
86+
string config = JsonSerializer.Serialize(updatedConfig, JsonSerializerOptions);
8287
File.WriteAllText(configPath, config);
8388
}
8489

src/Microsoft.Data.SqlClient/tests/tools/Microsoft.Data.SqlClient.TestUtilities/config.default.jsonc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
"AzureKeyVaultURL": "",
2121
"AzureKeyVaultTenantId": "",
2222
"SupportsIntegratedSecurity": true,
23+
"SupportsFileStream": false,
2324
"LocalDbAppName": "",
2425
"LocalDbSharedInstanceName": "",
2526
"FileStreamDirectory": "",
@@ -30,12 +31,13 @@
3031
"IsDNSCachingSupportedCR": false,
3132
"IsDNSCachingSupportedTR": false,
3233
"EnclaveAzureDatabaseConnString": "",
34+
"IsAzureSynapse": false,
3335
"ManagedIdentitySupported": true,
3436
"UserManagedIdentityClientId": "",
3537
"PowerShellPath": "",
3638
"AliasName": "",
3739
"WorkloadIdentityFederationServiceConnectionId": "",
3840
"KerberosDomainPassword": "",
39-
"KerberosDomainuser": "",
41+
"KerberosDomainUser": "",
4042
"IsManagedInstance": false
4143
}

0 commit comments

Comments
 (0)