public async void HandleRefreshRequestAsync_ReturnsExpected() { var opts = new RefreshEndpointOptions(); var mopts = new ActuatorManagementOptions(); mopts.EndpointOptions.Add(opts); ConfigurationBuilder configurationBuilder = new ConfigurationBuilder(); configurationBuilder.AddInMemoryCollection(AppSettings); var config = configurationBuilder.Build(); var ep = new RefreshEndpoint(opts, config); var middle = new RefreshEndpointMiddleware(null, ep, mopts); var context = CreateRequest("GET", "/refresh"); await middle.HandleRefreshRequestAsync(context); context.Response.Body.Seek(0, SeekOrigin.Begin); var reader = new StreamReader(context.Response.Body, Encoding.UTF8); var json = await reader.ReadLineAsync(); var expected = "[\"management\",\"management:endpoints\",\"management:endpoints:enabled\",\"Logging\",\"Logging:LogLevel\",\"Logging:LogLevel:Steeltoe\",\"Logging:LogLevel:Pivotal\",\"Logging:LogLevel:Default\",\"Logging:IncludeScopes\"]"; Assert.Equal(expected, json); }
public void RefreshEndpointMiddleware_PathAndVerbMatching_ReturnsExpected() { var opts = new RefreshOptions(); ConfigurationBuilder configurationBuilder = new ConfigurationBuilder(); configurationBuilder.AddInMemoryCollection(appSettings); var config = configurationBuilder.Build(); var ep = new RefreshEndpoint(opts, config); var middle = new RefreshEndpointMiddleware(null, ep); Assert.True(middle.RequestVerbAndPathMatch("GET", "/refresh")); Assert.False(middle.RequestVerbAndPathMatch("PUT", "/refresh")); Assert.False(middle.RequestVerbAndPathMatch("GET", "/badpath")); }
public void RefreshEndpointMiddleware_PathAndVerbMatching_ReturnsExpected() { var opts = new RefreshEndpointOptions(); var mopts = TestHelpers.GetManagementOptions(opts); ConfigurationBuilder configurationBuilder = new ConfigurationBuilder(); configurationBuilder.AddInMemoryCollection(AppSettings); var config = configurationBuilder.Build(); var ep = new RefreshEndpoint(opts, config); var middle = new RefreshEndpointMiddleware(null, ep, mopts); Assert.True(middle.RequestVerbAndPathMatch("GET", "/cloudfoundryapplication/refresh")); Assert.False(middle.RequestVerbAndPathMatch("PUT", "/cloudfoundryapplication/refresh")); Assert.False(middle.RequestVerbAndPathMatch("GET", "/cloudfoundryapplication/badpath")); }