public void do_nothing_if_tracing_is_off()
        {
            var registry = new FubuRegistry();
            registry.AlterSettings<DiagnosticsSettings>(x => x.TraceLevel = TraceLevel.None);
            registry.Configure(graph =>
            {
                chain1 = new BehaviorChain();
                chain1.AddToEnd(Wrapper.For<SimpleBehavior>());
                chain1.AddToEnd(Wrapper.For<DifferentBehavior>());
                chain1.Route = new RouteDefinition("something");
                graph.AddChain(chain1);

                chain2 = new BehaviorChain();
                chain2.IsPartialOnly = true;
                chain2.AddToEnd(Wrapper.For<SimpleBehavior>());
                chain2.AddToEnd(Wrapper.For<DifferentBehavior>());
                graph.AddChain(chain2);
            });


            registry.Policies.Add<ApplyTracing>();

            var notTracedGraph = BehaviorGraph.BuildFrom(registry);
            notTracedGraph.Behaviors.SelectMany(x => x).Any(x => x is DiagnosticBehavior).ShouldBeFalse();
            notTracedGraph.Behaviors.SelectMany(x => x).Any(x => x is BehaviorTracer).ShouldBeFalse();
        }
Exemplo n.º 2
0
        public void Configure(FubuRegistry registry)
        {
            registry
                .Actions
                .FindWith<ExplicitControllerRegistration>();

            registry
                .Views
                .TryToAttachWithDefaultConventions()
                .TryToAttachViewsInPackages();

            registry
                .UseSpark(spark => spark.ConfigureComposer(c => c.AddBinder<DiagnosticsTemplateBinder>()));

            registry.Configure(graph =>
                                   {
                                       var chain = graph.FindHomeChain();
                                       if (chain == null)
                                       {
                                           graph
                                               .BehaviorFor<GettingStartedController>(x => x.Execute(new GettingStartedRequestModel()))
                                               .Route = new RouteDefinition(string.Empty);
                                       }
                                   });
        }
        public void Configure(FubuRegistry registry)
        {
            registry.Policies.Add<ApplyTracing>();
			registry.Policies.Add<DescriptionVisualizationPolicy>();
            registry.Policies.Add<DiagnosticChainsPolicy>();
            registry.Services<DiagnosticServiceRegistry>();

            registry.Configure(graph => {
                var settings = graph.Settings.Get<DiagnosticsSettings>();

                if (settings.TraceLevel == TraceLevel.Verbose)
                {
                    graph.Services.Clear(typeof(IBindingLogger));
                    graph.Services.AddService<IBindingLogger, RecordingBindingLogger>();

                    graph.Services.Clear(typeof(IBindingHistory));
                    graph.Services.AddService<IBindingHistory, BindingHistory>();

                    graph.Services.AddService<ILogListener, RequestTraceListener>();
                }

                if (settings.TraceLevel == TraceLevel.Production)
                {
                    graph.Services.AddService<ILogListener, ProductionModeTraceListener>();
                }
            });

            registry.Policies.Add<DefaultHome>();
        }
Exemplo n.º 4
0
        public void Configure(FubuRegistry registry)
        {
            MimeType.New("text/jsx", ".jsx");

            registry.Services<DiagnosticServiceRegistry>();

            registry.AlterSettings<AssetSettings>(x => x.AllowableExtensions.Add(".jsx"));

            registry.AlterSettings<DiagnosticsSettings>(x =>
            {
                x.TraceLevel = TraceLevel.Verbose;
            });

            registry.Configure(graph => {
                var settings = graph.Settings.Get<DiagnosticsSettings>();

                if (settings.TraceLevel == TraceLevel.Verbose)
                {
                    graph.Services.Clear(typeof (IBindingLogger));
                    graph.Services.AddService<IBindingLogger, RecordingBindingLogger>();

                    graph.Services.Clear(typeof (IBindingHistory));
                    graph.Services.AddService<IBindingHistory, BindingHistory>();

                    graph.Services.AddService<ILogListener, RequestTraceListener>();
                }

                if (settings.TraceLevel == TraceLevel.Production)
                {
                    graph.Services.AddService<ILogListener, ProductionModeTraceListener>();
                }
            });
        }
 public void Configure(FubuRegistry registry)
 {
     registry.Configure(graph =>
     {
         graph.Behaviors.Where(PassportConfiguration.RestrictedAction).Each(c =>
         {
             var x = new Wrapper(typeof (AuthenticationPolicy));
             c.Prepend(x);
         });
     });
 }
