当前位置: 首页>>代码示例>>C#>>正文


C# FakeHookedModule.RequiresClaims方法代码示例

本文整理汇总了C#中Nancy.Tests.Fakes.FakeHookedModule.RequiresClaims方法的典型用法代码示例。如果您正苦于以下问题:C# FakeHookedModule.RequiresClaims方法的具体用法?C# FakeHookedModule.RequiresClaims怎么用?C# FakeHookedModule.RequiresClaims使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Nancy.Tests.Fakes.FakeHookedModule的用法示例。


在下文中一共展示了FakeHookedModule.RequiresClaims方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Should_add_two_items_to_the_start_of_the_begin_pipeline_when_RequiresClaims_enabled

        public void Should_add_two_items_to_the_start_of_the_begin_pipeline_when_RequiresClaims_enabled()
        {
            var module = new FakeHookedModule(A.Fake<BeforePipeline>());

            module.RequiresClaims(new[] { string.Empty });

            A.CallTo(() => module.Before.AddItemToStartOfPipeline(A<Func<NancyContext, Response>>.Ignored)).MustHaveHappened(Repeated.Exactly.Twice);
        }
开发者ID:nuxleus,项目名称:Nancy,代码行数:8,代码来源:ModuleSecurityFixture.cs

示例2: Should_return_forbidden_response_with_RequiresClaims_enabled_but_claims_key_missing

        public void Should_return_forbidden_response_with_RequiresClaims_enabled_but_claims_key_missing()
        {
            var module = new FakeHookedModule(new BeforePipeline());
            module.RequiresClaims(new[] { "Claim1" });
            var context = new NancyContext();
            context.Items[Nancy.Security.SecurityConventions.AuthenticatedUsernameKey] = "username";

            var result = module.Before.Invoke(context);

            result.ShouldNotBeNull();
            result.StatusCode.ShouldEqual(HttpStatusCode.Forbidden);
        }
开发者ID:nuxleus,项目名称:Nancy,代码行数:12,代码来源:ModuleSecurityFixture.cs

示例3: Should_return_forbidden_response_with_RequiresClaims_enabled_but_claims_key_missing

        public void Should_return_forbidden_response_with_RequiresClaims_enabled_but_claims_key_missing()
        {
            var module = new FakeHookedModule(new BeforePipeline());
            module.RequiresClaims(new[] { "Claim1" });
            var context = new NancyContext
                              {
                                  CurrentUser = GetFakeUser("username")
                              };

            var result = module.Before.Invoke(context);

            result.ShouldNotBeNull();
            result.StatusCode.ShouldEqual(HttpStatusCode.Forbidden);
        }
开发者ID:nathanpalmer,项目名称:Nancy,代码行数:14,代码来源:ModuleSecurityFixture.cs

示例4: Should_return_unauthorized_response_with_RequiresClaims_enabled_and_no_username

        public void Should_return_unauthorized_response_with_RequiresClaims_enabled_and_no_username()
        {
            var module = new FakeHookedModule(new BeforePipeline());
            module.RequiresClaims(new[] { string.Empty });

            var result = module.Before.Invoke(new NancyContext());

            result.ShouldNotBeNull();
            result.StatusCode.ShouldEqual(HttpStatusCode.Unauthorized);
        }
开发者ID:nuxleus,项目名称:Nancy,代码行数:10,代码来源:ModuleSecurityFixture.cs

示例5: Should_return_unauthorized_response_with_RequiresClaims_enabled_and_blank_username

        public void Should_return_unauthorized_response_with_RequiresClaims_enabled_and_blank_username()
        {
            var module = new FakeHookedModule(new BeforePipeline());
            module.RequiresClaims(new[] { string.Empty });
            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);
        }
开发者ID:nuxleus,项目名称:Nancy,代码行数:12,代码来源:ModuleSecurityFixture.cs

示例6: Should_return_null_with_RequiresClaims_and_all_claims_met

        public void Should_return_null_with_RequiresClaims_and_all_claims_met()
        {
            var module = new FakeHookedModule(new BeforePipeline());
            module.RequiresClaims(new[] { "Claim1", "Claim2" });
            var context = new NancyContext();
            context.Items[Nancy.Security.SecurityConventions.AuthenticatedUsernameKey] = "username";
            context.Items[Nancy.Security.SecurityConventions.AuthenticatedClaimsKey] = new[] { "Claim1", "Claim2", "Claim3" };

            var result = module.Before.Invoke(context);

            result.ShouldBeNull();
        }
开发者ID:nuxleus,项目名称:Nancy,代码行数:12,代码来源:ModuleSecurityFixture.cs

示例7: Should_return_null_with_RequiresClaims_and_all_claims_met

        public void Should_return_null_with_RequiresClaims_and_all_claims_met()
        {
            var module = new FakeHookedModule(new BeforePipeline());
            module.RequiresClaims(new[] { "Claim1", "Claim2" });
            var context = new NancyContext
                              {
                                  CurrentUser = GetFakeUser("username", new[] {"Claim1", "Claim2", "Claim3"})
                              };

            var result = module.Before.Invoke(context);

            result.ShouldBeNull();
        }
开发者ID:nathanpalmer,项目名称:Nancy,代码行数:13,代码来源:ModuleSecurityFixture.cs

示例8: Should_return_unauthorized_response_with_RequiresClaims_enabled_and_blank_username

        public void Should_return_unauthorized_response_with_RequiresClaims_enabled_and_blank_username()
        {
            var module = new FakeHookedModule(new BeforePipeline());
            module.RequiresClaims(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);
        }
开发者ID:lukywong,项目名称:Nancy,代码行数:14,代码来源:ModuleSecurityFixture.cs

示例9: Should_return_forbidden_response_with_RequiresClaims_enabled_but_not_all_claims_met

        public void Should_return_forbidden_response_with_RequiresClaims_enabled_but_not_all_claims_met()
        {
            var module = new FakeHookedModule(new BeforePipeline());
            module.RequiresClaims(new[] { "Claim1", "Claim2" });
            var context = new NancyContext
                              {
                                  CurrentUser = GetFakeUser("username", new[] {"Claim2"})
                              };

            var result = module.Before.Invoke(context, new CancellationToken());

            result.Result.ShouldNotBeNull();
            result.Result.StatusCode.ShouldEqual(HttpStatusCode.Forbidden);
        }
开发者ID:lukywong,项目名称:Nancy,代码行数:14,代码来源:ModuleSecurityFixture.cs

示例10: Should_return_forbidden_response_with_RequiresClaims_enabled_but_nonmatching_claims

        public void Should_return_forbidden_response_with_RequiresClaims_enabled_but_nonmatching_claims()
        {
            var module = new FakeHookedModule(new BeforePipeline());
            module.RequiresClaims(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);
        }
开发者ID:RadifMasud,项目名称:Nancy,代码行数:17,代码来源:ModuleSecurityFixture.cs

示例11: Should_return_null_with_RequiresClaims_and_all_claims_met

        public void Should_return_null_with_RequiresClaims_and_all_claims_met()
        {
            var module = new FakeHookedModule(new BeforePipeline());
            module.RequiresClaims(c => c.Type == "Claim1", c => c.Type == "Claim2");
            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();
        }
开发者ID:RadifMasud,项目名称:Nancy,代码行数:16,代码来源:ModuleSecurityFixture.cs


注:本文中的Nancy.Tests.Fakes.FakeHookedModule.RequiresClaims方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。