public void ContentProtector_ListIsImmutable() { Test(builder => { // Additional path builder.ProtectContent("/Root/TestFolder"); }, () => { var originalList = ContentProtector.GetProtectedPaths(); var expectedFirst = originalList[0]; originalList[0] = null; var actualList = ContentProtector.GetProtectedPaths(); var actualFirst = actualList[0]; Assert.AreEqual(expectedFirst, actualFirst); }); }
public void ContentProtector_ParentAxis() { var originalList = new string[0]; Test(builder => { originalList = ContentProtector.GetProtectedPaths(); // Add a deep path builder.ProtectContent("/Root/A/B/C"); }, () => { var actual = string.Join(" ", ContentProtector.GetProtectedPaths().Except(originalList)); // The whole parent axis added but the "Except" operation removes the "/Root". var expected = "/Root/A /Root/A/B /Root/A/B/C"; Assert.AreEqual(expected, actual); }); }
/// <summary> /// Adds the passed paths and all parent paths to the not-deletable Content whitelist. /// </summary> /// <param name="builder">The <see cref="IRepositoryBuilder"/> instance.</param> /// <param name="paths">Repository paths that will be added to the whitelist.</param> /// <returns>The passed <see cref="IRepositoryBuilder"/> instance.</returns> public static IRepositoryBuilder ProtectContent(this IRepositoryBuilder builder, params string[] paths) { ContentProtector.AddPaths(paths); return(builder); }