Merge branch temp8 into temp8-di2690

This commit is contained in:
Stephan
2018-11-23 14:58:08 +01:00
614 changed files with 13349 additions and 16438 deletions

View File

@@ -22,20 +22,5 @@ namespace Umbraco.Tests.Web.Controllers
};
[TestCaseSource("TestLegacyJsActionPaths")]
public void Separates_Legacy_JsActions_By_Block_Or_Url(object[] jsActions)
{
var jsBlocks =
BackOfficeController.GetLegacyActionJsForActions(BackOfficeController.LegacyJsActionType.JsBlock,
jsActions.Select(n => n.ToString()));
var jsUrls =
BackOfficeController.GetLegacyActionJsForActions(BackOfficeController.LegacyJsActionType.JsUrl,
jsActions.Select(n => n.ToString()));
Assert.That(jsBlocks.Count() == 4);
Assert.That(jsUrls.Count() == 3);
Assert.That(jsUrls.Last().StartsWith("~/") == false);
}
}
}

View File

@@ -22,7 +22,7 @@ using Umbraco.Web;
using Umbraco.Web.Editors;
using Umbraco.Web.Models.ContentEditing;
using Umbraco.Web.PublishedCache;
using Umbraco.Web._Legacy.Actions;
using Task = System.Threading.Tasks.Task;
using Umbraco.Core.Dictionary;
using Umbraco.Web.PropertyEditors;
@@ -30,6 +30,7 @@ using System;
using Umbraco.Web.WebApi;
using Umbraco.Web.Trees;
using System.Globalization;
using Umbraco.Web.Actions;
namespace Umbraco.Tests.Web.Controllers
{
@@ -53,10 +54,10 @@ namespace Umbraco.Tests.Web.Controllers
{
new EntityPermission(0, 123, new[]
{
ActionBrowse.Instance.Letter.ToString(),
ActionUpdate.Instance.Letter.ToString(),
ActionPublish.Instance.Letter.ToString(),
ActionNew.Instance.Letter.ToString()
ActionBrowse.ActionLetter.ToString(),
ActionUpdate.ActionLetter.ToString(),
ActionPublish.ActionLetter.ToString(),
ActionNew.ActionLetter.ToString()
}),
})));

View File

