2020-12-20 08:36:11 +01:00
|
|
|
// Copyright (c) Umbraco.
|
|
|
|
|
// See LICENSE for more details.
|
|
|
|
|
|
2020-08-13 10:13:23 +02:00
|
|
|
using System;
|
|
|
|
|
using NUnit.Framework;
|
2021-02-18 11:06:02 +01:00
|
|
|
using Umbraco.Cms.Core.Routing;
|
2020-08-13 10:13:23 +02:00
|
|
|
|
2021-02-18 11:06:02 +01:00
|
|
|
namespace Umbraco.Cms.Tests.UnitTests.Umbraco.Core.Routing
|
2020-08-13 10:13:23 +02:00
|
|
|
{
|
|
|
|
|
[TestFixture]
|
|
|
|
|
public class WebPathTests
|
|
|
|
|
{
|
|
|
|
|
[Test]
|
|
|
|
|
[TestCase("/umbraco", "config", "lang", ExpectedResult = "/umbraco/config/lang")]
|
|
|
|
|
[TestCase("/umbraco", "/config", "/lang", ExpectedResult = "/umbraco/config/lang")]
|
|
|
|
|
[TestCase("/umbraco/", "/config/", "/lang/", ExpectedResult = "/umbraco/config/lang")]
|
|
|
|
|
[TestCase("/umbraco/", "config/", "lang/", ExpectedResult = "/umbraco/config/lang")]
|
Implements Public Access in netcore (#10137)
* Getting new netcore PublicAccessChecker in place
* Adds full test coverage for PublicAccessChecker
* remove PublicAccessComposer
* adjust namespaces, ensure RoleManager works, separate public access controller, reduce content controller
* Implements the required methods on IMemberManager, removes old migrated code
* Updates routing to be able to re-route, Fixes middleware ordering ensuring endpoints are last, refactors pipeline options, adds public access middleware, ensures public access follows all hops
* adds note
* adds note
* Cleans up ext methods, ensures that members identity is added on both front-end and back ends. updates how UmbracoApplicationBuilder works in that it explicitly starts endpoints at the time of calling.
* Changes name to IUmbracoEndpointBuilder
* adds note
* Fixing tests, fixing error describers so there's 2x one for back office, one for members, fixes TryConvertTo, fixes login redirect
* fixing build
* Fixes keepalive, fixes PublicAccessMiddleware to not throw, updates startup code to be more clear and removes magic that registers middleware.
* adds note
* removes unused filter, fixes build
* fixes WebPath and tests
* Looks up entities in one query
* remove usings
* Fix test, remove stylesheet
* Set status code before we write to response to avoid error
* Ensures that users and members are validated when logging in. Shares more code between users and members.
* Fixes RepositoryCacheKeys to ensure the keys are normalized
* oops didn't mean to commit this
* Fix casing issues with caching, stop boxing value types for all cache operations, stop re-creating string keys in DefaultRepositoryCachePolicy
* bah, far out this keeps getting recommitted. sorry
Co-authored-by: Bjarke Berg <mail@bergmania.dk>
2021-04-20 15:11:45 +10:00
|
|
|
[TestCase("umbraco", "config", "lang", ExpectedResult = "umbraco/config/lang")]
|
|
|
|
|
[TestCase("umbraco", ExpectedResult = "umbraco")]
|
2020-08-13 10:13:23 +02:00
|
|
|
[TestCase("~/umbraco", "config", "lang", ExpectedResult = "~/umbraco/config/lang")]
|
|
|
|
|
[TestCase("~/umbraco", "/config", "/lang", ExpectedResult = "~/umbraco/config/lang")]
|
|
|
|
|
[TestCase("~/umbraco/", "/config/", "/lang/", ExpectedResult = "~/umbraco/config/lang")]
|
|
|
|
|
[TestCase("~/umbraco/", "config/", "lang/", ExpectedResult = "~/umbraco/config/lang")]
|
|
|
|
|
[TestCase("~/umbraco", ExpectedResult = "~/umbraco")]
|
Implements Public Access in netcore (#10137)
* Getting new netcore PublicAccessChecker in place
* Adds full test coverage for PublicAccessChecker
* remove PublicAccessComposer
* adjust namespaces, ensure RoleManager works, separate public access controller, reduce content controller
* Implements the required methods on IMemberManager, removes old migrated code
* Updates routing to be able to re-route, Fixes middleware ordering ensuring endpoints are last, refactors pipeline options, adds public access middleware, ensures public access follows all hops
* adds note
* adds note
* Cleans up ext methods, ensures that members identity is added on both front-end and back ends. updates how UmbracoApplicationBuilder works in that it explicitly starts endpoints at the time of calling.
* Changes name to IUmbracoEndpointBuilder
* adds note
* Fixing tests, fixing error describers so there's 2x one for back office, one for members, fixes TryConvertTo, fixes login redirect
* fixing build
* Fixes keepalive, fixes PublicAccessMiddleware to not throw, updates startup code to be more clear and removes magic that registers middleware.
* adds note
* removes unused filter, fixes build
* fixes WebPath and tests
* Looks up entities in one query
* remove usings
* Fix test, remove stylesheet
* Set status code before we write to response to avoid error
* Ensures that users and members are validated when logging in. Shares more code between users and members.
* Fixes RepositoryCacheKeys to ensure the keys are normalized
* oops didn't mean to commit this
* Fix casing issues with caching, stop boxing value types for all cache operations, stop re-creating string keys in DefaultRepositoryCachePolicy
* bah, far out this keeps getting recommitted. sorry
Co-authored-by: Bjarke Berg <mail@bergmania.dk>
2021-04-20 15:11:45 +10:00
|
|
|
[TestCase("https://hello.com/", "/world", ExpectedResult = "https://hello.com/world")]
|
2020-12-20 08:36:11 +01:00
|
|
|
public string Combine(params string[] parts) => WebPath.Combine(parts);
|
2020-08-13 10:13:23 +02:00
|
|
|
|
|
|
|
|
[Test]
|
2020-12-20 08:36:11 +01:00
|
|
|
public void Combine_must_handle_empty_array() => Assert.AreEqual(string.Empty, WebPath.Combine(Array.Empty<string>()));
|
2020-08-13 10:13:23 +02:00
|
|
|
|
|
|
|
|
[Test]
|
2020-12-20 08:36:11 +01:00
|
|
|
public void Combine_must_handle_null() => Assert.Throws<ArgumentNullException>(() => WebPath.Combine(null));
|
2020-08-13 10:13:23 +02:00
|
|
|
}
|
|
|
|
|
}
|