Skip to content
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

[Webex Adapter] Add Webex Functional Test and YAML File #3257

Merged
merged 11 commits into from
Jan 29, 2020

Conversation

matiasroldan6
Copy link
Contributor

@matiasroldan6 matiasroldan6 commented Jan 14, 2020

Description

This pull request adds a YAML file to set up a build pipeline for Webex Functional Test.

Changes made

We added the file botbuilder-dotnet-ci-webextest.yml inside the build/yaml folder.

Variables Summary

This is a summary of the variables you will need to get before setting up the Azure pipeline

Name Source Description
AppId* App Registration Portal The Application (client) ID of the App Registration.
AppSecret* App Registration Portal The secret’s value from the table under Client secrets of the App Registration
WebexBotAccessToken* Create a Bot in Webex Section The bot's access token obtained when it was created
WebexBotUserName Create a Bot in Webex Section The Bot Username (in format @webex.bot) that identifies the Webex bot
WebexRoomId* Get Room ID Section The roomId to talk with the Webex Bot
RefreshToken* Get Refresh Token Section The Refresh token from the Webex OAuth Integration App
WebexIntegrationClientId Create Integration Section The Client ID from the Webex Integration App
WebexIntegrationClientSecret* Create Integration Section The Client Secret from the Webex Integration App
AzureSubscription User The name of the Azure Resource Manager service connection configured in the pipeline
WebexWebhookName Create a Webhook Section The name you want for the Webhook
WebexWebhookSecret* Create a Webhook Section A secret string to secure the communications
BotName User The Bot name
BotGroup User The Resource Group name

Setting Up

The next steps will guide you through the configuration of a Build pipeline based on the YAML files.

Prerequisites

  • Azure DevOps organization.
  • Azure subscription. Required to create and delete Azure resources.
  • One App Registration in Azure. You can create one using the portal here
  • An Azure Resource Manager service connection configured for the DevOps project.
  • Postman API tool.

Create a Bot in Webex

  1. Go to Webex Developer portal, log in with a Webex developer account.

  2. Go to Start Building Apps -> Create a New App -> Create a Bot

  3. Complete the fields and click the Add Bot button.
    image

    Once created, it will display the Bot's Access token and Bot ID values.
    image

    Variables Outcome

    Name Value
    WebexBotAccessToken* Bot's Access token
    WebexBotUserName Bot UserName

Get Room ID

With the Bot Username value set in the section before, we will create a Room Id using the Webex Message API documentation.

  1. Go to the Webex Message API documentation, log in with a Webex developer account.

  2. In the Try It section, complete the fields:

    • toPersonEmail: Bot Username in format @webex.bot

    • text: Create Room Id

  3. Click on Run to get the Room Id value from the API JSON response.

    image

  4. Get the Room Id value from the API JSON response.

    image

    Variables Outcome

    Name Value
    WebexRoomId* roomId

Create Integration

  1. Go to the Webex Developer portal, log in with a Webex developer account.

  2. Go to Start Building Apps -> Create a New App -> Create an Integration

  3. Complete the following fields:

    • Integration Name: Name for the Integration App
    • Contact Email: Email to be notified
    • Icon: Default icon
    • Description: Short description for the Integration App
    • RedirectUri(s): Valid URL https://[url] to be redirected
    • Scopes : spark:all

    image

  4. Click the Add Integration button to create the Webex Integration App.

    image

    Variables Outcome

    Name Value
    WebexIntegrationClientId Client ID
    WebexIntegrationClientSecret* Client Secret

Get Refresh Token