Exemplo n.º 6
0
        public void Configure(FubuRegistry registry)
        {
            registry.Route("_fubu/getting_started").Calls<StartingController>(x => x.GettingStarted());

            registry.Configure(graph =>
            {
                var chain = graph.FindHomeChain();
                if (chain == null)
                {
                    graph.BehaviorFor<StartingController>(x => x.GettingStarted()).Route = new RouteDefinition(string.Empty);
                }
            });
        }
        public void Configure(FubuRegistry registry)
        {
            registry.Configure(graph =>
            {
                foreach(var c in graph.Behaviors)
                {
                    if(PassportConfiguration.RestrictedAction(c))
                    {

                    }
                }
            });
        }
        private BehaviorGraph setupActions()
        {
            var registry = new FubuRegistry();
            registry.Actions.IncludeType<RouteAliasAction1>();

            registry.Configure(x =>
            {
                theRouteDefinitionAlias = new RouteDefinition("{Client}/");
                theRouteDefinitionAlias.Input = MockRepository.GenerateMock<IRouteInput>();
                theRouteDefinitionAlias.Input.Stub(_ => _.Rank).Return(5);

                x.BehaviorFor<RouteAliasAction1>(_ => _.M1()).As<RoutedChain>().AddRouteAlias(theRouteDefinitionAlias);
            });

            return BehaviorGraph.BuildFrom(registry);
        }
Exemplo n.º 9
0
        public void adds_the_authentication_node_if_it_exists()
        {
            var registry = new FubuRegistry();
            registry.Actions.IncludeType<AuthenticatedEndpoint>();
            registry.Configure(
                graph => { graph.Chains.OfType<RoutedChain>().Each(x => x.Authentication = new AuthNode()); });

            using (var runtime = registry.ToRuntime())
            {
                runtime.Behaviors.ChainFor<AuthenticatedEndpoint>(x => x.get_hello())
                    .First().ShouldBeOfType<AuthNode>();
            }

            var chain = new RoutedChain("something");
            var auth = new AuthNode();
            chain.Authentication = auth;
        }
        public void Configure(FubuRegistry registry)
        {
            var tagPolicy = new AutoCompleteTagPolicy();
            

            registry.Actions.FindWith(new LookupActionSource());
            registry.Routes.UrlPolicy<LookupUrlPolicy>();

            registry.Import<HtmlConventionRegistry>(x => x.Editors.Add(tagPolicy));

            registry.Configure(graph => {
                var rules = graph.Settings.Get<AccessorRules>();

//                var strategy = new AutoCompleteStringifierStrategy(rules);
//                var stringifier = graph.Services.DefaultServiceFor<Stringifier>().Value.As<Stringifier>();
//                stringifier.AddStrategy(strategy);

                tagPolicy.Rules = rules;
            });
        }
        public void do_nothing_if_tracing_is_off()
        {
            var registry = new FubuRegistry();
            registry.Features.Diagnostics.Enable(TraceLevel.None);
            registry.Configure(graph =>
            {
                chain1 = new RoutedChain("something");
                chain1.AddToEnd(Wrapper.For<SimpleBehavior>());
                chain1.AddToEnd(Wrapper.For<DifferentBehavior>());
                graph.AddChain(chain1);

                chain2 = new BehaviorChain();
                chain2.IsPartialOnly = true;
                chain2.AddToEnd(Wrapper.For<SimpleBehavior>());
                chain2.AddToEnd(Wrapper.For<DifferentBehavior>());
                graph.AddChain(chain2);
            });

            var notTracedGraph = BehaviorGraph.BuildFrom(registry);
            notTracedGraph.Chains.SelectMany(x => x).Any(x => x is BehaviorTracerNode).ShouldBeFalse();
        }
