diff --git a/src/Lumina.Application/Common/Infrastructure/Themes/IThemeService.cs b/src/Lumina.Application/Common/Infrastructure/Themes/IThemeService.cs
index 4ac5fae5..e9c2bd4a 100644
--- a/src/Lumina.Application/Common/Infrastructure/Themes/IThemeService.cs
+++ b/src/Lumina.Application/Common/Infrastructure/Themes/IThemeService.cs
@@ -14,11 +14,6 @@ namespace Lumina.Application.Common.Infrastructure.Themes;
///
public interface IThemeService
{
- ///
- /// Gets a value indicating whether theme templates may contain script elements and theme assets may include script files.
- ///
- bool AllowThemeScripts { get; }
-
///
/// Gets the maximum allowed size of a theme archive, in bytes.
///
diff --git a/src/Lumina.Application/Core/Themes/Management/Queries/GetThemeSettings/GetThemeSettingsQueryHandler.cs b/src/Lumina.Application/Core/Themes/Management/Queries/GetThemeSettings/GetThemeSettingsQueryHandler.cs
index 595c53b5..ea90c975 100644
--- a/src/Lumina.Application/Core/Themes/Management/Queries/GetThemeSettings/GetThemeSettingsQueryHandler.cs
+++ b/src/Lumina.Application/Core/Themes/Management/Queries/GetThemeSettings/GetThemeSettingsQueryHandler.cs
@@ -35,7 +35,7 @@ public class GetThemeSettingsQueryHandler : IQueryHandler
public Task> HandleAsync(GetThemeSettingsQuery query, CancellationToken cancellationToken)
{
- ThemeSettingsResponse response = new(_themeService.MaxArchiveBytes, _themeService.AllowThemeScripts, _themeService.DefaultThemeId);
+ ThemeSettingsResponse response = new(_themeService.MaxArchiveBytes, _themeService.DefaultThemeId);
return Task.FromResult(Result.From(response));
}
}
diff --git a/src/Lumina.Contracts/Responses/Themes/ThemeSettingsResponse.cs b/src/Lumina.Contracts/Responses/Themes/ThemeSettingsResponse.cs
index c21851cc..def03523 100644
--- a/src/Lumina.Contracts/Responses/Themes/ThemeSettingsResponse.cs
+++ b/src/Lumina.Contracts/Responses/Themes/ThemeSettingsResponse.cs
@@ -9,11 +9,9 @@ namespace Lumina.Contracts.Responses.Themes;
/// Represents a theme settings response.
///
/// The maximum allowed size of a theme archive, in bytes.
-/// Whether theme templates may contain script elements and theme assets may include script files.
/// The identifier of the theme selected when no valid current theme is available.
[DebuggerDisplay("MaxArchiveBytes: {MaxArchiveBytes}")]
public record ThemeSettingsResponse(
long MaxArchiveBytes,
- bool AllowThemeScripts,
string DefaultThemeId
);
diff --git a/src/Lumina.Infrastructure/Common/Models/DTO/Configuration/ThemeEngineOptionsDto.cs b/src/Lumina.Infrastructure/Common/Models/DTO/Configuration/ThemeEngineOptionsDto.cs
index 1d2623b6..1a416220 100644
--- a/src/Lumina.Infrastructure/Common/Models/DTO/Configuration/ThemeEngineOptionsDto.cs
+++ b/src/Lumina.Infrastructure/Common/Models/DTO/Configuration/ThemeEngineOptionsDto.cs
@@ -46,9 +46,4 @@ public sealed class ThemeEngineOptionsDto
/// Gets or sets the maximum allowed number of entries in a theme pack archive.
///
public int MaxEntries { get; set; } = 250;
-
- ///
- /// Gets or sets a value indicating whether script elements in theme templates and script files in theme assets are allowed to be served.
- ///
- public bool AllowThemeScripts { get; set; }
}
diff --git a/src/Lumina.Infrastructure/Core/Themes/ThemeService.cs b/src/Lumina.Infrastructure/Core/Themes/ThemeService.cs
index aa90d83e..0a471cde 100644
--- a/src/Lumina.Infrastructure/Core/Themes/ThemeService.cs
+++ b/src/Lumina.Infrastructure/Core/Themes/ThemeService.cs
@@ -45,12 +45,6 @@ public sealed class ThemeService : IThemeService
"^[A-Za-z0-9][A-Za-z0-9._ -]*$",
RegexOptions.Compiled | RegexOptions.CultureInvariant);
- // strips every script element from a template, both the inline content and the src attribute variants,
- // so that no script bundled in a theme is executed in any client when scripts are disabled
- private static readonly Regex s_scriptElementPattern = new(
- "",
- RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.CultureInvariant);
-
private static readonly JsonSerializerOptions s_manifestJsonOptions = new(JsonSerializerDefaults.Web)
{
PropertyNameCaseInsensitive = true,
@@ -87,11 +81,6 @@ public sealed class ThemeService : IThemeService
_mutationGate = s_storageGates.GetOrAdd(_storageRoot, static _ => new SemaphoreSlim(1, 1));
}
- ///
- /// Gets a value indicating whether theme templates may contain script elements and theme assets may include script files.
- ///
- public bool AllowThemeScripts => _options.AllowThemeScripts;
-
///
/// Gets the maximum allowed size of a theme archive, in bytes.
///
@@ -280,8 +269,6 @@ public sealed class ThemeService : IThemeService
return Errors.Themes.ThemeFilesUnreadable;
string template = await File.ReadAllTextAsync(fullPathResult.Value, cancellationToken);
- if (!AllowThemeScripts)
- template = StripScriptElements(template);
return template;
}
@@ -330,10 +317,6 @@ public sealed class ThemeService : IThemeService
if (!normalizedPath.StartsWith("assets/", StringComparison.Ordinal))
return PackageInvalid("The requested asset is not located under the assets directory.");
- // scripts in theme assets are gated globally: when disabled, script files are not served at all
- if (!AllowThemeScripts && string.Equals(Path.GetExtension(normalizedPath), ".js", StringComparison.OrdinalIgnoreCase))
- return Errors.Themes.ThemeFilesUnreadable;
-
Result fullPathResult = ResolveContainedPath(ResolveThemePath(themeId), normalizedPath);
if (fullPathResult.IsFailure)
return fullPathResult.Errors;
@@ -782,16 +765,6 @@ public sealed class ThemeService : IThemeService
return Error.Validation(code: "Theme.Package.Invalid", description: description);
}
- ///
- /// Removes every script element from a theme template, so that no script bundled in the theme runs when scripts are disabled.
- ///
- /// The template content to strip script elements from.
- /// The template content without script elements.
- private static string StripScriptElements(string template)
- {
- return s_scriptElementPattern.Replace(template, string.Empty);
- }
-
///
/// Resolves the storage path of a theme pack directory for a theme identifier.
///
diff --git a/src/Lumina.Infrastructure/appsettings.shared.json b/src/Lumina.Infrastructure/appsettings.shared.json
index 6ccc0db4..7790a2e1 100644
--- a/src/Lumina.Infrastructure/appsettings.shared.json
+++ b/src/Lumina.Infrastructure/appsettings.shared.json
@@ -13,8 +13,7 @@
"MaxArchiveBytes": 8388608,
"MaxExpandedBytes": 25165824,
"MaxSingleFileBytes": 6291456,
- "MaxEntries": 250,
- "AllowThemeScripts": true
+ "MaxEntries": 250
},
"ConnectionStrings": {
"DefaultConnection": "Server=;Database=;User Id=;Password=;"
diff --git a/src/Lumina.Presentation.Api/Core/Endpoints/Themes/Queries/GetThemeSettings/GetThemeSettingsEndpointSummary.cs b/src/Lumina.Presentation.Api/Core/Endpoints/Themes/Queries/GetThemeSettings/GetThemeSettingsEndpointSummary.cs
index 791d45f6..ad8c9349 100644
--- a/src/Lumina.Presentation.Api/Core/Endpoints/Themes/Queries/GetThemeSettings/GetThemeSettingsEndpointSummary.cs
+++ b/src/Lumina.Presentation.Api/Core/Endpoints/Themes/Queries/GetThemeSettings/GetThemeSettingsEndpointSummary.cs
@@ -19,12 +19,11 @@ public class GetThemeSettingsEndpointSummary : Summary
public required string CurrentThemeId { get; init; }
- ///
- /// Gets or sets a value indicating whether theme templates may load script files.
- ///
- public required bool AllowThemeScripts { get; init; }
-
///
/// Gets or sets the maximum allowed size of a theme archive, in bytes.
///
diff --git a/src/Lumina.Presentation.Web/Common/DTO/Themes/ThemeSettingsResponseDto.cs b/src/Lumina.Presentation.Web/Common/DTO/Themes/ThemeSettingsResponseDto.cs
index 636830db..8fe7ae73 100644
--- a/src/Lumina.Presentation.Web/Common/DTO/Themes/ThemeSettingsResponseDto.cs
+++ b/src/Lumina.Presentation.Web/Common/DTO/Themes/ThemeSettingsResponseDto.cs
@@ -9,11 +9,9 @@ namespace Lumina.Presentation.Web.Common.DTO.Themes;
/// Data transfer object for the theme engine settings returned by the remote API.
///
/// The maximum allowed size of a theme archive, in bytes.
-/// Whether theme templates may contain script elements and theme assets may include script files.
/// The identifier of the theme selected when no valid current theme is available.
[DebuggerDisplay("MaxArchiveBytes: {MaxArchiveBytes}")]
public sealed record ThemeSettingsResponseDto(
long MaxArchiveBytes,
- bool AllowThemeScripts,
string DefaultThemeId
);
diff --git a/src/Lumina.Presentation.Web/Core/Endpoints/Admin/Themes/GetThemes/GetThemesEndpoint.cs b/src/Lumina.Presentation.Web/Core/Endpoints/Admin/Themes/GetThemes/GetThemesEndpoint.cs
index d1fd73ee..0782a519 100644
--- a/src/Lumina.Presentation.Web/Core/Endpoints/Admin/Themes/GetThemes/GetThemesEndpoint.cs
+++ b/src/Lumina.Presentation.Web/Core/Endpoints/Admin/Themes/GetThemes/GetThemesEndpoint.cs
@@ -58,7 +58,6 @@ public class GetThemesEndpoint : BaseEndpoint
{
Themes = themes,
CurrentThemeId = currentTheme.Id,
- AllowThemeScripts = settings.AllowThemeScripts,
MaxArchiveBytes = settings.MaxArchiveBytes
};
return JsonSuccess(themeAdmin);
diff --git a/tests/Common/Lumina.Contracts.Fixtures/Core/Responses/Themes/ThemeSettingsResponseFixture.cs b/tests/Common/Lumina.Contracts.Fixtures/Core/Responses/Themes/ThemeSettingsResponseFixture.cs
index 1a807539..2e091f3c 100644
--- a/tests/Common/Lumina.Contracts.Fixtures/Core/Responses/Themes/ThemeSettingsResponseFixture.cs
+++ b/tests/Common/Lumina.Contracts.Fixtures/Core/Responses/Themes/ThemeSettingsResponseFixture.cs
@@ -20,17 +20,14 @@ public class ThemeSettingsResponseFixture
/// Creates a random valid .
///
/// Optional. The maximum allowed size of a theme archive, in bytes.
- /// Optional. Whether theme templates may contain script elements.
/// Optional. The identifier of the default theme.
/// The created .
public ThemeSettingsResponse Create(
long? maxArchiveBytes = null,
- bool? allowThemeScripts = null,
string? defaultThemeId = null)
{
return new ThemeSettingsResponse(
maxArchiveBytes ?? _faker.Random.Long(1_000_000, 100_000_000),
- allowThemeScripts ?? _faker.Random.Bool(),
defaultThemeId ?? _faker.Lorem.Slug(2));
}
diff --git a/tests/Common/Lumina.Infrastructure.Fixtures/Common/Models/DTO/Configuration/ThemeEngineOptionsDtoFixture.cs b/tests/Common/Lumina.Infrastructure.Fixtures/Common/Models/DTO/Configuration/ThemeEngineOptionsDtoFixture.cs
index b61fbdd5..fa0c6533 100644
--- a/tests/Common/Lumina.Infrastructure.Fixtures/Common/Models/DTO/Configuration/ThemeEngineOptionsDtoFixture.cs
+++ b/tests/Common/Lumina.Infrastructure.Fixtures/Common/Models/DTO/Configuration/ThemeEngineOptionsDtoFixture.cs
@@ -25,7 +25,6 @@ public class ThemeEngineOptionsDtoFixture
/// Optional maximum total size of an extracted theme pack, in bytes.
/// Optional maximum size of a single file within a theme pack, in bytes.
/// Optional maximum number of entries in a theme pack archive.
- /// Optional value indicating whether script elements are allowed.
/// A configured instance.
public ThemeEngineOptionsDto Create(
string? storagePath = null,
@@ -34,8 +33,7 @@ public class ThemeEngineOptionsDtoFixture
long? maxArchiveBytes = null,
long? maxExpandedBytes = null,
long? maxSingleFileBytes = null,
- int? maxEntries = null,
- bool? allowThemeScripts = null)
+ int? maxEntries = null)
{
Faker faker = new();
return new ThemeEngineOptionsDto
@@ -46,8 +44,7 @@ public class ThemeEngineOptionsDtoFixture
MaxArchiveBytes = maxArchiveBytes ?? faker.Random.Long(1_000_000, 100_000_000),
MaxExpandedBytes = maxExpandedBytes ?? faker.Random.Long(10_000_000, 500_000_000),
MaxSingleFileBytes = maxSingleFileBytes ?? faker.Random.Long(1_000_000, 50_000_000),
- MaxEntries = maxEntries ?? faker.Random.Int(1, 1000),
- AllowThemeScripts = allowThemeScripts ?? faker.Random.Bool()
+ MaxEntries = maxEntries ?? faker.Random.Int(1, 1000)
};
}
diff --git a/tests/Common/Lumina.Presentation.Web.Fixtures/Common/DTO/Themes/ThemeSettingsResponseDtoFixture.cs b/tests/Common/Lumina.Presentation.Web.Fixtures/Common/DTO/Themes/ThemeSettingsResponseDtoFixture.cs
index fcb6ece5..03f0032e 100644
--- a/tests/Common/Lumina.Presentation.Web.Fixtures/Common/DTO/Themes/ThemeSettingsResponseDtoFixture.cs
+++ b/tests/Common/Lumina.Presentation.Web.Fixtures/Common/DTO/Themes/ThemeSettingsResponseDtoFixture.cs
@@ -18,18 +18,15 @@ public class ThemeSettingsResponseDtoFixture
/// Creates a new instance with randomized test data.
///
/// Optional maximum allowed archive size, in bytes.
- /// Whether theme templates may load script files.
/// Optional identifier of the fallback theme.
/// A configured instance.
public ThemeSettingsResponseDto Create(
long? maxArchiveBytes = null,
- bool? allowThemeScripts = null,
string? defaultThemeId = null)
{
Faker faker = new();
return new ThemeSettingsResponseDto(
MaxArchiveBytes: maxArchiveBytes ?? faker.Random.Long(1024 * 1024, 256 * 1024 * 1024),
- AllowThemeScripts: allowThemeScripts ?? faker.Random.Bool(),
DefaultThemeId: defaultThemeId ?? faker.Lorem.Word()
);
}
diff --git a/tests/UnitTests/Lumina.Application.UnitTests/Core/Themes/Management/Queries/GetThemeSettings/GetThemeSettingsQueryHandlerTests.cs b/tests/UnitTests/Lumina.Application.UnitTests/Core/Themes/Management/Queries/GetThemeSettings/GetThemeSettingsQueryHandlerTests.cs
index 64904a3d..4ff76e37 100644
--- a/tests/UnitTests/Lumina.Application.UnitTests/Core/Themes/Management/Queries/GetThemeSettings/GetThemeSettingsQueryHandlerTests.cs
+++ b/tests/UnitTests/Lumina.Application.UnitTests/Core/Themes/Management/Queries/GetThemeSettings/GetThemeSettingsQueryHandlerTests.cs
@@ -37,10 +37,8 @@ public class GetThemeSettingsQueryHandlerTests
// Arrange
GetThemeSettingsQuery query = _getThemeSettingsQueryFixture.Create();
long maxArchiveBytes = 50_000_000;
- bool allowThemeScripts = false;
string defaultThemeId = "default-theme";
_mockThemeService.MaxArchiveBytes.Returns(maxArchiveBytes);
- _mockThemeService.AllowThemeScripts.Returns(allowThemeScripts);
_mockThemeService.DefaultThemeId.Returns(defaultThemeId);
// Act
@@ -49,7 +47,6 @@ public class GetThemeSettingsQueryHandlerTests
// Assert
Assert.False(result.IsFailure);
Assert.Equal(maxArchiveBytes, result.Value.MaxArchiveBytes);
- Assert.Equal(allowThemeScripts, result.Value.AllowThemeScripts);
Assert.Equal(defaultThemeId, result.Value.DefaultThemeId);
}
}
diff --git a/tests/UnitTests/Lumina.Infrastructure.UnitTests/Core/Themes/ThemeServiceTests.cs b/tests/UnitTests/Lumina.Infrastructure.UnitTests/Core/Themes/ThemeServiceTests.cs
index fd609d97..204d80d3 100644
--- a/tests/UnitTests/Lumina.Infrastructure.UnitTests/Core/Themes/ThemeServiceTests.cs
+++ b/tests/UnitTests/Lumina.Infrastructure.UnitTests/Core/Themes/ThemeServiceTests.cs
@@ -51,8 +51,7 @@ public class ThemeServiceTests : IDisposable
maxArchiveBytes: 8 * 1024 * 1024,
maxExpandedBytes: 24 * 1024 * 1024,
maxSingleFileBytes: 6 * 1024 * 1024,
- maxEntries: 250,
- allowThemeScripts: false);
+ maxEntries: 250);
_sut = CreateSut(_options);
}
@@ -76,52 +75,6 @@ public class ThemeServiceTests : IDisposable
}
}
- [Fact]
- public void AllowThemeScripts_WhenConfiguredFalse_ShouldReturnFalse()
- {
- // Arrange
- ThemeEngineOptionsDto options = _themeEngineOptionsDtoFixture.Create(
- storagePath: Path.Combine(_testRootPath, "themes"),
- bundledThemesPath: Path.Combine(_testRootPath, "bundled"),
- defaultThemeId: "lumina-default",
- maxArchiveBytes: 8 * 1024 * 1024,
- maxExpandedBytes: 24 * 1024 * 1024,
- maxSingleFileBytes: 6 * 1024 * 1024,
- maxEntries: 250,
- allowThemeScripts: false);
- options.AllowThemeScripts = false;
- ThemeService sut = CreateSut(options);
-
- // Act
- bool result = sut.AllowThemeScripts;
-
- // Assert
- Assert.False(result);
- }
-
- [Fact]
- public void AllowThemeScripts_WhenConfiguredTrue_ShouldReturnTrue()
- {
- // Arrange
- ThemeEngineOptionsDto options = _themeEngineOptionsDtoFixture.Create(
- storagePath: Path.Combine(_testRootPath, "themes"),
- bundledThemesPath: Path.Combine(_testRootPath, "bundled"),
- defaultThemeId: "lumina-default",
- maxArchiveBytes: 8 * 1024 * 1024,
- maxExpandedBytes: 24 * 1024 * 1024,
- maxSingleFileBytes: 6 * 1024 * 1024,
- maxEntries: 250,
- allowThemeScripts: false);
- options.AllowThemeScripts = true;
- ThemeService sut = CreateSut(options);
-
- // Act
- bool result = sut.AllowThemeScripts;
-
- // Assert
- Assert.True(result);
- }
-
[Fact]
public void MaxArchiveBytes_WhenConfigured_ShouldReturnConfiguredValue()
{
@@ -133,8 +86,7 @@ public class ThemeServiceTests : IDisposable
maxArchiveBytes: 8 * 1024 * 1024,
maxExpandedBytes: 24 * 1024 * 1024,
maxSingleFileBytes: 6 * 1024 * 1024,
- maxEntries: 250,
- allowThemeScripts: false);
+ maxEntries: 250);
options.MaxArchiveBytes = 12345;
ThemeService sut = CreateSut(options);
@@ -156,8 +108,7 @@ public class ThemeServiceTests : IDisposable
maxArchiveBytes: 8 * 1024 * 1024,
maxExpandedBytes: 24 * 1024 * 1024,
maxSingleFileBytes: 6 * 1024 * 1024,
- maxEntries: 250,
- allowThemeScripts: false);
+ maxEntries: 250);
options.DefaultThemeId = "custom-default";
ThemeService sut = CreateSut(options);
@@ -288,8 +239,7 @@ public class ThemeServiceTests : IDisposable
maxArchiveBytes: 8 * 1024 * 1024,
maxExpandedBytes: 24 * 1024 * 1024,
maxSingleFileBytes: 6 * 1024 * 1024,
- maxEntries: 250,
- allowThemeScripts: false);
+ maxEntries: 250);
options.MaxArchiveBytes = 128;
ThemeService sut = CreateSut(options);
byte[] archive = _themePackFixture.Create();
@@ -453,8 +403,7 @@ public class ThemeServiceTests : IDisposable
maxArchiveBytes: 8 * 1024 * 1024,
maxExpandedBytes: 24 * 1024 * 1024,
maxSingleFileBytes: 6 * 1024 * 1024,
- maxEntries: 250,
- allowThemeScripts: false);
+ maxEntries: 250);
options.MaxEntries = 2;
ThemeService sut = CreateSut(options);
byte[] archive = _themePackFixture.Create();
@@ -478,8 +427,7 @@ public class ThemeServiceTests : IDisposable
maxArchiveBytes: 8 * 1024 * 1024,
maxExpandedBytes: 24 * 1024 * 1024,
maxSingleFileBytes: 6 * 1024 * 1024,
- maxEntries: 250,
- allowThemeScripts: false);
+ maxEntries: 250);
options.MaxSingleFileBytes = 10;
ThemeService sut = CreateSut(options);
string manifestJson = _themePackFixture.CreateManifestJson();
@@ -506,8 +454,7 @@ public class ThemeServiceTests : IDisposable
maxArchiveBytes: 8 * 1024 * 1024,
maxExpandedBytes: 24 * 1024 * 1024,
maxSingleFileBytes: 6 * 1024 * 1024,
- maxEntries: 250,
- allowThemeScripts: false);
+ maxEntries: 250);
options.MaxSingleFileBytes = 400;
options.MaxExpandedBytes = 300;
ThemeService sut = CreateSut(options);
@@ -1039,48 +986,6 @@ public class ThemeServiceTests : IDisposable
Assert.Equal(DEFAULT_TEMPLATE, result.Value);
}
- [Fact]
- public async Task GetTemplateAsync_WhenScriptsAreDisabled_ShouldStripScriptElements()
- {
- // Arrange
- byte[] archive = _themePackFixture.Create(defaultTemplateContent: "safe content
");
- await InstallValidThemeAsync(archive);
-
- // Act
- Result result = await _sut.GetTemplateAsync("test-theme", "unknown-page", CancellationToken.None);
-
- // Assert
- Assert.True(result.IsSuccess);
- Assert.Equal("safe content
", result.Value);
- }
-
- [Fact]
- public async Task GetTemplateAsync_WhenScriptsAreEnabled_ShouldPreserveScriptElements()
- {
- // Arrange
- ThemeEngineOptionsDto options = _themeEngineOptionsDtoFixture.Create(
- storagePath: Path.Combine(_testRootPath, "themes"),
- bundledThemesPath: Path.Combine(_testRootPath, "bundled"),
- defaultThemeId: "lumina-default",
- maxArchiveBytes: 8 * 1024 * 1024,
- maxExpandedBytes: 24 * 1024 * 1024,
- maxSingleFileBytes: 6 * 1024 * 1024,
- maxEntries: 250,
- allowThemeScripts: false);
- options.AllowThemeScripts = true;
- ThemeService sut = CreateSut(options);
- const string TEMPLATE_WITH_SCRIPT = "safe content
";
- byte[] archive = _themePackFixture.Create(defaultTemplateContent: TEMPLATE_WITH_SCRIPT);
- await InstallValidThemeAsync(archive, sut);
-
- // Act
- Result result = await sut.GetTemplateAsync("test-theme", "unknown-page", CancellationToken.None);
-
- // Assert
- Assert.True(result.IsSuccess);
- Assert.Equal(TEMPLATE_WITH_SCRIPT, result.Value);
- }
-
[Fact]
public async Task GetAssetAsync_WhenAssetExists_ShouldReturnFileBytesAndContentType()
{
@@ -1146,7 +1051,7 @@ public class ThemeServiceTests : IDisposable
}
[Fact]
- public async Task GetAssetAsync_WhenScriptsAreDisabledAndAssetIsJavaScript_ShouldReturnThemeFilesUnreadable()
+ public async Task GetAssetAsync_WhenAssetIsJavaScript_ShouldReturnJavaScriptContentType()
{
// Arrange
byte[] archive = _themePackFixture.Create(additionalFiles: new Dictionary
@@ -1158,35 +1063,6 @@ public class ThemeServiceTests : IDisposable
// Act
Result result = await _sut.GetAssetAsync("test-theme", "assets/app.js", CancellationToken.None);
- // Assert
- Assert.True(result.IsFailure);
- Assert.Equal("ThemeFilesUnreadable", result.FirstError.Description);
- }
-
- [Fact]
- public async Task GetAssetAsync_WhenScriptsAreEnabledAndAssetIsJavaScript_ShouldReturnJavaScriptContentType()
- {
- // Arrange
- ThemeEngineOptionsDto options = _themeEngineOptionsDtoFixture.Create(
- storagePath: Path.Combine(_testRootPath, "themes"),
- bundledThemesPath: Path.Combine(_testRootPath, "bundled"),
- defaultThemeId: "lumina-default",
- maxArchiveBytes: 8 * 1024 * 1024,
- maxExpandedBytes: 24 * 1024 * 1024,
- maxSingleFileBytes: 6 * 1024 * 1024,
- maxEntries: 250,
- allowThemeScripts: false);
- options.AllowThemeScripts = true;
- ThemeService sut = CreateSut(options);
- byte[] archive = _themePackFixture.Create(additionalFiles: new Dictionary
- {
- ["assets/app.js"] = "console.log('hello');"
- });
- await InstallValidThemeAsync(archive, sut);
-
- // Act
- Result result = await sut.GetAssetAsync("test-theme", "assets/app.js", CancellationToken.None);
-
// Assert
Assert.True(result.IsSuccess);
Assert.Equal("application/javascript", result.Value.ContentType);
diff --git a/tests/UnitTests/Lumina.Presentation.Web.UnitTests/Core/Endpoints/Admin/Themes/GetThemes/GetThemesEndpointTests.cs b/tests/UnitTests/Lumina.Presentation.Web.UnitTests/Core/Endpoints/Admin/Themes/GetThemes/GetThemesEndpointTests.cs
index 896dc807..5f88ece1 100644
--- a/tests/UnitTests/Lumina.Presentation.Web.UnitTests/Core/Endpoints/Admin/Themes/GetThemes/GetThemesEndpointTests.cs
+++ b/tests/UnitTests/Lumina.Presentation.Web.UnitTests/Core/Endpoints/Admin/Themes/GetThemes/GetThemesEndpointTests.cs
@@ -53,7 +53,7 @@ public class GetThemesEndpointTests
_mockApiHttpClient.GetAsync(ApiRoutes.Themes.GET_CURRENT_THEME, Arg.Any())
.Returns(currentTheme);
_mockApiHttpClient.GetAsync(ApiRoutes.Themes.GET_THEME_SETTINGS, Arg.Any())
- .Returns(_themeSettingsResponseDtoFixture.Create(maxArchiveBytes: 10 * 1024 * 1024, allowThemeScripts: true));
+ .Returns(_themeSettingsResponseDtoFixture.Create(maxArchiveBytes: 10 * 1024 * 1024));
// Act
IResult result = await _sut.ExecuteAsync(EmptyRequest.Instance, CancellationToken.None);
@@ -67,7 +67,6 @@ public class GetThemesEndpointTests
Assert.Equal(2, data.GetProperty("themes").GetArrayLength());
Assert.Equal("editorial-paper", data.GetProperty("themes")[0].GetProperty("id").GetString());
Assert.Equal("lumina-default", data.GetProperty("currentThemeId").GetString());
- Assert.True(data.GetProperty("allowThemeScripts").GetBoolean());
Assert.Equal(10 * 1024 * 1024, data.GetProperty("maxArchiveBytes").GetInt64());
Assert.Equal(10.0, data.GetProperty("maxArchiveMegabytes").GetDouble());
}
diff --git a/tests/UnitTests/Lumina.Presentation.Web.UnitTests/Core/Themes/ThemeServiceTests.cs b/tests/UnitTests/Lumina.Presentation.Web.UnitTests/Core/Themes/ThemeServiceTests.cs
index c24c55f0..0a306c3d 100644
--- a/tests/UnitTests/Lumina.Presentation.Web.UnitTests/Core/Themes/ThemeServiceTests.cs
+++ b/tests/UnitTests/Lumina.Presentation.Web.UnitTests/Core/Themes/ThemeServiceTests.cs
@@ -103,7 +103,7 @@ public class ThemeServiceTests
public async Task GetThemeSettingsAsync_WhenApiReturnsSettings_ShouldReturnSettings()
{
// Arrange
- ThemeSettingsResponseDto settings = _themeSettingsResponseDtoFixture.Create(maxArchiveBytes: 10 * 1024 * 1024, allowThemeScripts: true);
+ ThemeSettingsResponseDto settings = _themeSettingsResponseDtoFixture.Create(maxArchiveBytes: 10 * 1024 * 1024);
_mockApiHttpClient.GetAsync(ApiRoutes.Themes.GET_THEME_SETTINGS, Arg.Any())
.Returns(settings);