Skip to content

Instantly share code, notes, and snippets.

@skinny
Created May 3, 2012 20:11
Show Gist options
  • Save skinny/2588933 to your computer and use it in GitHub Desktop.
Save skinny/2588933 to your computer and use it in GitHub Desktop.
[Fact]
public void Should_return_unauthorized_response_for_route_based_authentication()
{
var module = new FakeHookedModule(new BeforePipeline());
module.Get["/public"] = _ =>
{
return HttpStatusCode.OK;
};
module.Get["/secure"] = _ =>
{
module.RequiresAuthenticationForAction();
return HttpStatusCode.OK;
};
var getContext = new NancyContext { Request = new Request("GET", "/public", "http") };
var result = module.Before.Invoke(getContext);
result.ShouldBeNull();
getContext = new NancyContext { Request = new Request("GET", "/secure", "http") };
result = module.Before.Invoke(getContext);
result.ShouldNotBeNull();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment