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");
        }
        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");
        }
        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);
        }
        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);
        }
        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");
        }
        public void ShouldReturnNullWhenBreakingOutOfTheRoot()
        {
            var ctlr = new AssetsController();

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

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