- Notifications
You must be signed in to change notification settings - Fork 301
Description
Port this change from botbuilder-dotnet/master branch:
microsoft/botbuilder-dotnet#3108
Proposed Changes
Add a new Functional test for SlackTestBot.
Details
- Add the new SlackClientTest to FunctionalTests project to test sending a message to the SlackTestBot deployed in Azure with ARM Templates and check its response.
- Update the
template-with-new-rg.json
and thetemplate-with-preexisting-rg.json
in the SlackTestBot to take the Slack credentials that will be used to deploy the bot on Azure. - Add the class SlackHistoryRetrieve to manage the retrieving of Slack Messages.
Steps to configure the Nightly Build Pipeline:
1- Define the following environment variables:
BotGroup: It's the name for the resource group.
SlackBotName: It's the name of the bot
SlackBotToken: It's the Bot User OAuth Access Token from the Slack App ( * )
SlackClientSigningSecret: It's the Signing Secret from the Slack App ( * )
SlackVerificationToken: It's the Verification Token from the Slack App ( * )
SlackChannel: It's the channel ID from the application
( * ) Mark these variables as secret.
2- A NETCore task to publish the SlackTestBot.
The arguments are:
--output $(System.DefaultWorkingDirectory)\tests\Adapters\Microsoft.Bot.Builder.Adapters.Slack.TestBot\PublishedBot --framework netcoreapp2.1
3- An Azure CLI task to create the resources in Azure and deploy the bot.
The inline script is the following:
call az deployment create --name "$(BotGroup)" --template-file "$(System.DefaultWorkingDirectory)\tests\Adapters\Microsoft.Bot.Builder.Adapters.Slack.TestBot\DeploymentTemplates\template-with-new-rg.json" --location "westus" --parameters appId="$(AppId)" appSecret="$(AppSecret)" botId="$(SlackBotName)" botSku=F0 newAppServicePlanName="$(SlackBotName)" newWebAppName="$(SlackBotName)" groupName="$(BotGroup)" groupLocation="westus" newAppServicePlanLocation="westus" slackVerificationToken="$(SlackVerificationToken)" slackBotToken="$(SlackBotToken)" slackClientSigningSecret="$(SlackClientSigningSecret)" call az webapp deployment source config-zip --resource-group "$(BotGroup)" --name "$(SlackBotName)" --src "$(System.DefaultWorkingDirectory)\tests\Adapters\Microsoft.Bot.Builder.Adapters.Slack.TestBot\PublishedBot\PublishedBot.zip"
4- A PowerShell task to set the environment variables needed to run the test
The script is:
echo '##vso[task.setvariable variable=SLACK_CHANNEL]$(SlackChannel)' echo '##vso[task.setvariable variable=SLACK_BOT_TOKEN]$(SlackBotToken)'
Finally, the new test will run with the rest of the functional tests and the bot should be deleted with the other resources deployed in the pipeline.
Note: As a pre-requisite, the SlackTestBot must be previously connected with a Slack App.