Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -132,25 +132,25 @@ private void GetEnvironmentVars()
_appSecret = Environment.GetEnvironmentVariable("FacebookTestBotFaceBookAppSecret");
if (string.IsNullOrWhiteSpace(_appSecret))
{
Assert.Inconclusive("Environment variable 'FacebookTestBotFaceBookAppSecret' not found.");
Assert.Fail("Environment variable 'FacebookTestBotFaceBookAppSecret' not found.");
}

_accessToken = Environment.GetEnvironmentVariable("FacebookTestBotFacebookAccessToken");
if (string.IsNullOrWhiteSpace(_accessToken))
{
Assert.Inconclusive("Environment variable 'FacebookTestBotFacebookAccessToken' not found.");
Assert.Fail("Environment variable 'FacebookTestBotFacebookAccessToken' not found.");
}

_botEndpoint = Environment.GetEnvironmentVariable("BOT_ENDPOINT");
if (string.IsNullOrWhiteSpace(_botEndpoint))
{
Assert.Inconclusive("Environment variable 'BOT_ENDPOINT' not found.");
Assert.Fail("Environment variable 'BOT_ENDPOINT' not found.");
}

_senderId = Environment.GetEnvironmentVariable("FacebookTestBotSenderId");
if (string.IsNullOrWhiteSpace(_senderId))
{
Assert.Inconclusive("Environment variable 'FacebookTestBotSenderId' not found.");
Assert.Fail("Environment variable 'FacebookTestBotSenderId' not found.");
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,41 +100,47 @@ private async Task RefreshAccessToken()

var httpResponse = await client.SendAsync(request);
var response = httpResponse.Content.ReadAsStringAsync().Result;
var kvPairs = JsonConvert.DeserializeObject<Dictionary<string, string>>(response);

_userAccessToken = kvPairs["access_token"];
if (httpResponse.StatusCode == HttpStatusCode.OK)
{
var kvPairs = JsonConvert.DeserializeObject<Dictionary<string, string>>(response);
_userAccessToken = kvPairs["access_token"];
}
else
{
throw new HttpRequestException($"RefreshAccessToken() failed: response = {response}");
}
}

private void GetEnvironmentVars()
{
_roomId = Environment.GetEnvironmentVariable("WebexTestBotWebexRoomId");
if (string.IsNullOrWhiteSpace(_roomId))
{
Assert.Inconclusive("Environment variable 'WebexTestBotWebexRoomId' not found.");
Assert.Fail("Environment variable 'WebexTestBotWebexRoomId' not found.");
}

_refreshToken = Environment.GetEnvironmentVariable("WebexTestBotRefreshToken");
if (string.IsNullOrWhiteSpace(_refreshToken))
{
Assert.Inconclusive("Environment variable 'WebexTestBotRefreshToken' not found.");
Assert.Fail("Environment variable 'WebexTestBotRefreshToken' not found.");
}

_integrationClientId = Environment.GetEnvironmentVariable("WebexTestBotWebexIntegrationClientId");
if (string.IsNullOrWhiteSpace(_integrationClientId))
{
Assert.Inconclusive("Environment variable 'WebexTestBotWebexIntegrationClientId' not found.");
Assert.Fail("Environment variable 'WebexTestBotWebexIntegrationClientId' not found.");
}

_integrationClientSecret = Environment.GetEnvironmentVariable("WebexTestBotWebexIntegrationClientSecret");
if (string.IsNullOrWhiteSpace(_integrationClientSecret))
{
Assert.Inconclusive("Environment variable 'WebexTestBotWebexIntegrationClientSecret' not found.");
Assert.Fail("Environment variable 'WebexTestBotWebexIntegrationClientSecret' not found.");
}

_targetBotEmail = Environment.GetEnvironmentVariable("WebexTestBotWebexBotUserName");
if (string.IsNullOrWhiteSpace(_targetBotEmail))
{
Assert.Inconclusive("Environment variable 'WebexTestBotWebexBotUserName' not found.");
Assert.Fail("Environment variable 'WebexTestBotWebexBotUserName' not found.");
}
}
}
Expand Down
33 changes: 15 additions & 18 deletions build/yaml/botbuilder-dotnet-ci-facebook-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,6 @@ variables:
# FacebookTestBotSenderId: define this in Azure?: This var not needed in build 156862. Revisit this after the build's test is fixed & running.

