* Remove IExternalLoginService.cs * Remove UmbracoApplicationComponentsInstallingNotification.cs * Remove UmbracoApplicationMainDomAcquiredNotification.cs * Merge IContentTypeWithHistoryCleanup with IContentType.cs * Remove obsolete ctors from notifications * Remove obsolete methods * Remove obsolete method from RequestHandlerSettings.cs * Fix UmbracoBuilder.Repositories.cs * RemoveRemove obsolete constants * Remove obsolete method from IRuntimeMinifier * Remove SetLastLogin from IMemberRepository * Revert "RemoveRemove obsolete constants" This reverts commit cddb8ad1cf3d02bd9949d52bed91b45c8d2d66a9. * Remove obsoleted Constants-Conventions.cs * Remove obsolete ctors * Make ContentData properties immutable * remove obsolete static property from TestOptionAttributeBase * Merge IMacroWithAliasService into IMacroService * Remove IUserComposer * remove obsolete AddOEmbedProvider method * remove obsolete static EmbedProvidersCollectionBuilder * remove obsolete HasFlagAll<T> method * Remove obsolete LocalizedTextService property from BaseHttpHeaderCheck * Remove obsolete GetDefaultFIleContent method from ViewHelper * Remove more obsolete ctors and methods * Remove obsolete ctor from RelationType * Remove more obsolete methods * Remove IExternalLoginRepository * merge IMacroWithAliasRepository with IMacroRepository * Remove obsolete methods from ExternalLoginRepository * Remove obsolete method from IUserRepository * Remove obsolete SetLastLogin, as it was NoOp * Remove wierd SetLastLogin method from UserService * Remove GetLogLevel from ILogViewer * Remove more obsolete methods and ctors * Remove more obsoletes * Use other method in BackOfficeServerVariables.cs since GetAllTypes is now removed * Remove obsolete ctor * Remove ConfigureIISServerOptions * Remove more obsolete methods * Merge ITwoFactorLoginService2 with ITwoFactorLoginService * Re-introduce GetCustomGenericProperties in MemberTabsAndPropertiesMapper.cs Co-authored-by: Nikolaj Geisle <niko737@edu.ucl.dk>
100 lines
3.9 KiB
C#
100 lines
3.9 KiB
C#
using System;
|
|
using Microsoft.AspNetCore.Builder;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using Microsoft.Extensions.Options;
|
|
using NUnit.Framework;
|
|
using Umbraco.Cms.Core;
|
|
using Umbraco.Cms.Core.Configuration.Models;
|
|
using Umbraco.Cms.Core.DependencyInjection;
|
|
using Umbraco.Cms.Core.IO;
|
|
using Umbraco.Cms.Core.Packaging;
|
|
using Umbraco.Cms.Core.PropertyEditors;
|
|
using Umbraco.Cms.Core.Serialization;
|
|
using Umbraco.Cms.Core.Services;
|
|
using Umbraco.Cms.Core.Strings;
|
|
using Umbraco.Cms.Infrastructure.Migrations;
|
|
using Umbraco.Cms.Infrastructure.Packaging;
|
|
using Umbraco.Cms.Tests.Common.Testing;
|
|
using Umbraco.Cms.Tests.Integration.Testing;
|
|
using Umbraco.Extensions;
|
|
|
|
namespace Umbraco.Cms.Tests.Integration.Umbraco.Core
|
|
{
|
|
[TestFixture]
|
|
[UmbracoTest(Database = UmbracoTestOptions.Database.NewSchemaPerTest)]
|
|
public class RuntimeStateTests : UmbracoIntegrationTest
|
|
{
|
|
private IRuntimeState RuntimeState => Services.GetRequiredService<IRuntimeState>();
|
|
|
|
protected override void CustomTestSetup(IUmbracoBuilder builder)
|
|
{
|
|
PackageMigrationPlanCollectionBuilder migrations = builder.PackageMigrationPlans();
|
|
migrations.Clear();
|
|
migrations.Add<TestMigrationPlan>();
|
|
}
|
|
|
|
[Test]
|
|
public void GivenPackageMigrationsExist_WhenLatestStateIsRegistered_ThenLevelIsRun()
|
|
{
|
|
// Add the final state to the keyvalue storage
|
|
IKeyValueService keyValueService = Services.GetRequiredService<IKeyValueService>();
|
|
keyValueService.SetValue(
|
|
Constants.Conventions.Migrations.KeyValuePrefix + TestMigrationPlan.TestMigrationPlanName,
|
|
TestMigrationPlan.TestMigrationFinalState.ToString());
|
|
|
|
RuntimeState.DetermineRuntimeLevel();
|
|
|
|
Assert.AreEqual(RuntimeLevel.Run, RuntimeState.Level);
|
|
Assert.AreEqual(RuntimeLevelReason.Run, RuntimeState.Reason);
|
|
}
|
|
|
|
[Test]
|
|
public void GivenPackageMigrationsExist_WhenUnattendedMigrations_ThenLevelIsRun()
|
|
{
|
|
RuntimeState.DetermineRuntimeLevel();
|
|
|
|
Assert.AreEqual(RuntimeLevel.Run, RuntimeState.Level);
|
|
Assert.AreEqual(RuntimeLevelReason.UpgradePackageMigrations, RuntimeState.Reason);
|
|
}
|
|
|
|
[Test]
|
|
public void GivenPackageMigrationsExist_WhenNotUnattendedMigrations_ThenLevelIsRun()
|
|
{
|
|
var unattendedOptions = Services.GetRequiredService<IOptions<UnattendedSettings>>();
|
|
unattendedOptions.Value.PackageMigrationsUnattended = false;
|
|
|
|
RuntimeState.DetermineRuntimeLevel();
|
|
|
|
Assert.AreEqual(RuntimeLevel.Run, RuntimeState.Level);
|
|
Assert.AreEqual(RuntimeLevelReason.Run, RuntimeState.Reason);
|
|
}
|
|
|
|
private class TestMigrationPlan : PackageMigrationPlan
|
|
{
|
|
public const string TestMigrationPlanName = "Test";
|
|
public static Guid TestMigrationFinalState => new Guid("BB02C392-4007-4A6C-A550-28BA2FF7E43D");
|
|
|
|
public TestMigrationPlan() : base(TestMigrationPlanName)
|
|
{
|
|
}
|
|
|
|
protected override void DefinePlan()
|
|
{
|
|
To<TestMigration>(TestMigrationFinalState);
|
|
}
|
|
}
|
|
|
|
private class TestMigration : PackageMigrationBase
|
|
{
|
|
public TestMigration(IPackagingService packagingService, IMediaService mediaService, MediaFileManager mediaFileManager, MediaUrlGeneratorCollection mediaUrlGenerators, IShortStringHelper shortStringHelper, IContentTypeBaseServiceProvider contentTypeBaseServiceProvider, IMigrationContext context, IOptions<PackageMigrationSettings> options) : base(packagingService, mediaService, mediaFileManager, mediaUrlGenerators, shortStringHelper, contentTypeBaseServiceProvider, context, options)
|
|
{
|
|
}
|
|
|
|
protected override void Migrate()
|
|
{
|
|
ImportPackage.FromEmbeddedResource<TestMigration>().Do();
|
|
}
|
|
}
|
|
}
|
|
}
|