Skip to content

Commit bc2f780

Browse files
authored
Fix cases and utils script for 'BotService' (#13813)
* Fix cases and utils script for 'BotService' * update env file * Add SubscriptionId in cmdlet ’New-AzBotService‘ * update the cmdlet 'New-AzBotservice' * Update custome file
1 parent d6e0580 commit bc2f780

7 files changed

+54
-20
lines changed

src/BotService/custom/New-AzBotService.ps1

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,9 @@ function New-AzBotService {
196196
Write-Error $NameAvailabilityResponse.Message
197197
throw
198198
}
199+
if ($PSBoundParameters.ContainsKey('SubscriptionId')) {
200+
$EnvPSBoundParameters['SubscriptionId'] = [System.String]$SubscriptionId
201+
}
199202
if ($BotKind -eq $Kind)
200203
{
201204
if (-not $PSBoundParameters.ContainsKey('DisplayName'))

src/BotService/test/Initialize-AzBotServicePrepareDeploy.Tests.ps1

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ while(-not $mockingPath) {
1212
. ($mockingPath | Select-Object -First 1).FullName
1313

1414
Describe 'Initialize-AzBotServicePrepareDeploy' {
15-
It '__AllParameterSets' -skip {
16-
# Join-Path $PSScriptRoot 'resources\MyEchoBot'
15+
It '__AllParameterSets' -Skip {
1716
Initialize-AzBotServicePrepareDeploy -CodeDir $env.NewBotService2 -ProjFileName EchoBot.csproj
1817
$IsExit = Test-Path "$($env.NewBotService2)\.deployment"
1918
$IsExit | Should -Be $True

src/BotService/test/New-AzBotService.Recording.json

Lines changed: 40 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
{
2-
"New-AzBotService+[NoContext]+WebApp+$POST+https://management.azure.com/providers/Microsoft.BotService/checkNameAvailability?api-version=2018-07-12+1": {
2+
"New-AzBotService+[NoContext]+Registration+$POST+https://management.azure.com/providers/Microsoft.BotService/checkNameAvailability?api-version=2018-07-12+1": {
33
"Request": {
44
"Method": "POST",
55
"RequestUri": "https://management.azure.com/providers/Microsoft.BotService/checkNameAvailability?api-version=2018-07-12",
6-
"Content": "{\r\n \"name\": \"BotService-v5kgny\",\r\n \"type\": \"sdk\"\r\n}",
6+
"Content": "{\r\n \"name\": \"BotService-02le6b\",\r\n \"type\": \"bot\"\r\n}",
77
"Headers": {
88
},
99
"ContentHeaders": {
@@ -19,11 +19,11 @@
1919
"Vary": [ "Accept-Encoding" ],
2020
"x-ms-ratelimit-remaining-tenant-writes": [ "1199" ],
2121
"Strict-Transport-Security": [ "max-age=31536000; includeSubDomains" ],
22-
"x-ms-request-id": [ "c1582637-c843-4584-b09b-d7df1984c07d" ],
23-
"x-ms-correlation-request-id": [ "c1582637-c843-4584-b09b-d7df1984c07d" ],
24-
"x-ms-routing-request-id": [ "SOUTHEASTASIA:20201216T123323Z:c1582637-c843-4584-b09b-d7df1984c07d" ],
22+
"x-ms-request-id": [ "196a3fb6-347e-4f44-8b02-ace52a682398" ],
23+
"x-ms-correlation-request-id": [ "196a3fb6-347e-4f44-8b02-ace52a682398" ],
24+
"x-ms-routing-request-id": [ "SOUTHEASTASIA:20201222T065124Z:196a3fb6-347e-4f44-8b02-ace52a682398" ],
2525
"X-Content-Type-Options": [ "nosniff" ],
26-
"Date": [ "Wed, 16 Dec 2020 12:33:23 GMT" ]
26+
"Date": [ "Tue, 22 Dec 2020 06:51:24 GMT" ]
2727
},
2828
"ContentHeaders": {
2929
"Content-Length": [ "42" ],
@@ -32,5 +32,39 @@
3232
},
3333
"Content": "{\"valid\":true,\"message\":\"\",\"absCode\":null}"
3434
}
35+
},
36+
"New-AzBotService+[NoContext]+Registration+$PUT+https://management.azure.com/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/youriBotService-rg-g0j9s3/providers/Microsoft.BotService/botServices/BotService-02le6b?api-version=2018-07-12+2": {
37+
"Request": {
38+
"Method": "PUT",
39+
"RequestUri": "https://management.azure.com/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/youriBotService-rg-g0j9s3/providers/Microsoft.BotService/botServices/BotService-02le6b?api-version=2018-07-12",
40+
"Content": "{\r\n \"sku\": {\r\n \"name\": \"F0\"\r\n },\r\n \"location\": \"global\",\r\n \"kind\": \"bot\",\r\n \"properties\": {\r\n \"displayName\": \"BotService-02le6b\",\r\n \"endpoint\": \"\",\r\n \"msaAppId\": \"2d00693f-17b0-4b43-b850-1d3fb485272e\"\r\n }\r\n}",
41+
"Headers": {
42+
},
43+
"ContentHeaders": {
44+
"Content-Type": [ "application/json" ],
45+
"Content-Length": [ "225" ]
46+
}
47+
},
48+
"Response": {
49+
"StatusCode": 201,
50+
"Headers": {
51+
"Cache-Control": [ "no-cache" ],
52+
"Pragma": [ "no-cache" ],
53+
"ETag": [ "\"0100ff99-0000-1800-0000-5fe197720000\"" ],
54+
"x-ms-request-id": [ "5746c342-bc8e-4d3f-9e96-4f1088dd16bd" ],
55+
"Strict-Transport-Security": [ "max-age=31536000; includeSubDomains" ],
56+
"x-ms-ratelimit-remaining-subscription-writes": [ "1199" ],
57+
"x-ms-correlation-request-id": [ "164fe878-e220-4eba-989a-8a6508d75069" ],
58+
"x-ms-routing-request-id": [ "SOUTHEASTASIA:20201222T065132Z:164fe878-e220-4eba-989a-8a6508d75069" ],
59+
"X-Content-Type-Options": [ "nosniff" ],
60+
"Date": [ "Tue, 22 Dec 2020 06:51:32 GMT" ]
61+
},
62+
"ContentHeaders": {
63+
"Content-Length": [ "1069" ],
64+
"Content-Type": [ "application/json; charset=utf-8" ],
65+
"Expires": [ "-1" ]
66+
},
67+
"Content": "{\"id\":\"/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/youriBotService-rg-g0j9s3/providers/Microsoft.BotService/botServices/BotService-02le6b\",\"name\":\"BotService-02le6b\",\"type\":\"Microsoft.BotService/botServices\",\"etag\":\"\\\"0100ff99-0000-1800-0000-5fe197720000\\\"\",\"location\":\"global\",\"sku\":{\"name\":\"F0\"},\"kind\":\"bot\",\"tags\":{},\"properties\":{\"displayName\":\"BotService-02le6b\",\"description\":null,\"iconUrl\":\"https://docs.botframework.com/static/devportal/client/images/bot-framework-default.png\",\"endpoint\":\"\",\"msaAppId\":\"2d00693f-17b0-4b43-b850-1d3fb485272e\",\"developerAppInsightKey\":null,\"developerAppInsightsApplicationId\":null,\"luisAppIds\":[],\"endpointVersion\":\"3.0\",\"configuredChannels\":[\"webchat\"],\"enabledChannels\":[\"webchat\",\"directline\"],\"isDeveloperAppInsightsApiKeySet\":false,\"isStreamingSupported\":false,\"publishingCredentials\":null,\"parameters\":null,\"allSettings\":null,\"manifestUrl\":null,\"storageResourceId\":null,\"migrationToken\":null,\"isCmekEnabled\":false,\"cmekKeyVaultUrl\":null,\"cmekEncryptionStatus\":\"Off\",\"provisioningState\":\"Succeeded\"}}"
68+
}
3569
}
3670
}

src/BotService/test/New-AzBotService.Tests.ps1

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,16 @@ while(-not $mockingPath) {
1212
. ($mockingPath | Select-Object -First 1).FullName
1313

1414
Describe 'New-AzBotService' {
15-
It 'Registration' -skip {
16-
$NewApplication = New-AzApplicationInsights -ResourceGroupName $env.ResourceGroupName -Name $env.WebApplicationName1 -Location $env.Location
17-
$NewAzBot = New-AzBotService -ResourceGroupName $env.ResourceGroupName -Name $env.NewBotService1 -ApplicationId $NewApplication.AppId -Location $env.Location -Sku F0 -Description "description" -Registration
15+
It 'Registration' {
16+
$NewAzBot = New-AzBotService -ResourceGroupName $env.ResourceGroupName -Name $env.NewBotService1 -ApplicationId $env.WebApplication1 -Location $env.Location -Sku F0 -Description "description" -Registration
1817
$NewAzBot.Name | Should -Be $env.NewBotService1
1918
}
2019

2120
#this case use the cmdlet 'New-AzResourceGroupDeployment' and it is can not be recorded.
2221
It 'WebApp' -Skip {
23-
$NewApplication = New-AzApplicationInsights -ResourceGroupName $env.ResourceGroupName -Name $env.WebApplicationName2 -Location $env.Location
2422
$ApplicationSecret = ConvertTo-SecureString -String $env.Secret -Force -AsPlainText
2523
write-host $ApplicationSecret
26-
$NewAzBot = New-AzBotService -ResourceGroupName $env.ResourceGroupName -Name $env.NewBotService2 -ApplicationId $NewApplication.AppId -Location $env.Location -Sku F0 -Description "description" -ApplicationSecret $ApplicationSecret -Webapp
24+
$NewAzBot = New-AzBotService -ResourceGroupName $env.ResourceGroupName -Name $env.NewBotService2 -ApplicationId $env.WebApplication2 -Location $env.Location -Sku F0 -Description "description" -ApplicationSecret $ApplicationSecret -Webapp
2725
$NewAzBot.Name | Should -Be $env.NewBotService2
2826
}
2927
}

src/BotService/test/Publish-AzBotServiceApp.Tests.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ while(-not $mockingPath) {
1212
. ($mockingPath | Select-Object -First 1).FullName
1313

1414
Describe 'Publish-AzBotServiceApp' {
15-
It '__AllParameterSets' -skip {
15+
It '__AllParameterSets' -Skip {
1616
$PublishService = Publish-AzBotServiceApp -ResourceGroupName $env.ResourceGroupName -Name $env.NewBotService2 -CodeDir "./$($env.NewBotService2)"
1717
$PublishService.Name | Should -Be $env.NewBotService2
1818
}

src/BotService/test/env.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"Tenant": "72f988bf-86f1-41af-91ab-2d7cd011db47",
3-
"WebApplicationName2": "WebApplication-r5tseq",
4-
"WebApplicationName1": "WebApplication-prq7cs",
3+
"WebApplication2": "88527e5d-3cc9-4c64-905e-f6d4f59a45f3",
4+
"WebApplication1": "2d00693f-17b0-4b43-b850-1d3fb485272e",
55
"NewBotService1": "BotService-02le6b",
66
"SubscriptionId": "9e223dbe-3399-4e19-88eb-0975f02ac87f",
77
"ResourceGroupName": "youriBotService-rg-g0j9s3",

src/BotService/test/utils.ps1

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@ function setupEnv() {
1616
Import-Module Az.Resources
1717
Import-Module Az.Websites
1818
# For any resources you created for test, you should add it to $env here.
19-
$WebApplicationName1 = 'WebApplication-' + (RandomString -allChars $false -len 6)
20-
$WebApplicationName2 = 'WebApplication-' + (RandomString -allChars $false -len 6)
19+
$WebApplication1 = '2d00693f-17b0-4b43-b850-1d3fb485272e'
20+
$WebApplication2 = '88527e5d-3cc9-4c64-905e-f6d4f59a45f3'
2121
$NewBotService1 = 'BotService-' + (RandomString -allChars $false -len 6)
2222
$NewBotService2 = 'BotService-' + (RandomString -allChars $false -len 6)
2323

2424
$Secret = "youriSecret"
25-
$null = $env.Add('WebApplicationName1', $WebApplicationName1)
26-
$null = $env.Add('WebApplicationName2', $WebApplicationName2)
25+
$null = $env.Add('WebApplication1', $WebApplication1)
26+
$null = $env.Add('WebApplication2', $WebApplication2)
2727
$null = $env.Add('NewBotService1', $NewBotService1)
2828
$null = $env.Add('NewBotService2', $NewBotService2)
2929
$null = $env.Add('Secret', $Secret)

0 commit comments

Comments
 (0)