steps:
- powershell: |
# Set values in appsettings.json file.
$file = "$(Build.SourcesDirectory)\tests\Adapters\Microsoft.Bot.Builder.Adapters.Facebook.PrimaryTestBot\appsettings.json";

$content = Get-Content -Raw $file | ConvertFrom-Json;
$content.FacebookVerifyToken = "$(FacebookTestBotFacebookVerifyToken)";
$content.FacebookAppSecret = "$(FacebookTestBotFaceBookAppSecret)";
$content.FacebookAccessToken = "$(FacebookTestBotFacebookAccessToken)";
$content | ConvertTo-Json | Set-Content $file;
displayName: 'Set values in appsettings.json file.'

- template: ci-build-steps.yml

- task: DotNetCoreCLI@2
Expand All @@ -79,11 +68,11 @@ steps:
:: Comment out either Option 1 or Option 2 below. Ultimately, both templates should be exercised to ensure they continue to work.

:: Option 1: Use the "new-rg" template:
call az deployment sub 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="$(BotName)" botSku=F0 newAppServicePlanName="$(BotName)" newWebAppName="$(BotName)" groupName="$(BotGroup)" groupLocation="westus" newAppServicePlanLocation="westus" slackVerificationToken="$(SlackVerificationToken)" slackBotToken="$(SlackBotToken)" slackClientSigningSecret="$(SlackClientSigningSecret)"
::call az deployment sub 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="$(FacebookTestBotFacebookVerifyToken)" facebookAppSecret="$(FacebookTestBotFaceBookAppSecret)" facebookAccessToken="$(FacebookTestBotFacebookAccessToken)"

:: Option 2: Use the "preexisting-rg" template:
call az group create --location westus --name $(BotGroup)
call az deployment group create --resource-group "$(BotGroup)" --template-file "$(System.DefaultWorkingDirectory)\tests\Adapters\Microsoft.Bot.Builder.Adapters.Facebook.PrimaryTestBot\DeploymentTemplates\template-with-preexisting-rg.json" --parameters appId="$(AppId)" appSecret="$(AppSecret)" botId="$(BotName)" botSku=F0 newAppServicePlanName="$(BotName)" newWebAppName="$(BotName)" appServicePlanLocation="westus" facebookVerifyToken="verifyToken" facebookAppSecret="$(FacebookTestBotFaceBookAppSecret)" facebookAccessToken="$(FacebookTestBotFacebookAccessToken)" --name "$(BotName)"
call az deployment group create --resource-group "$(BotGroup)" --template-file "$(System.DefaultWorkingDirectory)\tests\Adapters\Microsoft.Bot.Builder.Adapters.Facebook.PrimaryTestBot\DeploymentTemplates\template-with-preexisting-rg.json" --parameters appId="$(AppId)" appSecret="$(AppSecret)" botId="$(BotName)" botSku=F0 newAppServicePlanName="$(BotName)" newWebAppName="$(BotName)" appServicePlanLocation="westus" facebookVerifyToken="$(FacebookTestBotFacebookVerifyToken)" facebookAppSecret="$(FacebookTestBotFaceBookAppSecret)" facebookAccessToken="$(FacebookTestBotFacebookAccessToken)" --name "$(BotName)"

- task: AzureCLI@1
displayName: 'Deploy the bot'
Expand All @@ -93,21 +82,29 @@ steps:
inlineScript: |
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"

- powershell: |
echo '##vso[task.setvariable variable=BOT_ENDPOINT]https://$(BotName).azurewebsites.net/api/messages'
displayName: 'Set BOT_ENDPOINT environment variable'

