This project has moved and is read-only. For the latest updates, please go here.

How can I unit test OAuth2 authentication on Web API using Microsoft.Owin.Testing?

Oct 30, 2015 at 10:32 PM
Edited Oct 30, 2015 at 10:32 PM

I have this VS solution setup:
| -- WebApiProject
| -- UnitTestProject
I have installed the Microsoft.Owin.Diagnostics and Microsoft.Owin.Testing NuGet packages.

Now I want to test internal and external authentication using this set-up. How can I do this?

I have been googling this but can't find any documentation on how to apply TestServer here.

Thank you for enlightening me.
Nov 4, 2015 at 1:01 AM
Which OAuth2 components are you trying to test?
Nov 4, 2015 at 11:05 AM
Edited Nov 4, 2015 at 11:06 AM
At this time of reading I don't have the slightest idea as I'm right at the beginning of learning authentication with Web API. There is plenty of documentation for MVC but Web API doesn't even provide comments in the code. So I'm still striving for information.

Having some unit test I could create/use to see whether I'm following the right path (particularly in regard to expired tokens and using Refresh tokens) would be very helpful.
Nov 4, 2015 at 5:43 PM
Unit tests are for individual components, not entire applications flows.

This may help you get started:
Nov 6, 2015 at 1:57 AM
Yes, I know. But that's not the question. The question is: How can I unit test a Web API endpoint from a separate unit test project?
Nov 6, 2015 at 6:42 PM
Nov 7, 2015 at 2:40 PM
That doesn't work with testing OAuth authentication.

Do you know about this framework:
Nov 7, 2015 at 3:21 PM
Nov 7, 2015 at 4:45 PM
Exactly. And this project is my question about.
Nov 9, 2015 at 8:31 PM
Nov 9, 2015 at 11:06 PM
Would you mind just concentrating on my question or leave it to someone else to answer?