public async Task OD_Security_SetPermissions_NotPropagates() { await IsolatedODataTestAsync(async() => { InstallCarContentType(); var testRoot = CreateTestRoot("ODataTestRoot"); var content = Content.CreateNew("Folder", testRoot, Guid.NewGuid().ToString()); content.Save(); var folderPath = ODataMiddleware.GetEntityUrl(content.Path); var folderRepoPath = content.Path; content = Content.CreateNew("Car", testRoot, Guid.NewGuid().ToString()); content.Save(); var carRepoPath = content.Path; // ACTION var response = await ODataPostAsync( $"/OData.svc/{folderPath}/SetPermissions", "", "{r:[{identity:\"/Root/IMS/BuiltIn/Portal/Visitor\"," + " OpenMinor:\"allow\", propagates:false}]}") .ConfigureAwait(false); // ASSERT AssertNoError(response); Assert.AreEqual(0, response.Result.Length); Assert.AreEqual(204, response.StatusCode); var folder = Node.LoadNode(folderRepoPath); var car = Node.LoadNode(carRepoPath); Assert.IsTrue(folder.Security.HasPermission(User.Visitor as IUser, PermissionType.OpenMinor)); Assert.IsFalse(car.Security.HasPermission(User.Visitor as IUser, PermissionType.OpenMinor)); }).ConfigureAwait(false); }
public async Task OD_POST_Creation_FIX_InconsistentNameAfterCreation() { await ODataTestAsync(async() => { InstallCarContentType(); var testRoot = CreateTestRoot("ODataTestRoot"); var name = "Car"; // ACTION var names = new string[3]; for (int i = 0; i < 3; i++) { var response = await ODataPostAsync( String.Concat("/OData.svc", ODataMiddleware.GetEntityUrl(testRoot.Path)), "?metadata=no&$select=Name", $@"models=[{{""__ContentType"":""Car"",""Name"":""{name}""}}]") .ConfigureAwait(false); var entity = GetEntity(response); names[i] = entity.Name; } // ASSERT Assert.AreNotEqual(names[0], names[1]); Assert.AreNotEqual(names[0], names[2]); Assert.AreNotEqual(names[1], names[2]); }); }
public async Task OD_Security_SetPermissions() { await IsolatedODataTestAsync(async() => { InstallCarContentType(); var testRoot = CreateTestRoot("ODataTestRoot"); var content = Content.CreateNew("Car", testRoot, Guid.NewGuid().ToString()); content.Save(); var resourcePath = ODataMiddleware.GetEntityUrl(content.Path); // ACTION var response = await ODataPostAsync( string.Concat("/OData.svc/", resourcePath, "/SetPermissions"), "", "{r:[" + "{identity:\"/Root/IMS/BuiltIn/Portal/Visitor\", OpenMinor:\"allow\", Save:\"deny\"}," + "{identity:\"/Root/IMS/BuiltIn/Portal/Owners\", Custom16:\"A\", Custom17:\"1\"}]}") .ConfigureAwait(false); // ASSERT AssertNoError(response); Assert.AreEqual(0, response.Result.Length); Assert.AreEqual(204, response.StatusCode); // 204 No Content }).ConfigureAwait(false); }
public async Task OD_Security_Break() { await IsolatedODataTestAsync(async() => { InstallCarContentType(); var testRoot = CreateTestRoot("ODataTestRoot"); var content = Content.CreateNew("Car", testRoot, Guid.NewGuid().ToString()); content.Save(); var resourcePath = ODataMiddleware.GetEntityUrl(content.Path); // ACTION 1: Break var response = await ODataPostAsync( $"/OData.svc/{resourcePath}/SetPermissions", "", "{inheritance:\"break\"}") .ConfigureAwait(false); // ASSERT 1: Not inherited AssertNoError(response); var entity = GetEntity(response); Assert.AreEqual(content.Id, entity.Id); Assert.AreEqual(200, response.StatusCode); var node = Node.LoadNode(content.Id); Assert.IsFalse(node.Security.IsInherited); // ACTION 2: Unbreak response = await ODataPostAsync( $"/OData.svc/{resourcePath}/SetPermissions", "", "{inheritance:\"unbreak\"}") .ConfigureAwait(false); // ASSERT 2: Inherited AssertNoError(response); entity = GetEntity(response); Assert.AreEqual(content.Id, entity.Id); Assert.AreEqual(200, response.StatusCode); node = Node.LoadNode(content.Id); Assert.IsTrue(node.Security.IsInherited); }).ConfigureAwait(false); }