- task: DotNetCoreCLI@2
displayName: 'dotnet test'
inputs:
command: test
projects: '$(System.DefaultWorkingDirectory)\FunctionalTests\Microsoft.Bot.Builder.FunctionalTests\Microsoft.Bot.Builder.FunctionalTests.csproj'
arguments: '-v n --configuration $(BuildConfiguration) --no-build --no-restore --filter FacebookChatTest'
env:
BOT_ENDPOINT: https://$(BotName).azurewebsites.net/api/messages
FacebookTestBotFacebookAccessToken: $(FacebookTestBotFacebookAccessToken)
FacebookTestBotFacebookAppSecret: $(FacebookTestBotFacebookAppSecret)
FacebookTestBotSenderId: $(FacebookTestBotSenderId)

- task: AzureCLI@1
displayName: 'Delete Azure resources'
inputs:
azureSubscription: '$(AzureSubscription)'
scriptLocation: inlineScript
inlineScript: 'call az group delete -n "$(BotGroup)" --yes'
condition: and(always(), ne(variables['DeleteResourceGroup'], 'false'))
condition: and(always(), ne(variables['DeleteResourceGroup'], 'false'))

- script: |
cd ..
dir *.* /s
displayName: 'Dir workspace'
continueOnError: true
condition: succeededOrFailed()
18 changes: 9 additions & 9 deletions build/yaml/botbuilder-dotnet-ci-webex-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ variables:
# WebexTestBotBotGroup: define this in Azure
# WebexTestBotBotName: define this in Azure
# WebexTestBotRefreshToken: define this in Azure
# WebexTestBotWebexBotAccessToken: define this in Azure
# WebexTestBotWebexBotAccessToken: define this in Azure. Expires in 90 days, i.e. Sunday, November 15, 2020
# WebexTestBotWebexBotUserName: define this in Azure
# WebexTestBotWebexIntegrationClientId: define this in Azure
# WebexTestBotWebexIntegrationClientSecret: define this in Azure
Expand Down Expand Up @@ -87,21 +87,14 @@ steps:
inlineScript: |
call az webapp deployment source config-zip --resource-group "$(BotGroup)" --name "$(BotName)" --src "$(System.DefaultWorkingDirectory)\tests\Adapters\Microsoft.Bot.Builder.Adapters.Webex.TestBot\PublishedBot\PublishedBot.zip"

- task: AzureCLI@1
displayName: 'Zip Deploy Bot'
inputs:
azureSubscription: '$(AzureSubscription)'
scriptLocation: inlineScript
inlineScript: 'call az webapp deployment source config-zip --resource-group "$(BotGroup)" --name "$(BotName)" --src "$(System.DefaultWorkingDirectory)\tests\Adapters\Microsoft.Bot.Builder.Adapters.Webex.TestBot\PublishedBot\PublishedBot.zip"'

- task: DotNetCoreCLI@2
displayName: 'dotnet test'
inputs:
command: test
projects: 'FunctionalTests\Microsoft.Bot.Builder.FunctionalTests\Microsoft.Bot.Builder.FunctionalTests.csproj'
arguments: '-v n --configuration $(BuildConfiguration) --no-build --no-restore --filter WebexClientTest'
env:
XXXWebexTestBotWebexRoomId: $(WebexTestBotWebexRoomId)
WebexTestBotWebexRoomId: $(WebexTestBotWebexRoomId)
WebexTestBotRefreshToken: $(WebexTestBotRefreshToken)
WebexTestBotWebexIntegrationClientId: $(WebexTestBotWebexIntegrationClientId)
WebexTestBotWebexIntegrationClientSecret: $(WebexTestBotWebexIntegrationClientSecret)
Expand All @@ -114,3 +107,10 @@ steps:
scriptLocation: inlineScript
inlineScript: 'call az group delete -n "$(BotGroup)" --yes'
condition: and(always(), ne(variables['DeleteResourceGroup'], 'false'))

- script: |
cd ..
dir *.* /s
displayName: 'Dir workspace'
continueOnError: true
condition: succeededOrFailed()