Skip to content

Commit 71c638a

Browse files
amolagar5vidai-msftdingmeng-xuewyunchi-ms
authored
Fix aad graph endpoint for SQL server and managed instance APIs (#19712)
* Fixed batch test recording issue (#19706) * fix aad graph endpoint Co-authored-by: Vincent Dai <[email protected]> Co-authored-by: Dingmeng Xue <[email protected]> Co-authored-by: Yunchi Wang <[email protected]>
1 parent 02c9afc commit 71c638a

File tree

6 files changed

+28
-33
lines changed

6 files changed

+28
-33
lines changed

src/DevTestLabs/DevTestLabs.Test/ScenarioTests/PolicyTests.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,13 @@
1414

1515
using Microsoft.WindowsAzure.Commands.ScenarioTest;
1616
using Xunit;
17-
using Xunit.Sdk;
1817

1918
namespace Microsoft.Azure.Commands.DevTestLabs.Test.ScenarioTests
2019
{
2120
public class PolicyTests : DevTestLabsTestRunner
2221
{
2322

24-
public PolicyTests(TestOutputHelper output) : base(output)
23+
public PolicyTests(Xunit.Abstractions.ITestOutputHelper output) : base(output)
2524
{
2625

2726
}

src/Sql/Sql/ChangeLog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
* Removed the following aliases: `Enable-AzSqlServerAdvancedThreatProtection`, `Disable-AzSqlServerAdvancedThreatProtection`, `Get-AzSqlServerThreatDetectionSetting`, `Remove-AzSqlServerThreatDetectionSetting`, `Set-AzSqlServerThreatDetectionSetting`, `Get-AzSqlDatabaseThreatDetectionSetting`, `Set-AzSqlDatabaseThreatDetectionSetting` and `Remove-AzSqlDatabaseThreatDetectionSetting`
2727
* Changed the returned object for the following cmdlets: `Get-AzSqlServerAdvancedThreatProtectionSetting` and `Get-AzSqlDatabaseAdvancedThreatProtectionSetting`
2828
* Changed the parameters for the following cmdlets: `Update-AzSqlServerAdvancedThreatProtectionSetting` and `Update-AzSqlDatabaseAdvancedThreatProtectionSetting`. Only `Enable` parameter is now supported.
29+
* Changed endpoint used in SQL Server and SQL Instance from AD Graph to MS Graph
2930

3031
## Version 3.11.0
3132
* Removed the warning messages for MSGraph migration [#18856]

src/Sql/Sql/ManagedInstance/Services/AzureSqlManagedInstanceAdapter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public MicrosoftGraphClient MicrosoftGraphClient
6161
{
6262
if (_microsoftGraphClient == null)
6363
{
64-
_microsoftGraphClient = AzureSession.Instance.ClientFactory.CreateArmClient<MicrosoftGraphClient>(Context, AzureEnvironment.Endpoint.Graph);
64+
_microsoftGraphClient = AzureSession.Instance.ClientFactory.CreateArmClient<MicrosoftGraphClient>(Context, AzureEnvironment.ExtendedEndpoint.MicrosoftGraphUrl);
6565
_microsoftGraphClient.TenantID = Context.Tenant.Id;
6666
}
6767
return _microsoftGraphClient;

src/Sql/Sql/Server/Services/AzureSqlServerAdapter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public MicrosoftGraphClient MicrosoftGraphClient
6060
{
6161
if (_microsoftGraphClient == null)
6262
{
63-
_microsoftGraphClient = AzureSession.Instance.ClientFactory.CreateArmClient<MicrosoftGraphClient>(Context, AzureEnvironment.Endpoint.Graph);
63+
_microsoftGraphClient = AzureSession.Instance.ClientFactory.CreateArmClient<MicrosoftGraphClient>(Context, AzureEnvironment.ExtendedEndpoint.MicrosoftGraphUrl);
6464
_microsoftGraphClient.TenantID = Context.Tenant.Id;
6565
}
6666
return _microsoftGraphClient;

tools/TestFx/TestEnvironment.cs

Lines changed: 23 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,6 @@ public TestEnvironment(string connectionString)
110110

111111
InitTokenDictionary();
112112
SetupHttpRecorderMode();
113-
RecorderModeSettings();
114113
}
115114

116115
private void InitTestEndPoints()
@@ -186,31 +185,6 @@ private void SetupHttpRecorderMode()
186185
}
187186
}
188187

189-
private void RecorderModeSettings()
190-
{
191-
if (HttpMockServer.Mode == HttpRecorderMode.Record)
192-
{
193-
//Restore/Add Subscription Id in MockServer from supplied connection string
194-
if (HttpMockServer.Variables.ContainsCaseInsensitiveKey(ConnectionStringKeys.SubscriptionIdKey))
195-
{
196-
HttpMockServer.Variables.UpdateDictionary(ConnectionStringKeys.SubscriptionIdKey, SubscriptionId);
197-
}
198-
else
199-
{
200-
HttpMockServer.Variables.Add(ConnectionStringKeys.SubscriptionIdKey, SubscriptionId);
201-
}
202-
203-
// If User has provided Access Token in RawToken/GraphToken Key-Value, we don't need to authenticate
204-
// We currently only check for RawToken and do not check if GraphToken is provided
205-
if (string.IsNullOrEmpty(ConnectionString.GetValue(ConnectionStringKeys.RawTokenKey)))
206-
{
207-
Login();
208-
}
209-
210-
VerifyAuthTokens();
211-
}
212-
}
213-
214188
private void Login()
215189
{
216190
string userPassword = ConnectionString.GetValue(ConnectionStringKeys.PasswordKey);
@@ -413,9 +387,30 @@ private void VerifyGraphToken()
413387
}
414388
}
415389

416-
internal void SetRecordedEnvironmentVariables()
390+
internal void SetEnvironmentVariables()
417391
{
418-
if (HttpMockServer.Mode == HttpRecorderMode.Playback)
392+
if (HttpMockServer.Mode == HttpRecorderMode.Record)
393+
{
394+
//Restore/Add Subscription Id in MockServer from supplied connection string
395+
if (HttpMockServer.Variables.ContainsCaseInsensitiveKey(ConnectionStringKeys.SubscriptionIdKey))
396+
{
397+
HttpMockServer.Variables.UpdateDictionary(ConnectionStringKeys.SubscriptionIdKey, SubscriptionId);
398+
}
399+
else
400+
{
401+
HttpMockServer.Variables.Add(ConnectionStringKeys.SubscriptionIdKey, SubscriptionId);
402+
}
403+
404+
// If User has provided Access Token in RawToken/GraphToken Key-Value, we don't need to authenticate
405+
// We currently only check for RawToken and do not check if GraphToken is provided
406+
if (string.IsNullOrEmpty(ConnectionString.GetValue(ConnectionStringKeys.RawTokenKey)))
407+
{
408+
Login();
409+
}
410+
411+
VerifyAuthTokens();
412+
}
413+
else if (HttpMockServer.Mode == HttpRecorderMode.Playback)
419414
{
420415
//Get Subscription Id from MockServer. Otherwise, assign zero guid
421416
if (HttpMockServer.Variables.ContainsCaseInsensitiveKey(ConnectionStringKeys.SubscriptionIdKey))

tools/TestFx/TestEnvironmentFactory.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ static TestEnvironmentFactory()
3030

3131
internal static TestEnvironment BuildTestFxEnvironment()
3232
{
33-
_environment.SetRecordedEnvironmentVariables();
33+
_environment.SetEnvironmentVariables();
3434
return _environment;
3535
}
3636

0 commit comments

Comments
 (0)