Skip to content

Fix cases and utils script for 'BotService' #13813

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Dec 23, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/BotService/custom/New-AzBotService.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,9 @@ function New-AzBotService {
Write-Error $NameAvailabilityResponse.Message
throw
}
if ($PSBoundParameters.ContainsKey('SubscriptionId')) {
$EnvPSBoundParameters['SubscriptionId'] = [System.String]$SubscriptionId
}
if ($BotKind -eq $Kind)
{
if (-not $PSBoundParameters.ContainsKey('DisplayName'))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ while(-not $mockingPath) {
. ($mockingPath | Select-Object -First 1).FullName

Describe 'Initialize-AzBotServicePrepareDeploy' {
It '__AllParameterSets' -skip {
# Join-Path $PSScriptRoot 'resources\MyEchoBot'
It '__AllParameterSets' -Skip {
Initialize-AzBotServicePrepareDeploy -CodeDir $env.NewBotService2 -ProjFileName EchoBot.csproj
$IsExit = Test-Path "$($env.NewBotService2)\.deployment"
$IsExit | Should -Be $True
Expand Down
46 changes: 40 additions & 6 deletions src/BotService/test/New-AzBotService.Recording.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"New-AzBotService+[NoContext]+WebApp+$POST+https://management.azure.com/providers/Microsoft.BotService/checkNameAvailability?api-version=2018-07-12+1": {
"New-AzBotService+[NoContext]+Registration+$POST+https://management.azure.com/providers/Microsoft.BotService/checkNameAvailability?api-version=2018-07-12+1": {
"Request": {
"Method": "POST",
"RequestUri": "https://management.azure.com/providers/Microsoft.BotService/checkNameAvailability?api-version=2018-07-12",
"Content": "{\r\n \"name\": \"BotService-v5kgny\",\r\n \"type\": \"sdk\"\r\n}",
"Content": "{\r\n \"name\": \"BotService-02le6b\",\r\n \"type\": \"bot\"\r\n}",
"Headers": {
},
"ContentHeaders": {
Expand All @@ -19,11 +19,11 @@
"Vary": [ "Accept-Encoding" ],
"x-ms-ratelimit-remaining-tenant-writes": [ "1199" ],
"Strict-Transport-Security": [ "max-age=31536000; includeSubDomains" ],
"x-ms-request-id": [ "c1582637-c843-4584-b09b-d7df1984c07d" ],
"x-ms-correlation-request-id": [ "c1582637-c843-4584-b09b-d7df1984c07d" ],
"x-ms-routing-request-id": [ "SOUTHEASTASIA:20201216T123323Z:c1582637-c843-4584-b09b-d7df1984c07d" ],
"x-ms-request-id": [ "196a3fb6-347e-4f44-8b02-ace52a682398" ],
"x-ms-correlation-request-id": [ "196a3fb6-347e-4f44-8b02-ace52a682398" ],
"x-ms-routing-request-id": [ "SOUTHEASTASIA:20201222T065124Z:196a3fb6-347e-4f44-8b02-ace52a682398" ],
"X-Content-Type-Options": [ "nosniff" ],
"Date": [ "Wed, 16 Dec 2020 12:33:23 GMT" ]
"Date": [ "Tue, 22 Dec 2020 06:51:24 GMT" ]
},
"ContentHeaders": {
"Content-Length": [ "42" ],
Expand All @@ -32,5 +32,39 @@
},
"Content": "{\"valid\":true,\"message\":\"\",\"absCode\":null}"
}
},
"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": {
"Request": {
"Method": "PUT",
"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",
"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}",
"Headers": {
},
"ContentHeaders": {
"Content-Type": [ "application/json" ],
"Content-Length": [ "225" ]
}
},
"Response": {
"StatusCode": 201,
"Headers": {
"Cache-Control": [ "no-cache" ],
"Pragma": [ "no-cache" ],
"ETag": [ "\"0100ff99-0000-1800-0000-5fe197720000\"" ],
"x-ms-request-id": [ "5746c342-bc8e-4d3f-9e96-4f1088dd16bd" ],
"Strict-Transport-Security": [ "max-age=31536000; includeSubDomains" ],
"x-ms-ratelimit-remaining-subscription-writes": [ "1199" ],
"x-ms-correlation-request-id": [ "164fe878-e220-4eba-989a-8a6508d75069" ],
"x-ms-routing-request-id": [ "SOUTHEASTASIA:20201222T065132Z:164fe878-e220-4eba-989a-8a6508d75069" ],
"X-Content-Type-Options": [ "nosniff" ],
"Date": [ "Tue, 22 Dec 2020 06:51:32 GMT" ]
},
"ContentHeaders": {
"Content-Length": [ "1069" ],
"Content-Type": [ "application/json; charset=utf-8" ],
"Expires": [ "-1" ]
},
"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\"}}"
}
}
}
8 changes: 3 additions & 5 deletions src/BotService/test/New-AzBotService.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,16 @@ while(-not $mockingPath) {
. ($mockingPath | Select-Object -First 1).FullName

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

#this case use the cmdlet 'New-AzResourceGroupDeployment' and it is can not be recorded.
It 'WebApp' -Skip {
$NewApplication = New-AzApplicationInsights -ResourceGroupName $env.ResourceGroupName -Name $env.WebApplicationName2 -Location $env.Location
$ApplicationSecret = ConvertTo-SecureString -String $env.Secret -Force -AsPlainText
write-host $ApplicationSecret
$NewAzBot = New-AzBotService -ResourceGroupName $env.ResourceGroupName -Name $env.NewBotService2 -ApplicationId $NewApplication.AppId -Location $env.Location -Sku F0 -Description "description" -ApplicationSecret $ApplicationSecret -Webapp
$NewAzBot = New-AzBotService -ResourceGroupName $env.ResourceGroupName -Name $env.NewBotService2 -ApplicationId $env.WebApplication2 -Location $env.Location -Sku F0 -Description "description" -ApplicationSecret $ApplicationSecret -Webapp
$NewAzBot.Name | Should -Be $env.NewBotService2
}
}
2 changes: 1 addition & 1 deletion src/BotService/test/Publish-AzBotServiceApp.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ while(-not $mockingPath) {
. ($mockingPath | Select-Object -First 1).FullName

Describe 'Publish-AzBotServiceApp' {
It '__AllParameterSets' -skip {
It '__AllParameterSets' -Skip {
$PublishService = Publish-AzBotServiceApp -ResourceGroupName $env.ResourceGroupName -Name $env.NewBotService2 -CodeDir "./$($env.NewBotService2)"
$PublishService.Name | Should -Be $env.NewBotService2
}
Expand Down
4 changes: 2 additions & 2 deletions src/BotService/test/env.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"Tenant": "72f988bf-86f1-41af-91ab-2d7cd011db47",
"WebApplicationName2": "WebApplication-r5tseq",
"WebApplicationName1": "WebApplication-prq7cs",
"WebApplication2": "88527e5d-3cc9-4c64-905e-f6d4f59a45f3",
"WebApplication1": "2d00693f-17b0-4b43-b850-1d3fb485272e",
"NewBotService1": "BotService-02le6b",
"SubscriptionId": "9e223dbe-3399-4e19-88eb-0975f02ac87f",
"ResourceGroupName": "youriBotService-rg-g0j9s3",
Expand Down
8 changes: 4 additions & 4 deletions src/BotService/test/utils.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ function setupEnv() {
Import-Module Az.Resources
Import-Module Az.Websites
# For any resources you created for test, you should add it to $env here.
$WebApplicationName1 = 'WebApplication-' + (RandomString -allChars $false -len 6)
$WebApplicationName2 = 'WebApplication-' + (RandomString -allChars $false -len 6)
$WebApplication1 = '2d00693f-17b0-4b43-b850-1d3fb485272e'
$WebApplication2 = '88527e5d-3cc9-4c64-905e-f6d4f59a45f3'
$NewBotService1 = 'BotService-' + (RandomString -allChars $false -len 6)
$NewBotService2 = 'BotService-' + (RandomString -allChars $false -len 6)

$Secret = "youriSecret"
$null = $env.Add('WebApplicationName1', $WebApplicationName1)
$null = $env.Add('WebApplicationName2', $WebApplicationName2)
$null = $env.Add('WebApplication1', $WebApplication1)
$null = $env.Add('WebApplication2', $WebApplication2)
$null = $env.Add('NewBotService1', $NewBotService1)
$null = $env.Add('NewBotService2', $NewBotService2)
$null = $env.Add('Secret', $Secret)
Expand Down