Set up Facebook functional test key vault variables (#3505)

* Set up key vault variables

* Normalize vars

* Add delete resource conditional var

* Fix BotName var
This commit is contained in:
Eric Dahlvang 2020-03-05 15:44:30 -08:00 коммит произвёл GitHub
Родитель b3cf355537
Коммит 0833051494
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
2 изменённых файлов: 24 добавлений и 27 удалений

Просмотреть файл

@ -129,16 +129,16 @@ namespace Microsoft.Bot.Builder.FunctionalTests
{
if (string.IsNullOrWhiteSpace(_appSecret) || string.IsNullOrWhiteSpace(_accessToken) || string.IsNullOrWhiteSpace(_botEndpoint) || string.IsNullOrWhiteSpace(_senderId))
{
_appSecret = Environment.GetEnvironmentVariable("FACEBOOK_APP_SECRET");
_appSecret = Environment.GetEnvironmentVariable("FacebookTestBotFaceBookAppSecret");
if (string.IsNullOrWhiteSpace(_appSecret))
{
Assert.Inconclusive("Environment variable 'FACEBOOK_APP_SECRET' not found.");
Assert.Inconclusive("Environment variable 'FacebookTestBotFaceBookAppSecret' not found.");
}
_accessToken = Environment.GetEnvironmentVariable("FACEBOOK_ACCESS_TOKEN");
_accessToken = Environment.GetEnvironmentVariable("FacebookTestBotFacebookAccessToken");
if (string.IsNullOrWhiteSpace(_accessToken))
{
Assert.Inconclusive("Environment variable 'FACEBOOK_ACCESS_TOKEN' not found.");
Assert.Inconclusive("Environment variable 'FacebookTestBotFacebookAccessToken' not found.");
}
_botEndpoint = Environment.GetEnvironmentVariable("BOT_ENDPOINT");
@ -147,10 +147,10 @@ namespace Microsoft.Bot.Builder.FunctionalTests
Assert.Inconclusive("Environment variable 'BOT_ENDPOINT' not found.");
}
_senderId = Environment.GetEnvironmentVariable("SENDER_ID");
_senderId = Environment.GetEnvironmentVariable("FacebookTestBotSenderId");
if (string.IsNullOrWhiteSpace(_senderId))
{
Assert.Inconclusive("Environment variable 'SENDER_ID' not found.");
Assert.Inconclusive("Environment variable 'FacebookTestBotSenderId' not found.");
}
}
}

Просмотреть файл

