Example #1
0
        [Test][Assert_Admin] public void handledBySiteData()
        {
            UserGroup.Admin.assert();

            Assert.IsFalse("/aaa.txt".siteData_Handle_VirtualPath());
            Assert.IsFalse(tmFileStorage.siteData_Handle_VirtualPath("abc"));
            Assert.IsFalse((null as string).siteData_Handle_VirtualPath());
            Assert.IsFalse((null as TM_FileStorage).siteData_Handle_VirtualPath("aaa.txt"));
            Assert.IsFalse((null as TM_FileStorage).siteData_Handle_VirtualPath(null));

            tmFileStorage.set_Path_SiteData();

            Assert.IsTrue(tmFileStorage.siteData_Handle_VirtualPath("siteData"));
            Assert.IsFalse(tmFileStorage.siteData_Handle_VirtualPath("abc123"));
            //Create test file in siteData


            var file = util_Create_Test_File_In_SiteData("aaa.txt", "some content").fileName();

            Assert.IsTrue(tmFileStorage.siteData_Handle_VirtualPath(file));
            Assert.IsTrue(tmFileStorage.siteData_Handle_VirtualPath("/" + file));
            Assert.IsTrue(tmFileStorage.siteData_Handle_VirtualPath("/abc/" + file));
            Assert.IsTrue(tmFileStorage.siteData_Handle_VirtualPath("/abc/xyz/" + file));
            Assert.IsTrue(tmFileStorage.siteData_Handle_VirtualPath("/abc/../" + file));
            Assert.IsTrue(tmFileStorage.siteData_Handle_VirtualPath("//" + file));
            Assert.IsTrue(tmFileStorage.siteData_Handle_VirtualPath("../" + file));
            Assert.IsFalse(tmFileStorage.siteData_Handle_VirtualPath("../abc.123"));
            Assert.IsFalse(tmFileStorage.siteData_Handle_VirtualPath("abc.123"));
            Assert.IsFalse(tmFileStorage.siteData_Handle_VirtualPath("//abc.123"));
            Assert.IsFalse(tmFileStorage.siteData_Handle_VirtualPath(null));

            UserGroup.None.assert();
        }
Example #2
0
        [Test] public void set_Path_SiteData()
        {
            var tmFileStorage = new TM_FileStorage();

            var expectedPath = tmFileStorage.path_XmlDatabase().pathCombine(TMConsts.TM_SERVER_DEFAULT_NAME_SITEDATA);

            tmFileStorage.set_Path_SiteData();

            Assert.AreEqual(tmFileStorage.Path_SiteData, expectedPath);
            Assert.True(tmFileStorage.Path_SiteData.dirExists());


            // try with a different Name value
            var tempName = 10.randomLetters();

            tmFileStorage.Server.siteData_Config().Name = tempName;
            tmFileStorage.set_Path_SiteData();
            Assert.IsTrue(tmFileStorage.Path_SiteData.contains(tempName));

            //check bad data handling
            tmFileStorage.Server.siteData_Config().Name = null;
            tmFileStorage.set_Path_SiteData();
            Assert.IsTrue(tmFileStorage.Path_SiteData.contains(TMConsts.TM_SERVER_DEFAULT_NAME_SITEDATA));


            tmFileStorage.Server.siteData_Config().Name = "aaa:bbb"; // will fail to create the SiteData folder and force memory mode
            tmFileStorage.set_Path_SiteData();
            Assert.IsNull(tmFileStorage.Path_SiteData);
        }