mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-02 21:11:10 +00:00
Adds bundled plugin trust and cross-platform native deployment
- embeds the append-only historical and deny trust lists in the API and marks matching bundled plugins as Official without blocking loading - builds and records the current plugin manifest only for official release builds - deploys the PDF native libraries for the supported Linux, macOS and Windows runtimes from the plugin dependency manifest - records release hashes by appending only missing entries to master's manifest and rejects any diff that removes a line - documents the release flow, the supported runtimes and the plugin installer limits
This commit is contained in:
1 parent
3fb8912c7f
commit
b30cbd6b9e
114 files changed
+2708
-243
No files matched your search
+26
-7
@@ -1,11 +1,13 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Nemera.Application.Common.DataAccess.Entities.MediaLibrary.Management;
|
||||
using Nemera.Application.Common.DataAccess.Entities.Plugins;
|
||||
using Nemera.Application.Common.DataAccess.Repositories.MediaLibrary;
|
||||
using Nemera.Application.Common.DataAccess.Repositories.Plugins;
|
||||
using Nemera.Application.Common.DataAccess.UoW;
|
||||
using Nemera.Application.Common.DTO.Filtering;
|
||||
using Nemera.Application.Common.DTO.Pagination;
|
||||
using Nemera.Application.Common.Infrastructure.Plugins;
|
||||
using Nemera.Application.Fixtures.Common.DataAccess.Entities.MediaLibrary.Management;
|
||||
using Nemera.Application.Fixtures.Common.DataAccess.Entities.Plugins;
|
||||
@@ -17,13 +19,9 @@ using Nemera.Infrastructure.Common.Models.DTO.Plugins;
|
||||
using Nemera.Infrastructure.Core.Plugins;
|
||||
using Nemera.Infrastructure.Fixtures.Common.Models.DTO.Plugins;
|
||||
using Nemera.Plugins.Contracts.Core.Plugins;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using NSubstitute;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
@@ -149,6 +147,26 @@ public class PluginDetectionSyncJobTests
|
||||
Arg.Any<Func<object, Exception?, string>>());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task StartAsync_WhenWarningsExist_ShouldLogThemAsWarnings()
|
||||
{
|
||||
// Arrange
|
||||
_mockLogger.IsEnabled(Arg.Any<LogLevel>()).Returns(true);
|
||||
_mockPluginManager.GetPlugins().Returns([]);
|
||||
PluginDetectionSyncJob sut = CreateSut(warnings: ["The SHA-256 checksum of plugin assembly 'LockedPlugin.dll' could not be computed."]);
|
||||
|
||||
// Act
|
||||
await StartAndWaitForExecutionAsync(sut);
|
||||
|
||||
// Assert
|
||||
_mockLogger.Received(1).Log(
|
||||
LogLevel.Warning,
|
||||
Arg.Any<EventId>(),
|
||||
Arg.Is<object>(state => state.ToString()!.Contains("Plugin warning")),
|
||||
Arg.Any<Exception?>(),
|
||||
Arg.Any<Func<object, Exception?, string>>());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task StartAsync_WhenNoPluginsAreLoaded_ShouldOnlySaveChanges()
|
||||
{
|
||||
@@ -287,10 +305,11 @@ public class PluginDetectionSyncJobTests
|
||||
/// Creates the system under test wired to the mocked dependencies.
|
||||
/// </summary>
|
||||
/// <param name="loadErrors">The plugin load errors to feed to the job, when any.</param>
|
||||
/// <param name="warnings">The plugin load warnings to feed to the job, when any.</param>
|
||||
/// <returns>The created job instance.</returns>
|
||||
private PluginDetectionSyncJob CreateSut(IReadOnlyList<PluginLoadErrorDto>? loadErrors = null)
|
||||
private PluginDetectionSyncJob CreateSut(IReadOnlyList<PluginLoadErrorDto>? loadErrors = null, IReadOnlyList<string>? warnings = null)
|
||||
{
|
||||
return new PluginDetectionSyncJob(_mockServiceScopeFactory, _mockPluginManager, loadErrors ?? [], _mockLogger);
|
||||
return new PluginDetectionSyncJob(_mockServiceScopeFactory, _mockPluginManager, loadErrors ?? [], warnings ?? [], _mockLogger);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -15,16 +15,18 @@ namespace Nemera.Infrastructure.UnitTests.Core.Plugins;
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class PluginManagerTests
|
||||
{
|
||||
private PluginManager _sut = new([], [], new HashSet<Guid>());
|
||||
|
||||
[Fact]
|
||||
public void GetPlugins_WhenCalled_ShouldReturnAllLoadedPlugins()
|
||||
{
|
||||
// Arrange
|
||||
IPlugin firstPlugin = CreatePlugin(Guid.NewGuid(), "First Plugin");
|
||||
IPlugin secondPlugin = CreatePlugin(Guid.NewGuid(), "Second Plugin");
|
||||
PluginManager sut = new([firstPlugin, secondPlugin], []);
|
||||
_sut = new([firstPlugin, secondPlugin], [], new HashSet<Guid>());
|
||||
|
||||
// Act
|
||||
IReadOnlyList<IPlugin> result = sut.GetPlugins();
|
||||
IReadOnlyList<IPlugin> result = _sut.GetPlugins();
|
||||
|
||||
// Assert
|
||||
Assert.Equal(2, result.Count);
|
||||
@@ -36,10 +38,10 @@ public class PluginManagerTests
|
||||
public void GetPlugins_WhenNoPluginsWereLoaded_ShouldReturnEmptyList()
|
||||
{
|
||||
// Arrange
|
||||
PluginManager sut = new([], []);
|
||||
_sut = new([], [], new HashSet<Guid>());
|
||||
|
||||
// Act
|
||||
IReadOnlyList<IPlugin> result = sut.GetPlugins();
|
||||
IReadOnlyList<IPlugin> result = _sut.GetPlugins();
|
||||
|
||||
// Assert
|
||||
Assert.Empty(result);
|
||||
@@ -51,10 +53,10 @@ public class PluginManagerTests
|
||||
// Arrange
|
||||
Guid pluginId = Guid.NewGuid();
|
||||
IPlugin expectedPlugin = CreatePlugin(pluginId, "Expected Plugin");
|
||||
PluginManager sut = new([expectedPlugin, CreatePlugin(Guid.NewGuid(), "Other Plugin")], []);
|
||||
_sut = new([expectedPlugin, CreatePlugin(Guid.NewGuid(), "Other Plugin")], [], new HashSet<Guid>());
|
||||
|
||||
// Act
|
||||
IPlugin? result = sut.GetPlugin(pluginId);
|
||||
IPlugin? result = _sut.GetPlugin(pluginId);
|
||||
|
||||
// Assert
|
||||
Assert.Same(expectedPlugin, result);
|
||||
@@ -64,15 +66,43 @@ public class PluginManagerTests
|
||||
public void GetPlugin_WhenPluginWithIdWasNotLoaded_ShouldReturnNull()
|
||||
{
|
||||
// Arrange
|
||||
PluginManager sut = new([CreatePlugin(Guid.NewGuid(), "Loaded Plugin")], []);
|
||||
_sut = new([CreatePlugin(Guid.NewGuid(), "Loaded Plugin")], [], new HashSet<Guid>());
|
||||
|
||||
// Act
|
||||
IPlugin? result = sut.GetPlugin(Guid.NewGuid());
|
||||
IPlugin? result = _sut.GetPlugin(Guid.NewGuid());
|
||||
|
||||
// Assert
|
||||
Assert.Null(result);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void IsOfficial_WhenPluginIsInTheOfficialSet_ShouldReturnTrue()
|
||||
{
|
||||
// Arrange
|
||||
Guid pluginId = Guid.NewGuid();
|
||||
_sut = new([CreatePlugin(pluginId, "Official Plugin")], [], new HashSet<Guid> { pluginId });
|
||||
|
||||
// Act
|
||||
bool result = _sut.IsOfficial(pluginId);
|
||||
|
||||
// Assert
|
||||
Assert.True(result);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void IsOfficial_WhenPluginIsNotInTheOfficialSet_ShouldReturnFalse()
|
||||
{
|
||||
// Arrange
|
||||
Guid pluginId = Guid.NewGuid();
|
||||
_sut = new([CreatePlugin(pluginId, "Unofficial Plugin")], [], new HashSet<Guid>());
|
||||
|
||||
// Act
|
||||
bool result = _sut.IsOfficial(pluginId);
|
||||
|
||||
// Assert
|
||||
Assert.False(result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a mocked plugin with the provided identity.
|
||||
/// </summary>
|
||||
|
||||
Reference in new issue
Block a user