* Sends GUID instead of the numeric ID for SignalR Preview Hub * Add possibility to set cookies as HttpOnly * Set UMB_PREVIEW cookie as HttpOnly * fixup! Add possibility to set cookies as HttpOnly * Refactor ContentFinderByIdPath to more readable * Create ContentFinderByKeyPath reusing logic from ContentFinderByIdPath * Add a comment to DisableFindContentByIdPath setting * Append new content finder * Change ordering of content finders registrations * Refactor with a base class * Update/refactor and add tests regarding ContentFindersByIdentifier * Fix comment * Avoiding breaking change * Make usages use non-obsolete implementation * Fixed todo in config instead of use the one old legacy name even more. Also obsoleted the ContentFinderByIdPath * add `preview` as an allowed backoffice client route --------- Co-authored-by: Sven Geusens <sge@umbraco.dk> Co-authored-by: Bjarke Berg <mail@bergmania.dk> Co-authored-by: Jacob Overgaard <752371+iOvergaard@users.noreply.github.com>
51 lines
1.6 KiB
C#
51 lines
1.6 KiB
C#
using Microsoft.Extensions.Logging;
|
|
using Microsoft.Extensions.Options;
|
|
using Moq;
|
|
using NUnit.Framework;
|
|
using Umbraco.Cms.Core.Configuration.Models;
|
|
using Umbraco.Cms.Core.Routing;
|
|
using Umbraco.Cms.Core.Web;
|
|
using Umbraco.Extensions;
|
|
|
|
namespace Umbraco.Cms.Tests.UnitTests.Umbraco.Core.Routing;
|
|
|
|
[TestFixture]
|
|
public class ContentFinderByIdTests : ContentFinderByIdentifierTestsBase
|
|
{
|
|
[SetUp]
|
|
public override void Setup()
|
|
{
|
|
base.Setup();
|
|
}
|
|
|
|
[TestCase("/1046", 1046, true)]
|
|
[TestCase("/1046", 1047, false)]
|
|
public async Task Lookup_By_Id(string urlAsString, int nodeId, bool shouldSucceed)
|
|
{
|
|
PopulateCache(nodeId, Guid.NewGuid());
|
|
|
|
var umbracoContextAccessor = GetUmbracoContextAccessor(urlAsString);
|
|
var umbracoContext = umbracoContextAccessor.GetRequiredUmbracoContext();
|
|
var publishedRouter = CreatePublishedRouter(umbracoContextAccessor);
|
|
var frequest = await publishedRouter.CreateRequestAsync(umbracoContext.CleanedUmbracoUrl);
|
|
var webRoutingSettings = new WebRoutingSettings();
|
|
var lookup = new ContentFinderByIdPath(
|
|
Mock.Of<IOptionsMonitor<WebRoutingSettings>>(x => x.CurrentValue == webRoutingSettings),
|
|
Mock.Of<ILogger<ContentFinderByIdPath>>(),
|
|
Mock.Of<IRequestAccessor>(),
|
|
umbracoContextAccessor);
|
|
|
|
var result = await lookup.TryFindContent(frequest);
|
|
|
|
Assert.AreEqual(shouldSucceed, result);
|
|
if (shouldSucceed)
|
|
{
|
|
Assert.AreEqual(frequest.PublishedContent!.Id, nodeId);
|
|
}
|
|
else
|
|
{
|
|
Assert.IsNull(frequest.PublishedContent);
|
|
}
|
|
}
|
|
}
|