Beispiel #1
0
        public async Task HandleMappingsRequestAsync_MVCNotUsed_NoRoutes_ReturnsExpected()
        {
            var opts  = new MappingsEndpointOptions();
            var mopts = new CloudFoundryManagementOptions();

            mopts.EndpointOptions.Add(opts);

            var configurationBuilder = new ConfigurationBuilder();

            configurationBuilder.AddInMemoryCollection(AppSettings);
            var config = configurationBuilder.Build();
            var host   = HostingHelpers.GetHostingEnvironment();
            var ep     = new MappingsEndpoint(opts);
            var middle = new MappingsEndpointMiddleware(null, opts, mopts, ep);

            var context = CreateRequest("GET", "/cloudfoundryapplication/mappings");
            await middle.HandleMappingsRequestAsync(context);

            context.Response.Body.Seek(0, SeekOrigin.Begin);
            var reader = new StreamReader(context.Response.Body, Encoding.UTF8);
            var json   = await reader.ReadLineAsync();

            var expected = "{\"contexts\":{\"application\":{\"mappings\":{\"dispatcherServlets\":{\"dispatcherServlet\":[]}}}}}";

            Assert.Equal(expected, json);
        }
Beispiel #2
0
 public MappingsHandler(MappingsEndpoint endpoint, IEnumerable <ISecurityService> securityServices, IApiExplorer apiExplorer, IEnumerable <IManagementOptions> mgmtOptions, ILogger <MappingsHandler> logger = null)
     : base(securityServices, mgmtOptions, null, true, logger)
 {
     _options     = endpoint.Options;
     _endpoint    = endpoint;
     _apiExplorer = apiExplorer;
 }
Beispiel #3
0
        public static void UseMappingsActuator(IConfiguration configuration, IApiExplorer apiExplorer = null, ILoggerFactory loggerFactory = null)
        {
            var options = new MappingsEndpointOptions(configuration);

            _mgmtOptions.RegisterEndpointOptions(configuration, options);
            var ep      = new MappingsEndpoint(options, CreateLogger <MappingsEndpoint>(loggerFactory));
            var handler = new MappingsHandler(ep, SecurityServices, apiExplorer, _mgmtOptions, CreateLogger <MappingsHandler>(loggerFactory));

            ConfiguredHandlers.Add(handler);
        }