public void CloudFoundryEndpointMiddleware_PathAndVerbMatching_ReturnsExpected()
        {
            var opts   = new CloudFoundryOptions();
            var ep     = new CloudFoundryEndpoint(opts);
            var middle = new CloudFoundryEndpointMiddleware(null, ep);

            Assert.True(middle.RequestVerbAndPathMatch("GET", "/"));
            Assert.False(middle.RequestVerbAndPathMatch("PUT", "/"));
            Assert.False(middle.RequestVerbAndPathMatch("GET", "/badpath"));
        }
Пример #2
0
        public void CloudFoundryEndpointMiddleware_PathAndVerbMatching_ReturnsExpected()
        {
            var opts        = new CloudFoundryEndpointOptions();
            var mgmtOptions = TestHelpers.GetManagementOptions(opts);
            var ep          = new CloudFoundryEndpoint(opts, mgmtOptions);
            var middle      = new CloudFoundryEndpointMiddleware(null, ep, mgmtOptions);

            Assert.True(middle.RequestVerbAndPathMatch("GET", "/cloudfoundryapplication"));
            Assert.False(middle.RequestVerbAndPathMatch("PUT", "/cloudfoundryapplication"));
            Assert.False(middle.RequestVerbAndPathMatch("GET", "/cloudfoundryapplication/badpath"));
        }
        public async void HandleCloudFoundryRequestAsync_ReturnsExpected()
        {
            var opts    = new CloudFoundryOptions();
            var ep      = new TestCloudFoundryEndpoint(opts);
            var middle  = new CloudFoundryEndpointMiddleware(null, ep);
            var context = CreateRequest("GET", "/");
            await middle.HandleCloudFoundryRequestAsync(context);

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

            Assert.Equal("{\"type\":\"steeltoe\",\"_links\":{}}", json);
        }
Пример #4
0
        public void IsCloudFoundryRequest_ReturnsExpected()
        {
            var opts   = new CloudFoundryOptions();
            var ep     = new CloudFoundryEndpoint(opts);
            var middle = new CloudFoundryEndpointMiddleware(null, ep);

            var context = CreateRequest("GET", "/");

            Assert.True(middle.IsCloudFoundryRequest(context));

            var context2 = CreateRequest("PUT", "/");

            Assert.False(middle.IsCloudFoundryRequest(context2));

            var context3 = CreateRequest("GET", "/badpath");

            Assert.False(middle.IsCloudFoundryRequest(context3));
        }