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

Make the OAuth APIs in .NET testable #1357

Merged
merged 4 commits into from
Feb 5, 2019
Merged

Conversation

Jeffders
Copy link
Member

@Jeffders Jeffders commented Feb 4, 2019

This PR includes a handful changes to make testing bots using the OAuth APIs and OAuthPrompt easier.

These include:

  1. Introduce the IUserTokenProvider interface which includes all of the OAuth APIs on the BotFrameworkAdapter
  2. Have BotFrameworkAdapter implement this interface
  3. Make all of these methods on BotFrameworkAdapter virtual (so they can be overridden by mock frameworks).
  4. Change OAuthPrompt to look for adapter's that implement IUserTokenProvider instead of BotFrameworkAdapter

Additionally, you can now write unit tests for your bot using the TestAdapter and TestFlow:

  1. TestAdapter includes a mock, in-memory implementation of IUserTokenProvider
  2. Added unit tests for this in-memory implementation
  3. Added unit tests for OAuthPrompt that test the entire login flow both with and without a magic code response.

@coveralls
Copy link
Collaborator

coveralls commented Feb 4, 2019

Pull Request Test Coverage Report for Build 48466

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • 54 unchanged lines in 1 file lost coverage.
  • Overall coverage increased (+2.7%) to 72.167%

Files with Coverage Reduction New Missed Lines %
/libraries/Microsoft.Bot.Builder/Adapters/TestAdapter.cs 54 79.86%
Totals Coverage Status
Change from base Build 48458: 2.7%
Covered Lines: 3744
Relevant Lines: 5188

💛 - Coveralls

Copy link
Contributor

@tomlm tomlm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

@tomlm
Copy link
Contributor

tomlm commented Feb 4, 2019

Hey jeff, can we make sure this is applied to js side too?

@cleemullins cleemullins merged commit ad33212 into master Feb 5, 2019
@cleemullins cleemullins deleted the jeffders/testOAuthApi branch February 5, 2019 01:51
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

4 participants