@@ -5,6 +5,7 @@ using NUnit.Framework;
using Umbraco.Core.Models;
using Umbraco.Core.Models.Entities;
using Umbraco.Core.Models.Membership;
using Umbraco.Core.Security;
using Umbraco.Core.Services;
using Umbraco.Web.Editors;
@@ -33,14 +34,14 @@ namespace Umbraco.Tests.Web.Controllers
var userService = userServiceMock.Object;
//act
var result = ContentController.CheckPermissions(new Dictionary<string, object>(), user, userService, contentService, entityService, 1234);
var result = ContentPermissionsHelper.CheckPermissions(1234, user, userService, contentService, entityService, out var foundContent);
//assert
Assert.IsTrue(result);
Assert.AreEqual(ContentPermissionsHelper.ContentAccess.Granted, result);
}
[Test]
public void Throws_Exception_When_No_Content_Found()
public void No_Content_Found()
{
//arrange
var userMock = new Mock<IUser>();
@@ -60,8 +61,11 @@ namespace Umbraco.Tests.Web.Controllers
var entityServiceMock = new Mock<IEntityService>();
var entityService = entityServiceMock.Object;
//act/assert
Assert.Throws<HttpResponseException>(() => ContentController.CheckPermissions(new Dictionary<string, object>(), user, userService, contentService, entityService, 1234, new[] { 'F' }));
//act
var result = ContentPermissionsHelper.CheckPermissions(1234, user, userService, contentService, entityService, out var foundContent, new[] { 'F' });
//assert
Assert.AreEqual(ContentPermissionsHelper.ContentAccess.NotFound, result);
}
[Test]
@@ -89,10 +93,10 @@ namespace Umbraco.Tests.Web.Controllers
var entityService = entityServiceMock.Object;
//act
var result = ContentController.CheckPermissions(new Dictionary<string, object>(), user, userService, contentService, entityService, 1234, new[] { 'F' });
var result = ContentPermissionsHelper.CheckPermissions(1234, user, userService, contentService, entityService, out var foundContent, new[] { 'F' });
//assert
Assert.IsFalse(result);
Assert.AreEqual(ContentPermissionsHelper.ContentAccess.Denied, result);
}
[Test]
@@ -120,10 +124,10 @@ namespace Umbraco.Tests.Web.Controllers
var entityService = entityServiceMock.Object;
//act
var result = ContentController.CheckPermissions(new Dictionary<string, object>(), user, userService, contentService, entityService, 1234, new[] { 'F' });
var result = ContentPermissionsHelper.CheckPermissions(1234, user, userService, contentService, entityService, out var foundContent, new[] { 'F' });
//assert
Assert.IsFalse(result);
Assert.AreEqual(ContentPermissionsHelper.ContentAccess.Denied, result);
}
[Test]
@@ -152,10 +156,10 @@ namespace Umbraco.Tests.Web.Controllers
var entityService = entityServiceMock.Object;
//act
var result = ContentController.CheckPermissions(new Dictionary<string, object>(), user, userService, contentService, entityService, 1234, new[] { 'F' });
var result = ContentPermissionsHelper.CheckPermissions(1234, user, userService, contentService, entityService, out var foundContent, new[] { 'F' });
//assert
Assert.IsTrue(result);
Assert.AreEqual(ContentPermissionsHelper.ContentAccess.Granted, result);
}
[Test]
@@ -174,10 +178,10 @@ namespace Umbraco.Tests.Web.Controllers
var entityService = entityServiceMock.Object;
//act
var result = ContentController.CheckPermissions(new Dictionary<string, object>(), user, userService, contentService, entityService, -1);
var result = ContentPermissionsHelper.CheckPermissions(-1, user, userService, contentService, entityService, out var foundContent);
//assert
Assert.IsTrue(result);
Assert.AreEqual(ContentPermissionsHelper.ContentAccess.Granted, result);
}
[Test]
@@ -196,10 +200,10 @@ namespace Umbraco.Tests.Web.Controllers
var entityService = entityServiceMock.Object;
//act
var result = ContentController.CheckPermissions(new Dictionary<string, object>(), user, userService, contentService, entityService, -20);
var result = ContentPermissionsHelper.CheckPermissions(-20, user, userService, contentService, entityService, out var foundContent);
//assert
Assert.IsTrue(result);
Assert.AreEqual(ContentPermissionsHelper.ContentAccess.Granted, result);
}
[Test]
@@ -220,10 +224,10 @@ namespace Umbraco.Tests.Web.Controllers
var entityService = entityServiceMock.Object;
//act
var result = ContentController.CheckPermissions(new Dictionary<string, object>(), user, userService, contentService, entityService, -20);
var result = ContentPermissionsHelper.CheckPermissions(-20, user, userService, contentService, entityService, out var foundContent);
//assert
Assert.IsFalse(result);
Assert.AreEqual(ContentPermissionsHelper.ContentAccess.Denied, result);
}
[Test]
@@ -244,10 +248,10 @@ namespace Umbraco.Tests.Web.Controllers
var entityService = entityServiceMock.Object;
//act
var result = ContentController.CheckPermissions(new Dictionary<string, object>(), user, userService, contentService, entityService, -1);
var result = ContentPermissionsHelper.CheckPermissions(-1, user, userService, contentService, entityService, out var foundContent);
//assert
Assert.IsFalse(result);
Assert.AreEqual(ContentPermissionsHelper.ContentAccess.Denied, result);
}
[Test]
@@ -274,10 +278,10 @@ namespace Umbraco.Tests.Web.Controllers
//act
var result = ContentController.CheckPermissions(new Dictionary<string, object>(), user, userService, contentService, entityService, -1, new[] { 'A' });
var result = ContentPermissionsHelper.CheckPermissions(-1, user, userService, contentService, entityService, out var foundContent, new[] { 'A' });
//assert
Assert.IsTrue(result);
Assert.AreEqual(ContentPermissionsHelper.ContentAccess.Granted, result);
}
[Test]
@@ -302,10 +306,10 @@ namespace Umbraco.Tests.Web.Controllers
var contentService = contentServiceMock.Object;
//act
var result = ContentController.CheckPermissions(new Dictionary<string, object>(), user, userService, contentService, entityService, -1, new[] { 'B' });
var result = ContentPermissionsHelper.CheckPermissions(-1, user, userService, contentService, entityService, out var foundContent, new[] { 'B' });
//assert
Assert.IsFalse(result);
Assert.AreEqual(ContentPermissionsHelper.ContentAccess.Denied, result);
}
[Test]
@@ -332,10 +336,10 @@ namespace Umbraco.Tests.Web.Controllers
var contentService = contentServiceMock.Object;
//act
var result = ContentController.CheckPermissions(new Dictionary<string, object>(), user, userService, contentService, entityService, -20, new[] { 'A' });
var result = ContentPermissionsHelper.CheckPermissions(-20, user, userService, contentService, entityService, out var foundContent, new[] { 'A' });
//assert
Assert.IsTrue(result);
Assert.AreEqual(ContentPermissionsHelper.ContentAccess.Granted, result);
}
[Test]
@@ -360,10 +364,10 @@ namespace Umbraco.Tests.Web.Controllers
var contentService = contentServiceMock.Object;
//act
var result = ContentController.CheckPermissions(new Dictionary<string, object>(), user, userService, contentService, entityService, -20, new[] { 'B' });
var result = ContentPermissionsHelper.CheckPermissions(-20, user, userService, contentService, entityService, out var foundContent, new[] { 'B' });
//assert
Assert.IsFalse(result);
Assert.AreEqual(ContentPermissionsHelper.ContentAccess.Denied, result);
}
}