當前位置: 首頁>>代碼示例>>C#>>正文


C# Fakes.FakeHookedModule類代碼示例

本文整理匯總了C#中Nancy.Tests.Fakes.FakeHookedModule的典型用法代碼示例。如果您正苦於以下問題:C# FakeHookedModule類的具體用法?C# FakeHookedModule怎麽用?C# FakeHookedModule使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


FakeHookedModule類屬於Nancy.Tests.Fakes命名空間,在下文中一共展示了FakeHookedModule類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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);
        }
開發者ID:nuxleus,項目名稱:Nancy,代碼行數:8,代碼來源:ModuleSecurityFixture.cs

示例2: Should_add_two_items_to_the_start_of_the_begin_pipeline_when_RequiresValidatedClaims_enabled

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

            module.RequiresValidatedClaims(c => false);

            A.CallTo(() => module.Before.AddItemToStartOfPipeline(A<Func<NancyContext, Response>>.Ignored)).MustHaveHappened(Repeated.Exactly.Twice);
        }
開發者ID:nuxleus,項目名稱:Nancy,代碼行數:8,代碼來源:ModuleSecurityFixture.cs

示例3: Should_add_two_items_to_the_end_of_the_begin_pipeline_when_RequiresClaims_enabled

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

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

            A.CallTo(() => module.Before.AddItemToEndOfPipeline(A<Func<NancyContext, Response>>.Ignored)).MustHaveHappened(Repeated.Exactly.Twice);
        }
開發者ID:lukywong,項目名稱:Nancy,代碼行數:8,代碼來源:ModuleSecurityFixture.cs

示例4: 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);
        }
開發者ID:RadifMasud,項目名稱:Nancy,代碼行數:10,代碼來源:ModuleSecurityFixture.cs

示例5: 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

示例6: 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

示例7: 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();
        }
開發者ID:RadifMasud,項目名稱:Nancy,代碼行數:14,代碼來源:ModuleSecurityFixture.cs

示例8: 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);
        }
開發者ID:JulianRooze,項目名稱:Nancy,代碼行數:15,代碼來源:ModuleSecurityFixture.cs

示例9: Should_call_IsValid_delegate_with_RequiresValidatedClaims_and_valid_username

        public void Should_call_IsValid_delegate_with_RequiresValidatedClaims_and_valid_username()
        {
            bool called = false;
            var module = new FakeHookedModule(new BeforePipeline());
            var context = new NancyContext();
            context.Items[Nancy.Security.SecurityConventions.AuthenticatedUsernameKey] = "username";
            context.Items[Nancy.Security.SecurityConventions.AuthenticatedClaimsKey] = new[] { "Claim1", "Claim2", "Claim3" };
            module.RequiresValidatedClaims(s =>
                {
                    called = true;
                    return true;
                });

            module.Before.Invoke(context);

            called.ShouldEqual(true);
        }
開發者ID:nuxleus,項目名稱:Nancy,代碼行數:17,代碼來源:ModuleSecurityFixture.cs

示例10: Should_call_IsValid_delegate_with_RequiresValidatedClaims_and_valid_username

        public void Should_call_IsValid_delegate_with_RequiresValidatedClaims_and_valid_username()
        {
            bool called = false;
            var module = new FakeHookedModule(new BeforePipeline());
            var context = new NancyContext
                              {
                                  CurrentUser = GetFakeUser("username", new[] {"Claim1", "Claim2", "Claim3"})
                              };

            module.RequiresValidatedClaims(s =>
                {
                    called = true;
                    return true;
                });

            module.Before.Invoke(context);

            called.ShouldEqual(true);
        }
開發者ID:nathanpalmer,項目名稱:Nancy,代碼行數:19,代碼來源:ModuleSecurityFixture.cs

示例11: Should_return_forbidden_response_when_request_url_is_non_secure_method_is_delete_and_requires_https

        public void Should_return_forbidden_response_when_request_url_is_non_secure_method_is_delete_and_requires_https()
        {
            // Given
            var module = new FakeHookedModule(new BeforePipeline());
            var url = GetFakeUrl(false);
            var context = new NancyContext
                              {
                                  Request = new Request("DELETE", url)
                              };

            module.RequiresHttps();

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

            // Then
            result.ShouldNotBeNull();
            result.StatusCode.ShouldEqual(HttpStatusCode.Forbidden);
        }
開發者ID:kppullin,項目名稱:Nancy,代碼行數:19,代碼來源:ModuleSecurityFixture.cs

示例12: 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

示例13: Should_return_unauthorized_response_with_RequiresValidatedClaims_enabled_and_no_username

        public void Should_return_unauthorized_response_with_RequiresValidatedClaims_enabled_and_no_username()
        {
            var module = new FakeHookedModule(new BeforePipeline());
            module.RequiresValidatedClaims(c => false);

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

            result.ShouldNotBeNull();
            result.StatusCode.ShouldEqual(HttpStatusCode.Unauthorized);
        }
開發者ID:nuxleus,項目名稱:Nancy,代碼行數:10,代碼來源:ModuleSecurityFixture.cs

示例14: Should_return_unauthorized_response_with_RequiresValidatedClaims_enabled_and_blank_username

        public void Should_return_unauthorized_response_with_RequiresValidatedClaims_enabled_and_blank_username()
        {
            var module = new FakeHookedModule(new BeforePipeline());
            module.RequiresValidatedClaims(c => false);
            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

示例15: Should_return_null_with_RequiresValidatedClaims_and_IsValid_returns_true

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

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

            result.ShouldBeNull();
        }
開發者ID:nuxleus,項目名稱:Nancy,代碼行數:12,代碼來源:ModuleSecurityFixture.cs


注:本文中的Nancy.Tests.Fakes.FakeHookedModule類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。