With the Integration Client ID and the Integration Client Secret values obtained in the section before, we will get a refresh token. This allows to us setup an authorization token for the functional test that will not expire.

  1. Go to the Webex Developer My Apps portal, log in with a Webex developer account.

  2. Select the Integration App created before.

  3. Open the OAuth Authorization URL using a web browser, It will take you to the URL you set as a RedirectUri(s). In the address bar you will see:
    http://[YOUR_REDIRECT_URL]/?code=[CODE].

    image

  4. Make a POST request to https://api.ciscospark.com/v1/access_token with the next values:

    We are using Postman Tool. You can get it here

    • content type: x-www-form-urlencoded
    • grant_type (Set it to authorization_code)
    • client_id (Add the Client ID of the Webex Integration App)
    • client_secret (Add the Client Secret of the Webex Integration App)
    • code (The authorization code from the previous step. ex: [CODE])
    • redirect_uri (Must match the one used in the RedirectUri(s) set in the Webex Integration App)

    image

    While the access_token will be valid for 90 days, we don't need to wait that long to request a new access token. The functional test will requests a new access token (using the provided refresh_token) every time it runs.

    Variables Outcome

    Name Value
    RefreshToken* refresh_token

Create a Webhook

To connect the functional test with Webex, we need to create a Webhook.

  1. Go to the Webex Create WebHook API documentation, log in with a Webex developer account.

  2. In the Try It section, complete the following fields:

    • name: Name for the Webhook
    • targetUrl: Replace the BotName value with the one used in the Azure pipeline variables https://<BotName>.azurewebsites.net/api/messages
    • resource: messages
    • event: created
    • secret: Secret string to secure the communications
  3. Click on Run to create the Webex Webhook

image

Variables Outcome

Name Value
WebexWebhookName Webhook Name
WebexWebhookSecret* Webhook Secret

Set up a build pipeline

  1. Create a new build pipeline. Then, select the Use classic editor option.
    image

  2. Configure the repository and branch. Then, in the configuration as code, click on Apply for the YAML file option.
    image

  3. In section YAML, write the build name and select the build YAML file inside the folder build/yaml in the root of the directory.
    image

Setup variables

The following are the variables we need to add to the pipeline. It is a good idea to prefix their names with "Webex" or something to make them more relatable to Webex, since more than one set of functional tests may be running in the same pipeline.

*Set these variables as private.

Name Source Description
AppId* App Registration Portal The Application (client) ID of the App Registration.
AppSecret* App Registration Portal The secret’s value from the table under Client secrets of the App Registration
WebexBotAccessToken* Create a Bot in Webex Section The bot's access token obtained when it was created
WebexBotUserName Create a Bot in Webex Section The Bot Username (in format @webex.bot) that identifies the Webex bot
WebexRoomId* Get Room ID Section The roomId to talk with the Webex Bot
RefreshToken* Get Refresh Token Section The Refresh token from the Webex OAuth Integration App
WebexIntegrationClientId Create Integration Section The Client ID from the Webex Integration App
WebexIntegrationClientSecret* Create Integration Section The Client Secret from the Webex Integration App
AzureSubscription User The name of the Azure Resource Manager service connection configured in the pipeline
WebexWebhookName Create a Webhook Section The name you want for the Webhook
WebexWebhookSecret* Create a Webhook Section A secret string to secure the communications
BotName User The Bot name
BotGroup User The Resource Group name

@coveralls
Copy link
Collaborator

coveralls commented Jan 14, 2020

Pull Request Test Coverage Report for Build 102396

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • 10 unchanged lines in 8 files lost coverage.
  • Overall coverage increased (+1.4%) to 79.63%

Files with Coverage Reduction New Missed Lines %
/libraries/Microsoft.Bot.Builder.Dialogs/ObjectPath.cs 1 86.46%
/libraries/Microsoft.Bot.Builder.Dialogs/Prompts/OAuthPrompt.cs 1 56.4%
/libraries/Microsoft.Bot.Builder/Inspection/InspectionMiddleware.cs 1 78.89%
/libraries/Microsoft.Bot.Expressions/BuiltInFunctions.cs 1 93.12%
/libraries/Microsoft.Bot.Expressions/LRUCache.cs 1 82.93%
/libraries/Microsoft.Bot.Expressions/TriggerTrees/Trigger.cs 1 85.09%
/libraries/Microsoft.Bot.Builder.Azure/CosmosDbStorageOptions.cs 2 75.0%
/libraries/Microsoft.Bot.Builder/MemoryTranscriptStore.cs 2 86.09%
Totals Coverage Status
Change from base Build 102391: 1.4%
Covered Lines: 10836
Relevant Lines: 13608

