Ejemplo n.º 1
0
        public void ShouldVerifyPathWithManyDots()
        {
            var ctlr = new AssetsController();

            ctlr.NormalizePath(@"path\path2\..\..\Index.html").Should().Be("Index.html");
            ctlr.NormalizePath(@"path/path2/../../Index.html").Should().Be("Index.html");
            ctlr.NormalizePath(@"path\path2\../../Index.html").Should().Be("Index.html");
        }
Ejemplo n.º 2
0
        public void ShouldVerifyPathWithDot()
        {
            var ctlr = new AssetsController();

            ctlr.NormalizePath(@"path\.\Index.html").Should().Be("path\\Index.html");
            ctlr.NormalizePath(@"path/./Index.html").Should().Be("path\\Index.html");
            ctlr.NormalizePath(@"path\./Index.html").Should().Be("path\\Index.html");
        }
Ejemplo n.º 3
0
        public void ShouldNotLoadAssetThatDoesntExist()
        {
            var ctlr   = new AssetsController();
            var ctx    = new TestHttpContext();
            var rezult = ctlr.At(ctx, new List <PositionedResult>(), @"c:\Temp\", Guid.NewGuid() + "\\index.html");

            ctx.Response.StatusCode.Should().Be(404);
        }
Ejemplo n.º 4
0
        public void ShouldNotLoadAssetOutOfSandBox()
        {
            var ctlr   = new AssetsController();
            var ctx    = new TestHttpContext();
            var rezult = ctlr.At(ctx, new List <PositionedResult>(), @"c:\Something\", @"path\..\..\");

            ctx.Response.StatusCode.Should().Be(404);
        }
Ejemplo n.º 5
0
        public void ShouldLoadAssetThatExists()
        {
            var ctlr = new AssetsController();
            var ctx  = new TestHttpContext();
            var path = Path.GetTempFileName();

            File.WriteAllText(path, "Scott Youngblut");
            var rezult = ctlr.At(ctx, new List <PositionedResult>(), Path.GetDirectoryName(path), Path.GetFileName(path));

            ctx.Response.StatusCode.Should().Be(200);
            rezult.Content.BodyAsString.Should().Be("Scott Youngblut");
        }
Ejemplo n.º 6
0
        public void ShouldReturnNullWhenBreakingOutOfTheRoot()
        {
            var ctlr = new AssetsController();

            ctlr.NormalizePath(@"path\..\path2\..\..\Index.html").Should().BeNull();
        }
Ejemplo n.º 7
0
        public void ShouldVerifyPathWithInterspercedDots()
        {
            var ctlr = new AssetsController();

            ctlr.NormalizePath(@"root\path\..\path2\..\Index.html").Should().Be("root\\Index.html");
        }