@ -13,15 +13,16 @@ variables:
BuildPlatform: 'any cpu'
BuildConfiguration: 'debug'
Parameters.solution: Microsoft.Bot.Builder.sln
# AppId: define this in Azure
# AppSecret: define this in Azure
# FacebookTestBotAppId: define this in Azure
# FacebookTestBotAppSecret: define this in Azure
# AzureSubscription: define this in Azure
# BotGroup: define this in Azure
# BotName: define this in Azure
# FacebookAccessToken: define this in Azure
# FacebookAppSecret: define this in Azure
# FacebookVerifyToken: define this in Azure
# SenderId: define this in Azure
# DeleteResourceGroup: (optional) define this in Azure. Default = true.
# FacebookTestBotBotGroup: define this in Azure
# FacebookTestBotBotName: define this in Azure
# FacebookTestBotFacebookAccessToken: define this in Azure
# FacebookTestBotFacebookAppSecret: define this in Azure
# FacebookTestBotFacebookVerifyToken: define this in Azure
# FacebookTestBotSenderId: define this in Azure
steps:
- powershell: |
@ -29,9 +30,9 @@ steps:
$file = "$(Build.SourcesDirectory)\tests\Adapters\Microsoft.Bot.Builder.Adapters.Facebook.PrimaryTestBot\appsettings.json";
$content = Get-Content -Raw $file | ConvertFrom-Json;
$content.FacebookVerifyToken = "$(FacebookVerifyToken)";
$content.FacebookAppSecret = "$(FacebookAppSecret)";
$content.FacebookAccessToken = "$(FacebookAccessToken)";
$content.FacebookVerifyToken = "$(FacebookTestBotFacebookVerifyToken)";
$content.FacebookAppSecret = "$(FacebookTestBotFaceBookAppSecret)";
$content.FacebookAccessToken = "$(FacebookTestBotFacebookAccessToken)";
$content | ConvertTo-Json | Set-Content $file;
displayName: 'Set values in appsettings.json file.'
@ -52,15 +53,12 @@ steps:
azureSubscription: '$(AzureSubscription)'
scriptLocation: inlineScript
inlineScript: |
call az deployment create --name "$(BotGroup)" --template-file "$(System.DefaultWorkingDirectory)\tests\Adapters\Microsoft.Bot.Builder.Adapters.Facebook.PrimaryTestBot\DeploymentTemplates\template-with-new-rg.json" --location "westus" --parameters appId="$(AppId)" appSecret="$(AppSecret)" botId="$(BotName)" botSku=F0 newAppServicePlanName="$(BotName)" newWebAppName="$(BotName)" groupName="$(BotGroup)" groupLocation="westus" newAppServicePlanLocation="westus" facebookVerifyToken="verifyToken" facebookAppSecret="$(FacebookAppSecret)" facebookAccessToken="$(FacebookAccessToken)"
call az webapp deployment source config-zip --resource-group "$(BotGroup)" --name "$(BotName)" --src "$(System.DefaultWorkingDirectory)\tests\Adapters\Microsoft.Bot.Builder.Adapters.Facebook.PrimaryTestBot\PublishedBot\PublishedBot.zip"
call az deployment create --name "$(FacebookTestBotBotGroup)" --template-file "$(System.DefaultWorkingDirectory)\tests\Adapters\Microsoft.Bot.Builder.Adapters.Facebook.PrimaryTestBot\DeploymentTemplates\template-with-new-rg.json" --location "westus" --parameters appId="$(AppId)" appSecret="$(FacebookTestBotAppSecret)" botId="$(FacebookTestBotBotName)" botSku=F0 newAppServicePlanName="$(FacebookTestBotBotName)" newWebAppName="$(FacebookTestBotBotName)" groupName="$(FacebookTestBotBotGroup)" groupLocation="westus" newAppServicePlanLocation="westus" facebookVerifyToken="verifyToken" facebookAppSecret="$(FacebookTestBotFaceBookAppSecret)" facebookAccessToken="$(FacebookTestBotFacebookAccessToken)"
call az webapp deployment source config-zip --resource-group "$(FacebookTestBotBotGroup)" --name "$(FacebookTestBotBotName)" --src "$(System.DefaultWorkingDirectory)\tests\Adapters\Microsoft.Bot.Builder.Adapters.Facebook.PrimaryTestBot\PublishedBot\PublishedBot.zip"
- powershell: |
echo '##vso[task.setvariable variable=FACEBOOK_ACCESS_TOKEN]$(FacebookAccessToken)'
echo '##vso[task.setvariable variable=FACEBOOK_APP_SECRET]$(FacebookAppSecret)'
echo '##vso[task.setvariable variable=BOT_ENDPOINT]https://$(BotName).azurewebsites.net/api/messages'
echo '##vso[task.setvariable variable=SENDER_ID]$(SenderId)'
displayName: 'Set environment variables'
echo '##vso[task.setvariable variable=BOT_ENDPOINT]https://$(FacebookTestBotBotName).azurewebsites.net/api/messages'
displayName: 'Set BOT_ENDPOINT environment variable'
- task: DotNetCoreCLI@2
displayName: 'dotnet test'
@ -74,6 +72,5 @@ steps:
inputs:
azureSubscription: '$(AzureSubscription)'
scriptLocation: inlineScript
inlineScript: 'call az group delete -n "$(BotGroup)" --yes'
condition: always()
enabled: true
inlineScript: 'call az group delete -n "$(FacebookTestBotBotGroup)" --yes'
condition: and(always(), ne(variables['DeleteResourceGroup'], 'false'))