Exemplo n.º 12
0
        public void BeforeEach()
        {
            _parent = new FubuRegistry();
            _parent.IncludeDiagnostics(true);

            _import = new FubuRegistry();
            _import.IncludeDiagnostics(true);
            _import.Actions
                .IncludeType<Handler1>()
                .IncludeType<Handler2>();

            _import.Configure(x =>
            {
                _importObserver = x.Observer;
                _importActions = x.Actions()
                    .Where(a => a.HandlerType.Namespace == GetType().Namespace);
            });

            _parent.Import(_import, "import");
            _parentObserver = _parent.BuildGraph().Observer;
        }
        public void SetUp()
        {
            var registry = new FubuRegistry();
            registry.Configure(graph =>
            {
                chain1 = new RoutedChain("something");
                chain1.AddToEnd(Wrapper.For<SimpleBehavior>());
                chain1.AddToEnd(Wrapper.For<DifferentBehavior>());
                graph.AddChain(chain1);

                chain2 = new BehaviorChain();
                chain2.IsPartialOnly = true;
                chain2.AddToEnd(Wrapper.For<SimpleBehavior>());
                chain2.AddToEnd(Wrapper.For<DifferentBehavior>());
                graph.AddChain(chain2);
            });

            registry.Features.Diagnostics.Enable(TraceLevel.Verbose);

            BehaviorGraph.BuildFrom(registry);
        }
        public void SetUp()
        {
            var registry = new FubuRegistry();
            registry.Configure(graph =>
            {
                chain1 = new BehaviorChain();
                chain1.AddToEnd(Wrapper.For<SimpleBehavior>());
                chain1.AddToEnd(Wrapper.For<DifferentBehavior>());
                chain1.Route = new RouteDefinition("something");
                graph.AddChain(chain1);

                chain2 = new BehaviorChain();
                chain2.IsPartialOnly = true;
                chain2.AddToEnd(Wrapper.For<SimpleBehavior>());
                chain2.AddToEnd(Wrapper.For<DifferentBehavior>());
                graph.AddChain(chain2);

            });

            registry.Policies.Add<ApplyTracing>();

            registry.BuildGraph();
        }
        public void action_without_json_attributes_or_JsonMessage_input_model_has_no_conneg()
        {
            // You have to make the endpoint get some sort of reader/writer to test the negative case,
            // otherwise the default "use json & xml if nothing else is provided" convention
            // takes over
            var registry = new FubuRegistry();
            registry.Actions.IncludeType<JsonController>();
            registry.Configure(graph =>
            {
                graph.Behaviors.Where(x => x.InputType() == typeof (Input1)).Each(chain =>
                {
                    chain.Input.AddFormatter<XmlFormatter>();
                    chain.Output.AddFormatter<XmlFormatter>();
                });
            });

            theGraph = BehaviorGraph.BuildFrom(registry);

            var theChain = theGraph.BehaviorFor(typeof (Input1));

            theChain.Input.UsesFormatter<JsonFormatter>().ShouldBeFalse();
            theChain.Output.UsesFormatter<JsonFormatter>().ShouldBeFalse();
        }
        public void SetUp()
        {
            theHttpRequest = OwinHttpRequest.ForTesting();
            theHttpRequest.FullUrl("http://server/fubu");

            var registry = new FubuRegistry();
            registry.Actions.IncludeType<OneController>();
            registry.Actions.IncludeType<TwoController>();
            registry.Actions.IncludeType<QueryStringTestController>();
            registry.Actions.IncludeType<OnlyOneActionController>();

            registry.Configure(x => { x.TypeResolver.AddStrategy<UrlModelForwarder>(); });

            //registry.Routes.HomeIs<DefaultModel>();

            graph = BehaviorGraph.BuildFrom(registry);

            var resolver = graph.Services.DefaultServiceFor<ITypeResolver>().Value;
            var urlResolver = new ChainUrlResolver(theHttpRequest);

            urls = new UrlRegistry(new ChainResolutionCache((ITypeResolver)resolver, graph), urlResolver,
                new JQueryUrlTemplate(), theHttpRequest);
        }
        private AuthorizationPreviewService withAuthorizationRules(Action<BehaviorGraph> configure)
        {
            var registry = new FubuRegistry();

            registry.Actions.IncludeType<OneController>();
            registry.Actions.IncludeType<TwoController>();

            registry.Configure(x =>
            {
                x.TypeResolver.AddStrategy<UrlModelForwarder>();
            });

            registry.Configure(configure);

            var container = new Container();
            FubuApplication.For(() => registry).StructureMap(container).Bootstrap();

            return container.GetInstance<AuthorizationPreviewService>();
        }
        public void use_custom_auth_handler_on_only_one_endpoint()
        {
            var registry = new FubuRegistry();
            registry.Configure(x => {
                x.BehaviorFor<AuthorizedEndpoint>(_ => _.get_authorized_text()).Authorization.FailureHandler<CustomAuthHandler>();
            });

            AuthorizationCheck.IsAuthorized = false;
            using (var server = FubuApplication.For(registry).StructureMap().RunEmbeddedWithAutoPort())
            {
                server.Endpoints.Get<AuthorizedEndpoint>(x => x.get_authorized_text())
                    .StatusCodeShouldBe(HttpStatusCode.Forbidden)
                    .ReadAsText().ShouldEqual("you are forbidden!");
            }
        }
        private AuthorizationPreviewService withAuthorizationRules(Action<BehaviorGraph> configure)
        {
            var registry = new FubuRegistry();

            registry.Actions.IncludeType<OneController>();
            registry.Actions.IncludeType<TwoController>();

            registry.Configure(configure);

            _runtime = registry.ToRuntime();

            return _runtime.Get<AuthorizationPreviewService>();
        }
        public void SetUp()
        {
            _theCurrentHttpRequest = new StubCurrentHttpRequest{
                TheApplicationRoot = "http://server/fubu"
            };

            var registry = new FubuRegistry();
            registry.Actions.IncludeType<OneController>();
            registry.Actions.IncludeType<TwoController>();
            registry.Actions.IncludeType<QueryStringTestController>();
            registry.Actions.IncludeType<OnlyOneActionController>();
            registry.Actions.ExcludeMethods(x => x.Name.Contains("Ignore"));

            registry.Routes
                .IgnoreControllerFolderName()
                .IgnoreNamespaceForUrlFrom<UrlRegistryIntegrationTester>()
                .IgnoreClassSuffix("Controller");

            registry.Configure(x =>
            {
                x.TypeResolver.AddStrategy<UrlModelForwarder>();
            });

            registry.Routes.HomeIs<DefaultModel>();

            graph = registry.BuildGraph();

            var resolver = graph.Services.DefaultServiceFor<ITypeResolver>().Value;

            urls = new UrlRegistry(new ChainResolutionCache((ITypeResolver) resolver, graph), new JQueryUrlTemplate(), _theCurrentHttpRequest);
        }
        public void use_custom_auth_handler_on_only_one_endpoint()
        {
            var registry = new FubuRegistry();

            registry.Configure(
                x =>
                {
                    x.ChainFor<AuthorizedEndpoint>(_ => _.get_authorized_text())
                        .Authorization.FailureHandler<CustomAuthHandler>();
                });

            AuthorizationCheck.IsAuthorized = false;
            using (var server = registry.ToRuntime())
            {
                server.Scenario(_ =>
                {
                    _.Get.Action<AuthorizedEndpoint>(x => x.get_authorized_text());

                    _.StatusCodeShouldBe(HttpStatusCode.Redirect);
                    _.Header(HttpResponseHeaders.Location).SingleValueShouldEqual("/403");
                });
            }
        }