本文整理汇总了C#中Nancy.Tests.Fakes.FakeHookedModule.RequiresAuthentication方法的典型用法代码示例。如果您正苦于以下问题:C# FakeHookedModule.RequiresAuthentication方法的具体用法?C# FakeHookedModule.RequiresAuthentication怎么用?C# FakeHookedModule.RequiresAuthentication使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Nancy.Tests.Fakes.FakeHookedModule
的用法示例。
在下文中一共展示了FakeHookedModule.RequiresAuthentication方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Should_add_an_item_to_the_start_of_the_begin_pipeline_when_RequiresAuthentication_enabled
public void Should_add_an_item_to_the_start_of_the_begin_pipeline_when_RequiresAuthentication_enabled()
{
var module = new FakeHookedModule(A.Fake<BeforePipeline>());
module.RequiresAuthentication();
A.CallTo(() => module.Before.AddItemToStartOfPipeline(A<Func<NancyContext, Response>>.Ignored)).MustHaveHappened(Repeated.Exactly.Once);
}
示例2: Should_return_unauthorized_response_with_RequiresAuthentication_enabled_and_no_user
public void Should_return_unauthorized_response_with_RequiresAuthentication_enabled_and_no_user()
{
var module = new FakeHookedModule(new BeforePipeline());
module.RequiresAuthentication();
var result = module.Before.Invoke(new NancyContext(), new CancellationToken());
result.Result.ShouldNotBeNull();
result.Result.StatusCode.ShouldEqual(HttpStatusCode.Unauthorized);
}
示例3: Should_return_null_with_RequiresAuthentication_enabled_and_user_provided
public void Should_return_null_with_RequiresAuthentication_enabled_and_user_provided()
{
var module = new FakeHookedModule(new BeforePipeline());
module.RequiresAuthentication();
var context = new NancyContext
{
CurrentUser = GetFakeUser("Bob")
};
var result = module.Before.Invoke(context, new CancellationToken());
result.Result.ShouldBeNull();
}
示例4: Should_return_unauthorized_response_with_RequiresAuthentication_enabled_and_blank_username
public void Should_return_unauthorized_response_with_RequiresAuthentication_enabled_and_blank_username()
{
var module = new FakeHookedModule(new BeforePipeline());
module.RequiresAuthentication();
var context = new NancyContext
{
CurrentUser = GetFakeUser(String.Empty)
};
var result = module.Before.Invoke(context, new CancellationToken());
result.Result.ShouldNotBeNull();
result.Result.StatusCode.ShouldEqual(HttpStatusCode.Unauthorized);
}
示例5: Should_return_unauthorized_response_with_RequiresAuthentication_enabled_and_blank_username
public void Should_return_unauthorized_response_with_RequiresAuthentication_enabled_and_blank_username()
{
var module = new FakeHookedModule(new BeforePipeline());
module.RequiresAuthentication();
var context = new NancyContext();
context.Items[Nancy.Security.SecurityConventions.AuthenticatedUsernameKey] = String.Empty;
var result = module.Before.Invoke(context);
result.ShouldNotBeNull();
result.StatusCode.ShouldEqual(HttpStatusCode.Unauthorized);
}
示例6: Should_return_null_with_RequiresAuthentication_enabled_and_username_provided
public void Should_return_null_with_RequiresAuthentication_enabled_and_username_provided()
{
var module = new FakeHookedModule(new BeforePipeline());
module.RequiresAuthentication();
var context = new NancyContext();
context.Items[Nancy.Security.SecurityConventions.AuthenticatedUsernameKey] = "test";
var result = module.Before.Invoke(context);
result.ShouldBeNull();
}