33
44using System . Text . Json ;
55using Azure . Mcp . Tests . Client ;
6+ using Azure . Mcp . Tests . Client . Helpers ;
7+ using Azure . Mcp . Tests . Generated . Models ;
68using Xunit ;
79
810namespace Azure . Mcp . Tools . AppService . LiveTests . Database ;
911
1012[ Trait ( "Command" , "DatabaseAddCommand" ) ]
11- public class DatabaseAddCommandLiveTests ( ITestOutputHelper output ) : CommandTestsBase ( output )
13+ public class DatabaseAddCommandLiveTests ( ITestOutputHelper output , TestProxyFixture fixture ) : RecordedCommandTestsBase ( output , fixture )
1214{
15+ public override List < BodyKeySanitizer > BodyKeySanitizers =>
16+ [
17+ ..base . BodyKeySanitizers ,
18+ new BodyKeySanitizer ( new BodyKeySanitizerBody ( "$.properties.selfLink" ) ) ,
19+ new BodyKeySanitizer ( new BodyKeySanitizerBody ( "$.properties.customDomainVerificationId" ) ) ,
20+ new BodyKeySanitizer ( new BodyKeySanitizerBody ( "$.properties.inboundIpAddress" ) ) ,
21+ new BodyKeySanitizer ( new BodyKeySanitizerBody ( "$.properties.possibleInboundIpAddresses" ) ) ,
22+ new BodyKeySanitizer ( new BodyKeySanitizerBody ( "$.properties.inboundIpv6Address" ) ) ,
23+ new BodyKeySanitizer ( new BodyKeySanitizerBody ( "$.properties.possibleInboundIpv6Addresses" ) ) ,
24+ new BodyKeySanitizer ( new BodyKeySanitizerBody ( "$.properties.ftpsHostName" ) ) ,
25+ new BodyKeySanitizer ( new BodyKeySanitizerBody ( "$.properties.outboundIpAddresses" ) ) ,
26+ new BodyKeySanitizer ( new BodyKeySanitizerBody ( "$.properties.possibleOutboundIpAddresses" ) ) ,
27+ new BodyKeySanitizer ( new BodyKeySanitizerBody ( "$.properties.outboundIpv6Addresses" ) ) ,
28+ new BodyKeySanitizer ( new BodyKeySanitizerBody ( "$.properties.possibleOutboundIpv6Addresses" ) ) ,
29+ new BodyKeySanitizer ( new BodyKeySanitizerBody ( "$.properties.homeStamp" ) ) ,
30+ ] ;
1331 [ Fact ]
1432 public async Task ExecuteAsync_WithValidParameters_ReturnsSuccessResult ( )
1533 {
34+ var resourceGroupName = RegisterOrRetrieveVariable ( "resourceGroupName" , Settings . ResourceGroupName ) ;
35+ var resourceBaseName = TestMode == Tests . Helpers . TestMode . Playback ? "Sanitized" : Settings . ResourceBaseName ;
1636 var result = await CallToolAsync (
1737 "appservice_database_add" ,
18- new Dictionary < string , object ? >
38+ new ( )
1939 {
2040 { "subscription" , Settings . SubscriptionId } ,
21- { "resource-group" , Settings . ResourceGroupName } ,
22- { "app" , Settings . ResourceBaseName + "-webapp" } ,
41+ { "resource-group" , resourceGroupName } ,
42+ { "app" , resourceBaseName + "-webapp" } ,
2343 { "database-type" , "SqlServer" } ,
24- { "database-server" , Settings . ResourceBaseName + "-sql.database.windows.net" } ,
25- { "database" , Settings . ResourceBaseName + "db" }
44+ { "database-server" , resourceBaseName + "-sql.database.windows.net" } ,
45+ { "database" , resourceBaseName + "db" }
2646 } ) ;
2747
2848 // Test should validate actual command execution and error handling
@@ -44,7 +64,7 @@ public async Task ExecuteAsync_WithDifferentDatabaseTypes_AcceptsValidTypes(stri
4464 {
4565 var result = await CallToolAsync (
4666 "appservice_database_add" ,
47- new Dictionary < string , object ? >
67+ new ( )
4868 {
4969 { "subscription" , Settings . SubscriptionId } ,
5070 { "resource-group" , "test-rg" } ,
@@ -81,16 +101,18 @@ public async Task ExecuteAsync_WithDifferentDatabaseTypes_AcceptsValidTypes(stri
81101 [ InlineData ( "random" ) ]
82102 public async Task ExecuteAsync_WithInvalidDatabaseTypes_ReturnsValidationError ( string invalidDatabaseType )
83103 {
104+ var resourceGroupName = RegisterOrRetrieveVariable ( "resourceGroupName" , Settings . ResourceGroupName ) ;
105+ var resourceBaseName = TestMode == Tests . Helpers . TestMode . Playback ? "Sanitized" : Settings . ResourceBaseName ;
84106 var result = await CallToolAsync (
85107 "appservice_database_add" ,
86- new Dictionary < string , object ? >
108+ new ( )
87109 {
88110 { "subscription" , Settings . SubscriptionId } ,
89- { "resource-group" , Settings . ResourceGroupName } ,
90- { "app" , Settings . ResourceBaseName + "-webapp" } ,
111+ { "resource-group" , resourceGroupName } ,
112+ { "app" , resourceBaseName + "-webapp" } ,
91113 { "database-type" , invalidDatabaseType } ,
92- { "database-server" , Settings . ResourceBaseName + "-sql.database.windows.net" } ,
93- { "database" , Settings . ResourceBaseName + "db" }
114+ { "database-server" , resourceBaseName + "-sql.database.windows.net" } ,
115+ { "database" , resourceBaseName + "db" }
94116 } ) ;
95117
96118 // For invalid types, the tool may either return no JSON (error case) or a JSON error payload.
0 commit comments