NancyFx / Nancy.MSOwinSecurity

Nancy Owin Security integration
MIT License
30 stars 14 forks source link

Sample Calling Test #4

Closed galenp closed 10 years ago

galenp commented 10 years ago

Hi Damian

Are you able to provide a demonstration of performing a test to a nancy module secured with this.RequiresMSOwinAuthentication();

Specifically what's the approach to tell Owin that this is an authorised request.

I'm currently using the following:

[Test]
public void Test_GET_Index()
{  
  var response = Browser.Get(baseUrl, with =>
  {
      with.Header("Authorization", Token);
      with.Header("Accept", "application/json");
      with.HttpRequest();
  });

  response.StatusCode.Should().Be(HttpStatusCode.OK);        
}

Where "Token" is a valid encoded Access Token. I suspect there is some missing Katana/Owin plumbing required that validates the request.

Thanks

galenp commented 10 years ago

To clarify... my nancy api is sitting inside an app that is using ThinkTecture IdentityServer for tokens. When fully wired up I have an authenticated end-user submitting requests with a valid token.

With this package I am able to use this.RequiresMSOwinAuthentication(); and pull the user up in Nancy.... everything works nice.

However im trying to write a small integration test where I'm manually sending the request and I'm not entirely sure of the complete set up of plumbing required I guess to emulate the MsOwin/Token authentication conditions.

Thanks