💛 - Coveralls

@fuselabs
Copy link
Collaborator

✔️ No Binary Compatibility issues for Microsoft.Bot.Builder.dll compared against version 4.6.3
✔️ No Binary Compatibility issues for Microsoft.Bot.Builder.AI.Luis.dll compared against version 4.6.3
✔️ No Binary Compatibility issues for Microsoft.Bot.Builder.AI.QnA.dll compared against version 4.6.3
✔️ No Binary Compatibility issues for Microsoft.Bot.Builder.ApplicationInsights.dll compared against version 4.6.3
✔️ No Binary Compatibility issues for Microsoft.Bot.Builder.Azure.dll compared against version 4.6.3
✔️ No Binary Compatibility issues for Microsoft.Bot.Builder.Dialogs.dll compared against version 4.6.3
✔️ No Binary Compatibility issues for Microsoft.Bot.Builder.Integration.ApplicationInsights.Core.dll compared against version 4.6.3
✔️ No Binary Compatibility issues for Microsoft.Bot.Builder.Integration.AspNet.Core.dll compared against version 4.6.3
✔️ No Binary Compatibility issues for Microsoft.Bot.Builder.TemplateManager.dll compared against version 4.6.3
✔️ No Binary Compatibility issues for Microsoft.Bot.Builder.Testing.dll compared against version 4.6.3
✔️ No Binary Compatibility issues for Microsoft.Bot.Configuration.dll compared against version 4.6.3
✔️ No Binary Compatibility issues for Microsoft.Bot.Connector.dll compared against version 4.6.3
✔️ No Binary Compatibility issues for Microsoft.Bot.Schema.dll compared against version 4.6.3
✔️ No Binary Compatibility issues for Microsoft.Bot.Streaming.dll compared against version 4.6.3

@fuselabs
Copy link
Collaborator

✔️ No Binary Compatibility issues for Microsoft.Bot.Builder.dll compared against version 4.6.3
✔️ No Binary Compatibility issues for Microsoft.Bot.Builder.AI.Luis.dll compared against version 4.6.3
✔️ No Binary Compatibility issues for Microsoft.Bot.Builder.AI.QnA.dll compared against version 4.6.3
✔️ No Binary Compatibility issues for Microsoft.Bot.Builder.ApplicationInsights.dll compared against version 4.6.3
✔️ No Binary Compatibility issues for Microsoft.Bot.Builder.Azure.dll compared against version 4.6.3
✔️ No Binary Compatibility issues for Microsoft.Bot.Builder.Dialogs.dll compared against version 4.6.3
✔️ No Binary Compatibility issues for Microsoft.Bot.Builder.Integration.ApplicationInsights.Core.dll compared against version 4.6.3
✔️ No Binary Compatibility issues for Microsoft.Bot.Builder.Integration.AspNet.Core.dll compared against version 4.6.3
✔️ No Binary Compatibility issues for Microsoft.Bot.Builder.TemplateManager.dll compared against version 4.6.3
✔️ No Binary Compatibility issues for Microsoft.Bot.Builder.Testing.dll compared against version 4.6.3
✔️ No Binary Compatibility issues for Microsoft.Bot.Configuration.dll compared against version 4.6.3
✔️ No Binary Compatibility issues for Microsoft.Bot.Connector.dll compared against version 4.6.3
✔️ No Binary Compatibility issues for Microsoft.Bot.Schema.dll compared against version 4.6.3
✔️ No Binary Compatibility issues for Microsoft.Bot.Streaming.dll compared against version 4.6.3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants