本文整理匯總了C#中Nancy.Tests.Fakes.FakeHookedModule.RequiresAnyClaim方法的典型用法代碼示例。如果您正苦於以下問題:C# FakeHookedModule.RequiresAnyClaim方法的具體用法?C# FakeHookedModule.RequiresAnyClaim怎麽用?C# FakeHookedModule.RequiresAnyClaim使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Nancy.Tests.Fakes.FakeHookedModule
的用法示例。
在下文中一共展示了FakeHookedModule.RequiresAnyClaim方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: Should_return_null_with_RequiresAnyClaim_and_any_claim_met
public void Should_return_null_with_RequiresAnyClaim_and_any_claim_met()
{
var module = new FakeHookedModule(new BeforePipeline());
module.RequiresAnyClaim(new[] { "Claim1", "Claim4" });
var context = new NancyContext
{
CurrentUser = GetFakeUser("username", new[] { "Claim1", "Claim2", "Claim3" })
};
var result = module.Before.Invoke(context);
result.ShouldBeNull();
}
示例2: Should_return_unauthorized_response_with_RequiresAnyClaim_enabled_and_no_username
public void Should_return_unauthorized_response_with_RequiresAnyClaim_enabled_and_no_username()
{
var module = new FakeHookedModule(new BeforePipeline());
module.RequiresAnyClaim(new[] { string.Empty });
var result = module.Before.Invoke(new NancyContext());
result.ShouldNotBeNull();
result.StatusCode.ShouldEqual(HttpStatusCode.Unauthorized);
}
示例3: Should_return_forbidden_response_with_RequiresAnyClaim_enabled_but_nonmatching_claims
public void Should_return_forbidden_response_with_RequiresAnyClaim_enabled_but_nonmatching_claims()
{
var module = new FakeHookedModule(new BeforePipeline());
module.RequiresAnyClaim(new[] { "Claim1" });
var context = new NancyContext
{
CurrentUser = GetFakeUser("username", new string[] { "Claim2", "Claim3" })
};
var result = module.Before.Invoke(context);
result.ShouldNotBeNull();
result.StatusCode.ShouldEqual(HttpStatusCode.Forbidden);
}
示例4: Should_return_unauthorized_response_with_RequiresAnyClaim_enabled_and_blank_username
public void Should_return_unauthorized_response_with_RequiresAnyClaim_enabled_and_blank_username()
{
var module = new FakeHookedModule(new BeforePipeline());
module.RequiresAnyClaim(new[] { string.Empty });
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_forbidden_response_with_RequiresAnyClaim_enabled_but_claims_key_missing
public void Should_return_forbidden_response_with_RequiresAnyClaim_enabled_but_claims_key_missing()
{
var module = new FakeHookedModule(new BeforePipeline());
module.RequiresAnyClaim(new[] { "Claim1" });
var context = new NancyContext
{
CurrentUser = GetFakeUser("username")
};
var result = module.Before.Invoke(context, new CancellationToken());
result.Result.ShouldNotBeNull();
result.Result.StatusCode.ShouldEqual(HttpStatusCode.Forbidden);
}
示例6: Should_return_null_with_RequiresAnyClaim_and_any_claim_met
public void Should_return_null_with_RequiresAnyClaim_and_any_claim_met()
{
var module = new FakeHookedModule(new BeforePipeline());
module.RequiresAnyClaim(c => c.Type == "Claim1", c => c.Type == "Claim4");
var context = new NancyContext
{
CurrentUser = GetFakeUser("username",
new Claim("Claim1", string.Empty),
new Claim("Claim2", string.Empty),
new Claim("Claim3", string.Empty))
};
var result = module.Before.Invoke(context, new CancellationToken());
result.Result.ShouldBeNull();
}
示例7: Should_return_forbidden_response_with_RequiresAnyClaim_enabled_but_nonmatching_claims
public void Should_return_forbidden_response_with_RequiresAnyClaim_enabled_but_nonmatching_claims()
{
var module = new FakeHookedModule(new BeforePipeline());
module.RequiresAnyClaim(c => c.Type == "Claim1");
var context = new NancyContext
{
CurrentUser = GetFakeUser(
"username",
new Claim("Claim2", string.Empty),
new Claim("Claim3", string.Empty))
};
var result = module.Before.Invoke(context, new CancellationToken());
result.Result.ShouldNotBeNull();
result.Result.StatusCode.ShouldEqual(HttpStatusCode.Forbidden);
}