예제 #1
0
        public async void LoggersInvoke_ReturnsExpected()
        {
            var ep      = new TestLoggersEndpoint(new LoggersOptions());
            var middle  = new LoggersEndpointOwinMiddleware(null, ep);
            var context = OwinTestHelpers.CreateRequest("GET", "/loggers");
            await middle.Invoke(context);

            context.Response.Body.Seek(0, SeekOrigin.Begin);
            StreamReader rdr  = new StreamReader(context.Response.Body);
            string       json = await rdr.ReadToEndAsync();

            Assert.Equal("{}", json);
        }
예제 #2
0
        public void LoggersEndpointMiddleware_PathAndVerbMatching_ReturnsExpected()
        {
            var opts   = new LoggersOptions();
            var ep     = new LoggersEndpoint(opts, null);
            var middle = new LoggersEndpointOwinMiddleware(null, ep);

            Assert.True(middle.RequestVerbAndPathMatch("GET", "/loggers"));
            Assert.False(middle.RequestVerbAndPathMatch("PUT", "/loggers"));
            Assert.False(middle.RequestVerbAndPathMatch("GET", "/badpath"));
            Assert.True(middle.RequestVerbAndPathMatch("POST", "/loggers"));
            Assert.False(middle.RequestVerbAndPathMatch("POST", "/badpath"));
            Assert.True(middle.RequestVerbAndPathMatch("POST", "/loggers/Foo.Bar.Class"));
            Assert.False(middle.RequestVerbAndPathMatch("POST", "/badpath/Foo.Bar.Class"));
        }
예제 #3
0
        public void LoggersEndpointMiddleware_PathAndVerbMatching_ReturnsExpected()
        {
            var opts   = new LoggersEndpointOptions();
            var mopts  = TestHelpers.GetManagementOptions(opts);
            var ep     = new LoggersEndpoint(opts, (IDynamicLoggerProvider)null);
            var middle = new LoggersEndpointOwinMiddleware(null, ep, mopts);

            Assert.True(middle.RequestVerbAndPathMatch("GET", "/cloudfoundryapplication/loggers"));
            Assert.False(middle.RequestVerbAndPathMatch("PUT", "/cloudfoundryapplication/loggers"));
            Assert.False(middle.RequestVerbAndPathMatch("GET", "/cloudfoundryapplication/badpath"));
            Assert.True(middle.RequestVerbAndPathMatch("POST", "/cloudfoundryapplication/loggers"));
            Assert.False(middle.RequestVerbAndPathMatch("POST", "/cloudfoundryapplication/badpath"));
            Assert.True(middle.RequestVerbAndPathMatch("POST", "/cloudfoundryapplication/loggers/Foo.Bar.Class"));
            Assert.False(middle.RequestVerbAndPathMatch("POST", "/cloudfoundryapplication/badpath/Foo.Bar.Class"));
        }