Browse Source

Update NSwag and OpenAPI. (#1064)

* Update NSwag and OpenAPI.

* Update Tests
pull/1066/head
Sebastian Stehle 2 years ago
committed by GitHub
parent
commit
0f6ec12244
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      backend/extensions/Squidex.Extensions/APM/Stackdriver/StackdriverExceptionHandler.cs
  2. 8
      backend/extensions/Squidex.Extensions/Squidex.Extensions.csproj
  3. 2
      backend/src/Migrations/Migrations.csproj
  4. 2
      backend/src/Squidex.Domain.Apps.Core.Model/Contents/RichTextMark.cs
  5. 2
      backend/src/Squidex.Domain.Apps.Core.Model/Squidex.Domain.Apps.Core.Model.csproj
  6. 2
      backend/src/Squidex.Domain.Apps.Core.Operations/GenerateJsonSchema/JsonTypeVisitor.cs
  7. 4
      backend/src/Squidex.Domain.Apps.Core.Operations/Squidex.Domain.Apps.Core.Operations.csproj
  8. 8
      backend/src/Squidex.Domain.Apps.Entities.MongoDb/Contents/Operations/QueryReferences.cs
  9. 2
      backend/src/Squidex.Domain.Apps.Entities.MongoDb/Squidex.Domain.Apps.Entities.MongoDb.csproj
  10. 7
      backend/src/Squidex.Domain.Apps.Entities/Assets/AssetsJintExtension.cs
  11. 4
      backend/src/Squidex.Domain.Apps.Entities/Squidex.Domain.Apps.Entities.csproj
  12. 2
      backend/src/Squidex.Domain.Apps.Events/Squidex.Domain.Apps.Events.csproj
  13. 2
      backend/src/Squidex.Domain.Users.MongoDb/Squidex.Domain.Users.MongoDb.csproj
  14. 7
      backend/src/Squidex.Domain.Users/DefaultUserService.cs
  15. 14
      backend/src/Squidex.Domain.Users/InMemory/ImmutableApplication.cs
  16. 39
      backend/src/Squidex.Domain.Users/InMemory/InMemoryApplicationStore.cs
  17. 6
      backend/src/Squidex.Domain.Users/Squidex.Domain.Users.csproj
  18. 4
      backend/src/Squidex.Infrastructure.GetEventStore/Squidex.Infrastructure.GetEventStore.csproj
  19. 2
      backend/src/Squidex.Infrastructure.MongoDb/Squidex.Infrastructure.MongoDb.csproj
  20. 6
      backend/src/Squidex.Infrastructure/Squidex.Infrastructure.csproj
  21. 2
      backend/src/Squidex.Shared/Squidex.Shared.csproj
  22. 2
      backend/src/Squidex.Web/Squidex.Web.csproj
  23. 2
      backend/src/Squidex/Areas/Api/Config/OpenApi/CommonProcessor.cs
  24. 13
      backend/src/Squidex/Areas/Api/Config/OpenApi/OpenApiServices.cs
  25. 2
      backend/src/Squidex/Areas/Api/Config/OpenApi/ReflectionServices.cs
  26. 3
      backend/src/Squidex/Areas/Api/Config/OpenApi/RequiredSchemaProcessor.cs
  27. 2
      backend/src/Squidex/Areas/Api/Config/OpenApi/ScopesProcessor.cs
  28. 9
      backend/src/Squidex/Areas/Api/Controllers/Assets/AssetContentController.cs
  29. 5
      backend/src/Squidex/Areas/Api/Controllers/Assets/Models/AssetFoldersDto.cs
  30. 22
      backend/src/Squidex/Areas/Api/Controllers/Contents/Generator/SchemasOpenApiGenerator.cs
  31. 4
      backend/src/Squidex/Areas/IdentityServer/Config/DynamicApplicationStore.cs
  32. 6
      backend/src/Squidex/Areas/IdentityServer/Config/TokenStoreInitializer.cs
  33. 8
      backend/src/Squidex/Areas/IdentityServer/Controllers/Account/AccountController.cs
  34. 2
      backend/src/Squidex/Areas/IdentityServer/Controllers/Setup/SetupController.cs
  35. 2
      backend/src/Squidex/Config/Domain/StoreServices.cs
  36. 22
      backend/src/Squidex/Squidex.csproj
  37. 2
      backend/tests/Squidex.Domain.Apps.Core.Tests/Model/Contents/RichTextTests.cs
  38. 8
      backend/tests/Squidex.Domain.Apps.Core.Tests/Model/Schemas/SchemaTests.cs
  39. 8
      backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/ConvertContent/FieldConvertersTests.cs
  40. 24
      backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/ExtractReferenceIds/ReferenceExtractionTests.cs
  41. 2
      backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/GenerateJsonSchema/JsonSchemaTests.cs
  42. 8
      backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/HandleRules/EventJsonSchemaGeneratorTests.cs
  43. 8
      backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/ValidateContent/Validators/AssetsValidatorTests.cs
  44. 8
      backend/tests/Squidex.Domain.Apps.Core.Tests/Squidex.Domain.Apps.Core.Tests.csproj
  45. 17
      backend/tests/Squidex.Domain.Apps.Entities.Tests/Assets/AssetChangedTriggerHandlerTests.cs
  46. 25
      backend/tests/Squidex.Domain.Apps.Entities.Tests/Assets/AssetUsageTrackerTests.cs
  47. 11
      backend/tests/Squidex.Domain.Apps.Entities.Tests/Assets/AssetsFluidExtensionTests.cs
  48. 11
      backend/tests/Squidex.Domain.Apps.Entities.Tests/Assets/AssetsJintExtensionTests.cs
  49. 24
      backend/tests/Squidex.Domain.Apps.Entities.Tests/Assets/DefaultAssetFileStoreTests.cs
  50. 12
      backend/tests/Squidex.Domain.Apps.Entities.Tests/Assets/MongoDb/AssetsQueryIntegrationTests.cs
  51. 20
      backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/ContentChangedTriggerHandlerTests.cs
  52. 23
      backend/tests/Squidex.Domain.Apps.Entities.Tests/Schemas/DomainObject/Guards/GuardSchemaFieldTests.cs
  53. 18
      backend/tests/Squidex.Domain.Apps.Entities.Tests/Schemas/SchemaChangedTriggerHandlerTests.cs
  54. 12
      backend/tests/Squidex.Domain.Apps.Entities.Tests/Squidex.Domain.Apps.Entities.Tests.csproj
  55. 2
      backend/tests/Squidex.Domain.Apps.Entities.Tests/TestHelpers/GivenContext.cs
  56. 8
      backend/tests/Squidex.Domain.Users.Tests/Squidex.Domain.Users.Tests.csproj
  57. 20
      backend/tests/Squidex.Infrastructure.Tests/HashExtensionsTests.cs
  58. 8
      backend/tests/Squidex.Infrastructure.Tests/Json/Objects/JsonValuesSerializationTests.cs
  59. 8
      backend/tests/Squidex.Infrastructure.Tests/NamedIdTests.cs
  60. 71
      backend/tests/Squidex.Infrastructure.Tests/Queries/QueryFromJsonTests.cs
  61. 8
      backend/tests/Squidex.Infrastructure.Tests/Squidex.Infrastructure.Tests.csproj
  62. 8
      backend/tests/Squidex.Web.Tests/Squidex.Web.Tests.csproj
  63. 6
      tools/TestSuite/TestSuite.ApiTests/TestSuite.ApiTests.csproj
  64. 10
      tools/TestSuite/TestSuite.LoadTests/ReadingBenchmarks.cs
  65. 10
      tools/TestSuite/TestSuite.LoadTests/ReadingContentBenchmarks.cs
  66. 2
      tools/TestSuite/TestSuite.LoadTests/TestSuite.LoadTests.csproj
  67. 10
      tools/TestSuite/TestSuite.LoadTests/WritingBenchmarks.cs
  68. 8
      tools/TestSuite/TestSuite.Shared/TestSuite.Shared.csproj

2
backend/extensions/Squidex.Extensions/APM/Stackdriver/StackdriverExceptionHandler.cs

@ -39,7 +39,7 @@ internal sealed class StackdriverExceptionHandler : ILogAppender
public string GetUserAgent() public string GetUserAgent()
{ {
return httpContextAccessor.HttpContext?.Request?.Headers["User-Agent"].ToString() ?? string.Empty; return httpContextAccessor.HttpContext?.Request?.Headers.UserAgent.ToString() ?? string.Empty;
} }
} }

8
backend/extensions/Squidex.Extensions/Squidex.Extensions.csproj

@ -18,17 +18,17 @@
<PackageReference Include="Elasticsearch.Net" Version="7.17.5" /> <PackageReference Include="Elasticsearch.Net" Version="7.17.5" />
<PackageReference Include="Google.Cloud.Diagnostics.Common" Version="5.1.0" /> <PackageReference Include="Google.Cloud.Diagnostics.Common" Version="5.1.0" />
<PackageReference Include="Google.Cloud.Logging.V2" Version="4.1.0" /> <PackageReference Include="Google.Cloud.Logging.V2" Version="4.1.0" />
<PackageReference Include="Google.Cloud.Monitoring.V3" Version="3.4.0" /> <PackageReference Include="Google.Cloud.Monitoring.V3" Version="3.5.0" />
<PackageReference Include="Meziantou.Analyzer" Version="2.0.125"> <PackageReference Include="Meziantou.Analyzer" Version="2.0.136">
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference> </PackageReference>
<PackageReference Include="Microsoft.Azure.CognitiveServices.Vision.ComputerVision" Version="7.0.1" /> <PackageReference Include="Microsoft.Azure.CognitiveServices.Vision.ComputerVision" Version="7.0.1" />
<PackageReference Include="Microsoft.Azure.SignalR.Management" Version="1.22.0" /> <PackageReference Include="Microsoft.Azure.SignalR.Management" Version="1.23.0" />
<PackageReference Include="Microsoft.Extensions.Http" Version="8.0.0" /> <PackageReference Include="Microsoft.Extensions.Http" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.0" /> <PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.0" />
<PackageReference Include="Microsoft.OData.Core" Version="7.20.0" /> <PackageReference Include="Microsoft.OData.Core" Version="7.20.0" />
<PackageReference Include="NodaTime" Version="3.1.9" /> <PackageReference Include="NodaTime" Version="3.1.10" />
<PackageReference Include="OpenSearch.Net" Version="1.6.0" /> <PackageReference Include="OpenSearch.Net" Version="1.6.0" />
<PackageReference Include="OpenTelemetry.Exporter.Console" Version="1.7.0" /> <PackageReference Include="OpenTelemetry.Exporter.Console" Version="1.7.0" />
<PackageReference Include="OpenTelemetry.Exporter.OpenTelemetryProtocol" Version="1.7.0" /> <PackageReference Include="OpenTelemetry.Exporter.OpenTelemetryProtocol" Version="1.7.0" />

2
backend/src/Migrations/Migrations.csproj

@ -6,7 +6,7 @@
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Meziantou.Analyzer" Version="2.0.125"> <PackageReference Include="Meziantou.Analyzer" Version="2.0.136">
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference> </PackageReference>

2
backend/src/Squidex.Domain.Apps.Core.Model/Contents/RichTextMark.cs

@ -10,7 +10,7 @@ using Squidex.Text.RichText.Model;
namespace Squidex.Domain.Apps.Core.Contents; namespace Squidex.Domain.Apps.Core.Contents;
internal class RichTextMark : IMark internal sealed class RichTextMark : IMark
{ {
private JsonObject? attrs; private JsonObject? attrs;

2
backend/src/Squidex.Domain.Apps.Core.Model/Squidex.Domain.Apps.Core.Model.csproj

@ -12,7 +12,7 @@
<DebugSymbols>True</DebugSymbols> <DebugSymbols>True</DebugSymbols>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Meziantou.Analyzer" Version="2.0.125"> <PackageReference Include="Meziantou.Analyzer" Version="2.0.136">
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference> </PackageReference>

2
backend/src/Squidex.Domain.Apps.Core.Operations/GenerateJsonSchema/JsonTypeVisitor.cs

@ -199,7 +199,7 @@ internal sealed class JsonTypeVisitor : IFieldVisitor<JsonSchemaProperty?, JsonT
property.MaxItems = field.Properties.MaxItems.Value; property.MaxItems = field.Properties.MaxItems.Value;
} }
property.ExtensionData = new Dictionary<string, object> property.ExtensionData = new Dictionary<string, object?>
{ {
["schemaIds"] = field.Properties.SchemaIds ?? [] ["schemaIds"] = field.Properties.SchemaIds ?? []
}; };

4
backend/src/Squidex.Domain.Apps.Core.Operations/Squidex.Domain.Apps.Core.Operations.csproj

@ -21,12 +21,12 @@
<PackageReference Include="Fluid.Core" Version="2.5.0" /> <PackageReference Include="Fluid.Core" Version="2.5.0" />
<PackageReference Include="GeoJSON.Net" Version="1.2.19" /> <PackageReference Include="GeoJSON.Net" Version="1.2.19" />
<PackageReference Include="Jint" Version="3.0.0-beta-2055" /> <PackageReference Include="Jint" Version="3.0.0-beta-2055" />
<PackageReference Include="Meziantou.Analyzer" Version="2.0.125"> <PackageReference Include="Meziantou.Analyzer" Version="2.0.136">
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference> </PackageReference>
<PackageReference Include="Microsoft.Extensions.Http" Version="8.0.0" /> <PackageReference Include="Microsoft.Extensions.Http" Version="8.0.0" />
<PackageReference Include="NJsonSchema" Version="10.9.0" /> <PackageReference Include="NJsonSchema" Version="11.0.0" />
<PackageReference Include="RefactoringEssentials" Version="5.6.0" PrivateAssets="all" /> <PackageReference Include="RefactoringEssentials" Version="5.6.0" PrivateAssets="all" />
<PackageReference Include="Squidex.Messaging.Subscriptions" Version="6.3.5" /> <PackageReference Include="Squidex.Messaging.Subscriptions" Version="6.3.5" />
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118" PrivateAssets="all" /> <PackageReference Include="StyleCop.Analyzers" Version="1.1.118" PrivateAssets="all" />

8
backend/src/Squidex.Domain.Apps.Entities.MongoDb/Contents/Operations/QueryReferences.cs

@ -42,12 +42,8 @@ internal sealed class QueryReferences : OperationBase
.Find(Filter.Eq(x => x.DocumentId, DomainId.Combine(app.Id, q.Referencing))) .Find(Filter.Eq(x => x.DocumentId, DomainId.Combine(app.Id, q.Referencing)))
.Project<ReferencedIdsOnly>(Projection.Include(x => x.ReferencedIds)); .Project<ReferencedIdsOnly>(Projection.Include(x => x.ReferencedIds));
var contentEntity = await find.FirstOrDefaultAsync(ct); var contentEntity = await find.FirstOrDefaultAsync(ct)
?? throw new DomainObjectNotFoundException(q.Referencing.ToString());
if (contentEntity == null)
{
throw new DomainObjectNotFoundException(q.Referencing.ToString());
}
if (contentEntity.ReferencedIds is not { Count: > 0 }) if (contentEntity.ReferencedIds is not { Count: > 0 })
{ {

2
backend/src/Squidex.Domain.Apps.Entities.MongoDb/Squidex.Domain.Apps.Entities.MongoDb.csproj

@ -19,7 +19,7 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Lucene.Net.QueryParser" Version="4.8.0-beta00016" /> <PackageReference Include="Lucene.Net.QueryParser" Version="4.8.0-beta00016" />
<PackageReference Include="Meziantou.Analyzer" Version="2.0.125"> <PackageReference Include="Meziantou.Analyzer" Version="2.0.136">
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference> </PackageReference>

7
backend/src/Squidex.Domain.Apps.Entities/Assets/AssetsJintExtension.cs

@ -323,12 +323,7 @@ public sealed class AssetsJintExtension : IJintExtension, IScriptDescriptor
var app = await appProvider.GetAppAsync(appId, false, ct); var app = await appProvider.GetAppAsync(appId, false, ct);
if (app == null) return app ?? throw new JavaScriptException("App does not exist.");
{
throw new JavaScriptException("App does not exist.");
}
return app;
} }
public void Describe(AddDescription describe, ScriptScope scope) public void Describe(AddDescription describe, ScriptScope scope)

4
backend/src/Squidex.Domain.Apps.Entities/Squidex.Domain.Apps.Entities.csproj

@ -27,14 +27,14 @@
<PackageReference Include="CsvHelper" Version="30.0.1" /> <PackageReference Include="CsvHelper" Version="30.0.1" />
<PackageReference Include="GraphQL" Version="7.7.2" /> <PackageReference Include="GraphQL" Version="7.7.2" />
<PackageReference Include="GraphQL.DataLoader" Version="7.7.2" /> <PackageReference Include="GraphQL.DataLoader" Version="7.7.2" />
<PackageReference Include="Meziantou.Analyzer" Version="2.0.125"> <PackageReference Include="Meziantou.Analyzer" Version="2.0.136">
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference> </PackageReference>
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="8.0.0" /> <PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="8.0.0" />
<PackageReference Include="Notifo.SDK" Version="1.7.4" /> <PackageReference Include="Notifo.SDK" Version="1.7.4" />
<PackageReference Include="RefactoringEssentials" Version="5.6.0" PrivateAssets="all" /> <PackageReference Include="RefactoringEssentials" Version="5.6.0" PrivateAssets="all" />
<PackageReference Include="Squidex.CLI.Core" Version="12.1.0" /> <PackageReference Include="Squidex.CLI.Core" Version="13.0.0" />
<PackageReference Include="Squidex.YDotNet.Extensions" Version="0.2.9" /> <PackageReference Include="Squidex.YDotNet.Extensions" Version="0.2.9" />
<PackageReference Include="Squidex.YDotNet.Server" Version="0.2.9" /> <PackageReference Include="Squidex.YDotNet.Server" Version="0.2.9" />
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118" PrivateAssets="all" /> <PackageReference Include="StyleCop.Analyzers" Version="1.1.118" PrivateAssets="all" />

2
backend/src/Squidex.Domain.Apps.Events/Squidex.Domain.Apps.Events.csproj

@ -14,7 +14,7 @@
<ProjectReference Include="..\Squidex.Infrastructure\Squidex.Infrastructure.csproj" /> <ProjectReference Include="..\Squidex.Infrastructure\Squidex.Infrastructure.csproj" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Meziantou.Analyzer" Version="2.0.125"> <PackageReference Include="Meziantou.Analyzer" Version="2.0.136">
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference> </PackageReference>

2
backend/src/Squidex.Domain.Users.MongoDb/Squidex.Domain.Users.MongoDb.csproj

@ -19,7 +19,7 @@
<ProjectReference Include="..\Squidex.Shared\Squidex.Shared.csproj" /> <ProjectReference Include="..\Squidex.Shared\Squidex.Shared.csproj" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Meziantou.Analyzer" Version="2.0.125"> <PackageReference Include="Meziantou.Analyzer" Version="2.0.136">
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference> </PackageReference>

7
backend/src/Squidex.Domain.Users/DefaultUserService.cs

@ -365,12 +365,7 @@ public sealed class DefaultUserService : IUserService
var user = await userManager.FindByIdAsync(id); var user = await userManager.FindByIdAsync(id);
if (user == null) return user ?? throw new DomainObjectNotFoundException(id);
{
throw new DomainObjectNotFoundException(id);
}
return user;
} }
private Task<IUser[]> ResolveAsync(IEnumerable<IdentityUser> users) private Task<IUser[]> ResolveAsync(IEnumerable<IdentityUser> users)

14
backend/src/Squidex.Domain.Users/InMemory/ImmutableApplication.cs

@ -8,6 +8,7 @@
using System.Collections.Immutable; using System.Collections.Immutable;
using System.Globalization; using System.Globalization;
using System.Text.Json; using System.Text.Json;
using Microsoft.IdentityModel.Tokens;
using OpenIddict.Abstractions; using OpenIddict.Abstractions;
namespace Squidex.Domain.Users.InMemory; namespace Squidex.Domain.Users.InMemory;
@ -20,11 +21,15 @@ public sealed class ImmutableApplication
public string? ClientSecret { get; } public string? ClientSecret { get; }
public string? ClientType { get; }
public string? ConsentType { get; } public string? ConsentType { get; }
public string? DisplayName { get; } public string? DisplayName { get; }
public string? Type { get; } public string? ApplicationType { get; }
public JsonWebKeySet? JsonWebKeySet { get; }
public ImmutableDictionary<CultureInfo, string> DisplayNames { get; } public ImmutableDictionary<CultureInfo, string> DisplayNames { get; }
@ -38,19 +43,24 @@ public sealed class ImmutableApplication
public ImmutableDictionary<string, JsonElement> Properties { get; } public ImmutableDictionary<string, JsonElement> Properties { get; }
public ImmutableDictionary<string, string> Settings { get; }
public ImmutableApplication(string id, OpenIddictApplicationDescriptor descriptor) public ImmutableApplication(string id, OpenIddictApplicationDescriptor descriptor)
{ {
Id = id; Id = id;
ApplicationType = descriptor.ApplicationType;
ClientId = descriptor.ClientId; ClientId = descriptor.ClientId;
ClientSecret = descriptor.ClientSecret; ClientSecret = descriptor.ClientSecret;
ClientType = descriptor.ClientType;
ConsentType = descriptor.ConsentType; ConsentType = descriptor.ConsentType;
DisplayName = descriptor.DisplayName; DisplayName = descriptor.DisplayName;
DisplayNames = descriptor.DisplayNames.ToImmutableDictionary(); DisplayNames = descriptor.DisplayNames.ToImmutableDictionary();
JsonWebKeySet = descriptor.JsonWebKeySet;
Permissions = descriptor.Permissions.ToImmutableArray(); Permissions = descriptor.Permissions.ToImmutableArray();
PostLogoutRedirectUris = descriptor.PostLogoutRedirectUris.Select(x => x.ToString()).ToImmutableArray(); PostLogoutRedirectUris = descriptor.PostLogoutRedirectUris.Select(x => x.ToString()).ToImmutableArray();
Properties = descriptor.Properties.ToImmutableDictionary(); Properties = descriptor.Properties.ToImmutableDictionary();
RedirectUris = descriptor.RedirectUris.Select(x => x.ToString()).ToImmutableArray(); RedirectUris = descriptor.RedirectUris.Select(x => x.ToString()).ToImmutableArray();
Requirements = descriptor.Requirements.ToImmutableArray(); Requirements = descriptor.Requirements.ToImmutableArray();
Type = descriptor.Type; Settings = descriptor.Settings.ToImmutableDictionary();
} }
} }

39
backend/src/Squidex.Domain.Users/InMemory/InMemoryApplicationStore.cs

@ -9,6 +9,7 @@ using System.Collections.Immutable;
using System.Globalization; using System.Globalization;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using System.Text.Json; using System.Text.Json;
using Microsoft.IdentityModel.Tokens;
using OpenIddict.Abstractions; using OpenIddict.Abstractions;
namespace Squidex.Domain.Users.InMemory; namespace Squidex.Domain.Users.InMemory;
@ -128,7 +129,7 @@ public class InMemoryApplicationStore : IOpenIddictApplicationStore<ImmutableApp
public virtual ValueTask<string?> GetClientTypeAsync(ImmutableApplication application, public virtual ValueTask<string?> GetClientTypeAsync(ImmutableApplication application,
CancellationToken cancellationToken) CancellationToken cancellationToken)
{ {
return application.Type.AsValueTask(); return application.ClientType.AsValueTask();
} }
public virtual ValueTask<string?> GetConsentTypeAsync(ImmutableApplication application, public virtual ValueTask<string?> GetConsentTypeAsync(ImmutableApplication application,
@ -179,6 +180,24 @@ public class InMemoryApplicationStore : IOpenIddictApplicationStore<ImmutableApp
return application.Properties.AsValueTask(); return application.Properties.AsValueTask();
} }
public ValueTask<string?> GetApplicationTypeAsync(ImmutableApplication application,
CancellationToken cancellationToken)
{
return application.ApplicationType.AsValueTask();
}
public ValueTask<JsonWebKeySet?> GetJsonWebKeySetAsync(ImmutableApplication application,
CancellationToken cancellationToken)
{
return application.JsonWebKeySet.AsValueTask();
}
public ValueTask<ImmutableDictionary<string, string>> GetSettingsAsync(ImmutableApplication application,
CancellationToken cancellationToken)
{
return application.Settings.AsValueTask();
}
public virtual ValueTask CreateAsync(ImmutableApplication application, public virtual ValueTask CreateAsync(ImmutableApplication application,
CancellationToken cancellationToken) CancellationToken cancellationToken)
{ {
@ -268,4 +287,22 @@ public class InMemoryApplicationStore : IOpenIddictApplicationStore<ImmutableApp
{ {
throw new NotSupportedException(); throw new NotSupportedException();
} }
public ValueTask SetApplicationTypeAsync(ImmutableApplication application, string? type,
CancellationToken cancellationToken)
{
throw new NotSupportedException();
}
public ValueTask SetJsonWebKeySetAsync(ImmutableApplication application, JsonWebKeySet? set,
CancellationToken cancellationToken)
{
throw new NotSupportedException();
}
public ValueTask SetSettingsAsync(ImmutableApplication application, ImmutableDictionary<string, string> settings,
CancellationToken cancellationToken)
{
throw new NotSupportedException();
}
} }

6
backend/src/Squidex.Domain.Users/Squidex.Domain.Users.csproj

@ -18,13 +18,13 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="IdentityModel" Version="6.2.0" /> <PackageReference Include="IdentityModel" Version="6.2.0" />
<PackageReference Include="Meziantou.Analyzer" Version="2.0.125"> <PackageReference Include="Meziantou.Analyzer" Version="2.0.136">
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference> </PackageReference>
<PackageReference Include="Microsoft.Extensions.Identity.Stores" Version="8.0.0" /> <PackageReference Include="Microsoft.Extensions.Identity.Stores" Version="8.0.1" />
<PackageReference Include="Microsoft.Win32.Registry" Version="5.0.0" /> <PackageReference Include="Microsoft.Win32.Registry" Version="5.0.0" />
<PackageReference Include="OpenIddict.AspNetCore" Version="4.10.0" /> <PackageReference Include="OpenIddict.AspNetCore" Version="5.0.1" />
<PackageReference Include="RefactoringEssentials" Version="5.6.0" PrivateAssets="all" /> <PackageReference Include="RefactoringEssentials" Version="5.6.0" PrivateAssets="all" />
<PackageReference Include="SharpPwned.NET" Version="2.0.1" /> <PackageReference Include="SharpPwned.NET" Version="2.0.1" />
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118" PrivateAssets="all" /> <PackageReference Include="StyleCop.Analyzers" Version="1.1.118" PrivateAssets="all" />

4
backend/src/Squidex.Infrastructure.GetEventStore/Squidex.Infrastructure.GetEventStore.csproj

@ -14,8 +14,8 @@
<PackageReference Include="EventStore.Client.Grpc.PersistentSubscriptions" Version="23.1.0" /> <PackageReference Include="EventStore.Client.Grpc.PersistentSubscriptions" Version="23.1.0" />
<PackageReference Include="EventStore.Client.Grpc.ProjectionManagement" Version="23.1.0" /> <PackageReference Include="EventStore.Client.Grpc.ProjectionManagement" Version="23.1.0" />
<PackageReference Include="EventStore.Client.Grpc.Streams" Version="23.1.0" /> <PackageReference Include="EventStore.Client.Grpc.Streams" Version="23.1.0" />
<PackageReference Include="Grpc.Net.Client" Version="2.59.0" /> <PackageReference Include="Grpc.Net.Client" Version="2.60.0" />
<PackageReference Include="Meziantou.Analyzer" Version="2.0.125"> <PackageReference Include="Meziantou.Analyzer" Version="2.0.136">
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference> </PackageReference>

2
backend/src/Squidex.Infrastructure.MongoDb/Squidex.Infrastructure.MongoDb.csproj

@ -14,7 +14,7 @@
<ProjectReference Include="..\Squidex.Infrastructure\Squidex.Infrastructure.csproj" /> <ProjectReference Include="..\Squidex.Infrastructure\Squidex.Infrastructure.csproj" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Meziantou.Analyzer" Version="2.0.125"> <PackageReference Include="Meziantou.Analyzer" Version="2.0.136">
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference> </PackageReference>

6
backend/src/Squidex.Infrastructure/Squidex.Infrastructure.csproj

@ -13,15 +13,15 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="MailKit" Version="4.3.0" /> <PackageReference Include="MailKit" Version="4.3.0" />
<PackageReference Include="McMaster.NETCore.Plugins" Version="1.4.0" /> <PackageReference Include="McMaster.NETCore.Plugins" Version="1.4.0" />
<PackageReference Include="Meziantou.Analyzer" Version="2.0.125"> <PackageReference Include="Meziantou.Analyzer" Version="2.0.136">
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference> </PackageReference>
<PackageReference Include="Microsoft.Extensions.Caching.Abstractions" Version="8.0.0" /> <PackageReference Include="Microsoft.Extensions.Caching.Abstractions" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Diagnostics.HealthChecks.Abstractions" Version="8.0.0" /> <PackageReference Include="Microsoft.Extensions.Diagnostics.HealthChecks.Abstractions" Version="8.0.1" />
<PackageReference Include="Microsoft.IO.RecyclableMemoryStream" Version="3.0.0" /> <PackageReference Include="Microsoft.IO.RecyclableMemoryStream" Version="3.0.0" />
<PackageReference Include="Microsoft.OData.Core" Version="7.20.0" /> <PackageReference Include="Microsoft.OData.Core" Version="7.20.0" />
<PackageReference Include="NodaTime" Version="3.1.9" /> <PackageReference Include="NodaTime" Version="3.1.10" />
<PackageReference Include="OpenTelemetry.Api" Version="1.7.0" /> <PackageReference Include="OpenTelemetry.Api" Version="1.7.0" />
<PackageReference Include="RefactoringEssentials" Version="5.6.0" PrivateAssets="all" /> <PackageReference Include="RefactoringEssentials" Version="5.6.0" PrivateAssets="all" />
<PackageReference Include="Squidex.Assets" Version="6.3.5" /> <PackageReference Include="Squidex.Assets" Version="6.3.5" />

2
backend/src/Squidex.Shared/Squidex.Shared.csproj

@ -10,7 +10,7 @@
<DebugSymbols>True</DebugSymbols> <DebugSymbols>True</DebugSymbols>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Meziantou.Analyzer" Version="2.0.125"> <PackageReference Include="Meziantou.Analyzer" Version="2.0.136">
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference> </PackageReference>

2
backend/src/Squidex.Web/Squidex.Web.csproj

@ -16,7 +16,7 @@
<PackageReference Include="GraphQL" Version="7.7.2" /> <PackageReference Include="GraphQL" Version="7.7.2" />
<PackageReference Include="GraphQL.SystemTextJson" Version="7.7.2" /> <PackageReference Include="GraphQL.SystemTextJson" Version="7.7.2" />
<PackageReference Include="GraphQL.Server.Transports.AspNetCore" Version="7.6.0" /> <PackageReference Include="GraphQL.Server.Transports.AspNetCore" Version="7.6.0" />
<PackageReference Include="Meziantou.Analyzer" Version="2.0.125"> <PackageReference Include="Meziantou.Analyzer" Version="2.0.136">
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference> </PackageReference>

2
backend/src/Squidex/Areas/Api/Config/OpenApi/CommonProcessor.cs

@ -33,7 +33,7 @@ public sealed class CommonProcessor : IDocumentProcessor
{ {
context.Document.Info.Title = "Squidex API"; context.Document.Info.Title = "Squidex API";
context.Document.Info.Version = version; context.Document.Info.Version = version;
context.Document.Info.ExtensionData = new Dictionary<string, object> context.Document.Info.ExtensionData = new Dictionary<string, object?>
{ {
["x-logo"] = new ["x-logo"] = new
{ {

13
backend/src/Squidex/Areas/Api/Config/OpenApi/OpenApiServices.cs

@ -55,9 +55,9 @@ public static class OpenApiServices
services.AddSingletonAs<OpenApiSchemaGenerator>() services.AddSingletonAs<OpenApiSchemaGenerator>()
.AsSelf(); .AsSelf();
services.AddSingleton(c => services.AddSingleton<JsonSchemaGeneratorSettings>(c =>
{ {
var settings = new JsonSchemaGeneratorSettings(); var settings = new SystemTextJsonSchemaGeneratorSettings();
ConfigureSchemaSettings(settings, c.GetRequiredService<TypeRegistry>(), true); ConfigureSchemaSettings(settings, c.GetRequiredService<TypeRegistry>(), true);
@ -68,13 +68,10 @@ public static class OpenApiServices
{ {
var settings = new OpenApiDocumentGeneratorSettings var settings = new OpenApiDocumentGeneratorSettings
{ {
SerializerSettings = new JsonSerializerSettings SchemaSettings = new SystemTextJsonSchemaGeneratorSettings()
{
ContractResolver = new CamelCasePropertyNamesContractResolver()
}
}; };
ConfigureSchemaSettings(settings, c.GetRequiredService<TypeRegistry>(), true); ConfigureSchemaSettings(settings.SchemaSettings, c.GetRequiredService<TypeRegistry>(), true);
foreach (var processor in c.GetRequiredService<IEnumerable<IDocumentProcessor>>()) foreach (var processor in c.GetRequiredService<IEnumerable<IDocumentProcessor>>())
{ {
@ -86,7 +83,7 @@ public static class OpenApiServices
services.AddOpenApiDocument((settings, services) => services.AddOpenApiDocument((settings, services) =>
{ {
ConfigureSchemaSettings(settings, services.GetRequiredService<TypeRegistry>(), false); ConfigureSchemaSettings(settings.SchemaSettings, services.GetRequiredService<TypeRegistry>(), false);
}); });
} }

2
backend/src/Squidex/Areas/Api/Config/OpenApi/ReflectionServices.cs

@ -11,7 +11,7 @@ using Squidex.Infrastructure.Collections;
namespace Squidex.Areas.Api.Config.OpenApi; namespace Squidex.Areas.Api.Config.OpenApi;
public class ReflectionServices : DefaultReflectionService public class ReflectionServices : SystemTextJsonReflectionService
{ {
protected override bool IsArrayType(ContextualType contextualType) protected override bool IsArrayType(ContextualType contextualType)
{ {

3
backend/src/Squidex/Areas/Api/Config/OpenApi/RequiredSchemaProcessor.cs

@ -5,6 +5,7 @@
// All rights reserved. Licensed under the MIT license. // All rights reserved. Licensed under the MIT license.
// ========================================================================== // ==========================================================================
using Namotion.Reflection;
using NJsonSchema; using NJsonSchema;
using NJsonSchema.Generation; using NJsonSchema.Generation;
using Squidex.Web; using Squidex.Web;
@ -15,7 +16,7 @@ public sealed class RequiredSchemaProcessor : ISchemaProcessor
{ {
public void Process(SchemaProcessorContext context) public void Process(SchemaProcessorContext context)
{ {
if (context.ContextualType.GetAttribute<OpenApiRequestAttribute>() != null) if (context.ContextualType.GetAttribute<OpenApiRequestAttribute>(true) != null)
{ {
FixRequest(context); FixRequest(context);
} }

2
backend/src/Squidex/Areas/Api/Config/OpenApi/ScopesProcessor.cs

@ -36,7 +36,7 @@ public sealed class ScopesProcessor : IOperationProcessor
context.MethodInfo.DeclaringType!.GetCustomAttributes<AuthorizeAttribute>(true)) context.MethodInfo.DeclaringType!.GetCustomAttributes<AuthorizeAttribute>(true))
.ToArray(); .ToArray();
if (authorizeAttributes.Any()) if (authorizeAttributes.Length != 0)
{ {
var scopes = authorizeAttributes.Where(a => a.Roles != null).SelectMany(a => a.Roles!.Split(',')).Distinct().ToList(); var scopes = authorizeAttributes.Where(a => a.Roles != null).SelectMany(a => a.Roles!.Split(',')).Distinct().ToList();

9
backend/src/Squidex/Areas/Api/Controllers/Assets/AssetContentController.cs

@ -68,12 +68,9 @@ public sealed class AssetContentController : ApiController
{ {
var requestContext = Context.Clone(b => b.WithNoAssetEnrichment()); var requestContext = Context.Clone(b => b.WithNoAssetEnrichment());
var asset = await assetQuery.FindAsync(requestContext, DomainId.Create(idOrSlug), request.Deleted, ct: HttpContext.RequestAborted); var asset =
await assetQuery.FindAsync(requestContext, DomainId.Create(idOrSlug), request.Deleted, ct: HttpContext.RequestAborted) ??
if (asset == null) await assetQuery.FindBySlugAsync(requestContext, idOrSlug, request.Deleted, HttpContext.RequestAborted);
{
asset = await assetQuery.FindBySlugAsync(requestContext, idOrSlug, request.Deleted, HttpContext.RequestAborted);
}
return await DeliverAssetAsync(requestContext, asset, request); return await DeliverAssetAsync(requestContext, asset, request);
} }

5
backend/src/Squidex/Areas/Api/Controllers/Assets/Models/AssetFoldersDto.cs

@ -33,11 +33,10 @@ public sealed class AssetFoldersDto : Resource
var result = new AssetFoldersDto var result = new AssetFoldersDto
{ {
Total = assetFolders.Total, Total = assetFolders.Total,
Items = assetFolders.Select(x => AssetFolderDto.FromDomain(x, resources)).ToArray() Items = assetFolders.Select(x => AssetFolderDto.FromDomain(x, resources)).ToArray(),
Path = path.Select(x => AssetFolderDto.FromDomain(x, resources)).ToArray()
}; };
result.Path = path.Select(x => AssetFolderDto.FromDomain(x, resources)).ToArray();
return result.CreateLinks(resources); return result.CreateLinks(resources);
} }

22
backend/src/Squidex/Areas/Api/Controllers/Contents/Generator/SchemasOpenApiGenerator.cs

@ -24,22 +24,22 @@ namespace Squidex.Areas.Api.Controllers.Contents.Generator;
public sealed class SchemasOpenApiGenerator public sealed class SchemasOpenApiGenerator
{ {
private readonly IAppProvider appProvider; private readonly IAppProvider appProvider;
private readonly OpenApiDocumentGeneratorSettings schemaSettings; private readonly OpenApiDocumentGeneratorSettings openApiSettings;
private readonly OpenApiSchemaGenerator schemaGenerator; private readonly OpenApiSchemaGenerator openApiGenerator;
private readonly IRequestUrlGenerator urlGenerator; private readonly IRequestUrlGenerator urlGenerator;
private readonly IRequestCache requestCache; private readonly IRequestCache requestCache;
public SchemasOpenApiGenerator( public SchemasOpenApiGenerator(
IAppProvider appProvider, IAppProvider appProvider,
OpenApiDocumentGeneratorSettings schemaSettings, OpenApiDocumentGeneratorSettings openApiSettings,
OpenApiSchemaGenerator schemaGenerator, OpenApiSchemaGenerator openApiGenerator,
IRequestUrlGenerator urlGenerator, IRequestUrlGenerator urlGenerator,
IRequestCache requestCache) IRequestCache requestCache)
{ {
this.appProvider = appProvider; this.appProvider = appProvider;
this.urlGenerator = urlGenerator; this.urlGenerator = urlGenerator;
this.schemaSettings = schemaSettings; this.openApiSettings = openApiSettings;
this.schemaGenerator = schemaGenerator; this.openApiGenerator = openApiGenerator;
this.requestCache = requestCache; this.requestCache = requestCache;
} }
@ -47,7 +47,7 @@ public sealed class SchemasOpenApiGenerator
{ {
var document = CreateApiDocument(httpContext, app); var document = CreateApiDocument(httpContext, app);
var schemaResolver = new OpenApiSchemaResolver(document, schemaSettings); var schemaResolver = new OpenApiSchemaResolver(document, openApiSettings.SchemaSettings);
requestCache.AddDependency(app.UniqueId, app.Version); requestCache.AddDependency(app.UniqueId, app.Version);
@ -56,7 +56,7 @@ public sealed class SchemasOpenApiGenerator
requestCache.AddDependency(schema.UniqueId, schema.Version); requestCache.AddDependency(schema.UniqueId, schema.Version);
} }
var builder = new Builder(app, document, schemaResolver, schemaGenerator); var builder = new Builder(app, document, schemaResolver, openApiGenerator);
var partitionResolver = app.PartitionResolver(); var partitionResolver = app.PartitionResolver();
@ -77,10 +77,10 @@ public sealed class SchemasOpenApiGenerator
Enumerable.Empty<Type>(), Enumerable.Empty<Type>(),
Enumerable.Empty<Type>(), Enumerable.Empty<Type>(),
schemaResolver, schemaResolver,
schemaGenerator, openApiGenerator,
schemaSettings); openApiSettings);
foreach (var processor in schemaSettings.DocumentProcessors) foreach (var processor in openApiSettings.DocumentProcessors)
{ {
processor.Process(context); processor.Process(context);
} }

4
backend/src/Squidex/Areas/IdentityServer/Config/DynamicApplicationStore.cs

@ -168,7 +168,7 @@ public class DynamicApplicationStore : InMemoryApplicationStore
Permissions.Prefixes.Scope + Constants.ScopeApi, Permissions.Prefixes.Scope + Constants.ScopeApi,
Permissions.Prefixes.Scope + Constants.ScopePermissions Permissions.Prefixes.Scope + Constants.ScopePermissions
}, },
Type = ClientTypes.Public ClientType = ClientTypes.Public
}); });
var internalClientId = Constants.ClientInternalId; var internalClientId = Constants.ClientInternalId;
@ -197,7 +197,7 @@ public class DynamicApplicationStore : InMemoryApplicationStore
Permissions.Prefixes.Scope + Constants.ScopeApi, Permissions.Prefixes.Scope + Constants.ScopeApi,
Permissions.Prefixes.Scope + Constants.ScopePermissions Permissions.Prefixes.Scope + Constants.ScopePermissions
}, },
Type = ClientTypes.Public ClientType = ClientTypes.Public
}); });
var identityOptions = serviceProvider.GetRequiredService<IOptions<MyIdentityOptions>>().Value; var identityOptions = serviceProvider.GetRequiredService<IOptions<MyIdentityOptions>>().Value;

6
backend/src/Squidex/Areas/IdentityServer/Config/TokenStoreInitializer.cs

@ -65,11 +65,11 @@ public sealed class TokenStoreInitializer : IInitializable, IBackgroundProcess
{ {
var database = await scope.ServiceProvider.GetRequiredService<IOpenIddictMongoDbContext>().GetDatabaseAsync(ct); var database = await scope.ServiceProvider.GetRequiredService<IOpenIddictMongoDbContext>().GetDatabaseAsync(ct);
var collection = database.GetCollection<OpenIddictMongoDbToken<string>>(options.TokensCollectionName); var collection = database.GetCollection<OpenIddictMongoDbToken>(options.TokensCollectionName);
await collection.Indexes.CreateOneAsync( await collection.Indexes.CreateOneAsync(
new CreateIndexModel<OpenIddictMongoDbToken<string>>( new CreateIndexModel<OpenIddictMongoDbToken>(
Builders<OpenIddictMongoDbToken<string>>.IndexKeys Builders<OpenIddictMongoDbToken>.IndexKeys
.Ascending(x => x.ReferenceId)), .Ascending(x => x.ReferenceId)),
cancellationToken: ct); cancellationToken: ct);
} }

8
backend/src/Squidex/Areas/IdentityServer/Controllers/Account/AccountController.cs

@ -96,13 +96,9 @@ public sealed class AccountController : IdentityServerController
return View(vm); return View(vm);
} }
var user = await userService.GetAsync(User, HttpContext.RequestAborted);
// There is almost no case where this could have happened. // There is almost no case where this could have happened.
if (user == null) var user = await userService.GetAsync(User, HttpContext.RequestAborted)
{ ?? throw new DomainException(T.Get("users.userNotFound"));
throw new DomainException(T.Get("users.userNotFound"));
}
var update = new UserValues var update = new UserValues
{ {

2
backend/src/Squidex/Areas/IdentityServer/Controllers/Setup/SetupController.cs

@ -108,7 +108,7 @@ public class SetupController : IdentityServerController
IsValidHttps = HttpContext.Request.IsHttps, IsValidHttps = HttpContext.Request.IsHttps,
IsAssetStoreFile = assetStore is FolderAssetStore, IsAssetStoreFile = assetStore is FolderAssetStore,
IsAssetStoreFtp = assetStore is FTPAssetStore, IsAssetStoreFtp = assetStore is FTPAssetStore,
HasExternalLogin = externalProviders.Any(), HasExternalLogin = externalProviders.Count != 0,
HasPasswordAuth = identityOptions.AllowPasswordAuth HasPasswordAuth = identityOptions.AllowPasswordAuth
}; };

2
backend/src/Squidex/Config/Domain/StoreServices.cs

@ -173,7 +173,7 @@ public static class StoreServices
services.AddOpenIddict() services.AddOpenIddict()
.AddCore(builder => .AddCore(builder =>
{ {
builder.UseMongoDb<string>() builder.UseMongoDb()
.SetScopesCollectionName("Identity_Scopes") .SetScopesCollectionName("Identity_Scopes")
.SetTokensCollectionName("Identity_Tokens"); .SetTokensCollectionName("Identity_Tokens");

22
backend/src/Squidex/Squidex.csproj

@ -37,27 +37,27 @@
<PackageReference Include="GraphQL" Version="7.7.2" /> <PackageReference Include="GraphQL" Version="7.7.2" />
<PackageReference Include="GraphQL.MicrosoftDI" Version="7.7.2" /> <PackageReference Include="GraphQL.MicrosoftDI" Version="7.7.2" />
<PackageReference Include="GraphQL.SystemTextJson" Version="7.7.2" /> <PackageReference Include="GraphQL.SystemTextJson" Version="7.7.2" />
<PackageReference Include="Meziantou.Analyzer" Version="2.0.125"> <PackageReference Include="Meziantou.Analyzer" Version="2.0.136">
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference> </PackageReference>
<PackageReference Include="Microsoft.AspNetCore.Authentication.Google" Version="8.0.0" /> <PackageReference Include="Microsoft.AspNetCore.Authentication.Google" Version="8.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.MicrosoftAccount" Version="8.0.0" /> <PackageReference Include="Microsoft.AspNetCore.Authentication.MicrosoftAccount" Version="8.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.OpenIdConnect" Version="8.0.0" /> <PackageReference Include="Microsoft.AspNetCore.Authentication.OpenIdConnect" Version="8.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation" Version="8.0.0" /> <PackageReference Include="Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation" Version="8.0.1" />
<PackageReference Include="Microsoft.AspNetCore.SpaServices.Extensions" Version="8.0.0" /> <PackageReference Include="Microsoft.AspNetCore.SpaServices.Extensions" Version="8.0.1" />
<PackageReference Include="Microsoft.Bcl.AsyncInterfaces" Version="8.0.0" /> <PackageReference Include="Microsoft.Bcl.AsyncInterfaces" Version="8.0.0" />
<PackageReference Include="Microsoft.CodeAnalysis.RulesetToEditorconfigConverter" Version="3.3.3" /> <PackageReference Include="Microsoft.CodeAnalysis.RulesetToEditorconfigConverter" Version="3.3.3" />
<PackageReference Include="Microsoft.Data.Edm" Version="5.8.5" /> <PackageReference Include="Microsoft.Data.Edm" Version="5.8.5" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="8.0.0" /> <PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Options" Version="8.0.0" /> <PackageReference Include="Microsoft.Extensions.Options" Version="8.0.1" />
<PackageReference Include="Microsoft.OData.Core" Version="7.20.0" /> <PackageReference Include="Microsoft.OData.Core" Version="7.20.0" />
<PackageReference Include="MongoDB.Driver" Version="2.23.1" /> <PackageReference Include="MongoDB.Driver" Version="2.23.1" />
<PackageReference Include="MongoDB.Driver.Core.Extensions.OpenTelemetry" Version="1.0.0" /> <PackageReference Include="MongoDB.Driver.Core.Extensions.OpenTelemetry" Version="1.0.0" />
<PackageReference Include="NetTopologySuite.IO.GeoJSON4STJ" Version="4.0.0" /> <PackageReference Include="NetTopologySuite.IO.GeoJSON4STJ" Version="4.0.0" />
<PackageReference Include="NJsonSchema" Version="10.9.0" /> <PackageReference Include="NJsonSchema" Version="11.0.0" />
<PackageReference Include="NodaTime.Serialization.SystemTextJson" Version="1.1.2" /> <PackageReference Include="NodaTime.Serialization.SystemTextJson" Version="1.1.2" />
<PackageReference Include="NSwag.AspNetCore" Version="13.20.0" /> <PackageReference Include="NSwag.AspNetCore" Version="14.0.1" />
<PackageReference Include="OpenCover" Version="4.7.1221" PrivateAssets="all" /> <PackageReference Include="OpenCover" Version="4.7.1221" PrivateAssets="all" />
<PackageReference Include="OpenTelemetry.Instrumentation.AspNetCore" Version="1.7.0" /> <PackageReference Include="OpenTelemetry.Instrumentation.AspNetCore" Version="1.7.0" />
<PackageReference Include="OpenTelemetry.Instrumentation.Http" Version="1.7.0" /> <PackageReference Include="OpenTelemetry.Instrumentation.Http" Version="1.7.0" />
@ -71,11 +71,11 @@
<PackageReference Include="Squidex.Assets.Mongo" Version="6.3.5" /> <PackageReference Include="Squidex.Assets.Mongo" Version="6.3.5" />
<PackageReference Include="Squidex.Assets.S3" Version="6.3.5" /> <PackageReference Include="Squidex.Assets.S3" Version="6.3.5" />
<PackageReference Include="Squidex.Assets.TusAdapter" Version="6.3.5" /> <PackageReference Include="Squidex.Assets.TusAdapter" Version="6.3.5" />
<PackageReference Include="Squidex.ClientLibrary" Version="17.2.0" /> <PackageReference Include="Squidex.ClientLibrary" Version="19.0.0" />
<PackageReference Include="Squidex.Hosting" Version="6.3.5" /> <PackageReference Include="Squidex.Hosting" Version="6.3.5" />
<PackageReference Include="Squidex.Messaging.All" Version="6.3.5" /> <PackageReference Include="Squidex.Messaging.All" Version="6.3.5" />
<PackageReference Include="Squidex.Messaging.Subscriptions" Version="6.3.5" /> <PackageReference Include="Squidex.Messaging.Subscriptions" Version="6.3.5" />
<PackageReference Include="Squidex.OpenIddict.MongoDb" Version="4.0.1-dev" /> <PackageReference Include="Squidex.OpenIddict.MongoDb" Version="5.1.0" />
<PackageReference Include="Squidex.YDotNet" Version="0.2.9" /> <PackageReference Include="Squidex.YDotNet" Version="0.2.9" />
<PackageReference Include="Squidex.YDotNet.Native" Version="0.2.9" /> <PackageReference Include="Squidex.YDotNet.Native" Version="0.2.9" />
<PackageReference Include="Squidex.YDotNet.Server" Version="0.2.9" /> <PackageReference Include="Squidex.YDotNet.Server" Version="0.2.9" />

2
backend/tests/Squidex.Domain.Apps.Core.Tests/Model/Contents/RichTextTests.cs

@ -56,6 +56,6 @@ public class RichTextTests
private static string Sanitize(string source) private static string Sanitize(string source)
{ {
return source.Replace("\r\n", "\n").Trim(); return source.Replace("\r\n", "\n", StringComparison.Ordinal).Trim();
} }
} }

8
backend/tests/Squidex.Domain.Apps.Core.Tests/Model/Schemas/SchemaTests.cs

@ -17,13 +17,11 @@ public class SchemaTests
{ {
private readonly Schema schema_0 = new Schema { Name = "my-schema" }; private readonly Schema schema_0 = new Schema { Name = "my-schema" };
public static IEnumerable<object[]> FieldProperyTypes() public static readonly TheoryData<Type> FieldPropertyTypes =
{ new TheoryData<Type>(typeof(Schema).Assembly.GetTypes().Where(x => x.BaseType == typeof(FieldProperties)));
return typeof(Schema).Assembly.GetTypes().Where(x => x.BaseType == typeof(FieldProperties)).Select(x => new object[] { x });
}
[Theory] [Theory]
[MemberData(nameof(FieldProperyTypes))] [MemberData(nameof(FieldPropertyTypes))]
public void Should_make_deep_equal_test(Type type) public void Should_make_deep_equal_test(Type type)
{ {
var lhs = (FieldProperties)Activator.CreateInstance(type)!; var lhs = (FieldProperties)Activator.CreateInstance(type)!;

8
backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/ConvertContent/FieldConvertersTests.cs

@ -19,11 +19,11 @@ public class FieldConvertersTests
{ {
private readonly LanguagesConfig languages = LanguagesConfig.English.Set(Language.DE); private readonly LanguagesConfig languages = LanguagesConfig.English.Set(Language.DE);
public static IEnumerable<object?[]> InvalidValues() public static readonly TheoryData<JsonValue> InvalidValues = new TheoryData<JsonValue>
{ {
yield return new object?[] { JsonValue.Null }; { JsonValue.Null },
yield return new object?[] { JsonValue.Create(false) }; // Undefined { JsonValue.Create(false) },
} };
[Fact] [Fact]
public void Should_not_change_data_if_all_field_values_have_correct_type() public void Should_not_change_data_if_all_field_values_have_correct_type()

24
backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/ExtractReferenceIds/ReferenceExtractionTests.cs

@ -19,6 +19,18 @@ public class ReferenceExtractionTests
private readonly Schema schema; private readonly Schema schema;
private readonly ResolvedComponents components; private readonly ResolvedComponents components;
public static readonly TheoryData<NestedField> ReferencingNestedFields = new TheoryData<NestedField>
{
{ Fields.References(1, "myRefs") },
{ Fields.Assets(1, "myAssets") },
};
public static readonly TheoryData<RootField> ReferencingFields = new TheoryData<RootField>
{
{ Fields.References(1, "myRefs", Partitioning.Invariant) },
{ Fields.Assets(1, "myAssets", Partitioning.Invariant) },
};
public ReferenceExtractionTests() public ReferenceExtractionTests()
{ {
schema = schema =
@ -299,18 +311,6 @@ public class ReferenceExtractionTests
Assert.Equal(CreateValue(id1), actual); Assert.Equal(CreateValue(id1), actual);
} }
public static IEnumerable<object[]> ReferencingNestedFields()
{
yield return new object[] { Fields.References(1, "myRefs") };
yield return new object[] { Fields.Assets(1, "myAssets") };
}
public static IEnumerable<object[]> ReferencingFields()
{
yield return new object[] { Fields.References(1, "myRefs", Partitioning.Invariant) };
yield return new object[] { Fields.Assets(1, "myAssets", Partitioning.Invariant) };
}
private static HashSet<DomainId> RandomIds() private static HashSet<DomainId> RandomIds()
{ {
return HashSet.Of(DomainId.NewGuid()); return HashSet.Of(DomainId.NewGuid());

2
backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/GenerateJsonSchema/JsonSchemaTests.cs

@ -86,7 +86,7 @@ public class JsonSchemaTests
{ {
var actual = new HashSet<string>(); var actual = new HashSet<string>();
void AddProperties(JsonSchema current) void AddProperties(JsonSchema? current)
{ {
if (current == null) if (current == null)
{ {

8
backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/HandleRules/EventJsonSchemaGeneratorTests.cs

@ -19,7 +19,7 @@ public class EventJsonSchemaGeneratorTests
{ {
var jsonSchemaGenerator = var jsonSchemaGenerator =
new JsonSchemaGenerator( new JsonSchemaGenerator(
new JsonSchemaGeneratorSettings()); new SystemTextJsonSchemaGeneratorSettings());
sut = new EventJsonSchemaGenerator(jsonSchemaGenerator); sut = new EventJsonSchemaGenerator(jsonSchemaGenerator);
} }
@ -34,10 +34,8 @@ public class EventJsonSchemaGeneratorTests
yield return nameof(EnrichedUsageExceededEvent); yield return nameof(EnrichedUsageExceededEvent);
} }
public static IEnumerable<object[]> AllTypesData() public static readonly TheoryData<string> AllTypesData =
{ new TheoryData<string>(AllTypes());
return AllTypes().Select(x => new object[] { x });
}
[Fact] [Fact]
public void Should_return_null_for_unknown_type_name() public void Should_return_null_for_unknown_type_name()

8
backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/ValidateContent/Validators/AssetsValidatorTests.cs

@ -24,11 +24,11 @@ public class AssetsValidatorTests : IClassFixture<TranslationsFixture>
private static readonly Asset ImageSvg = TestAssets.Svg(DomainId.NewGuid()); private static readonly Asset ImageSvg = TestAssets.Svg(DomainId.NewGuid());
private static readonly Asset Video = TestAssets.Video(DomainId.NewGuid()); private static readonly Asset Video = TestAssets.Video(DomainId.NewGuid());
public static IEnumerable<object[]> AssetsWithDimensions() public static readonly TheoryData<DomainId> AssetsWithDimensions = new TheoryData<DomainId>
{ {
yield return new object[] { Image1.Id }; { Image1.Id },
yield return new object[] { Video.Id }; { Video.Id }
} };
[Fact] [Fact]
public async Task Should_not_add_error_if_assets_are_valid() public async Task Should_not_add_error_if_assets_are_valid()

8
backend/tests/Squidex.Domain.Apps.Core.Tests/Squidex.Domain.Apps.Core.Tests.csproj

@ -14,9 +14,9 @@
<ProjectReference Include="..\..\src\Squidex.Infrastructure\Squidex.Infrastructure.csproj" /> <ProjectReference Include="..\..\src\Squidex.Infrastructure\Squidex.Infrastructure.csproj" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="FakeItEasy" Version="8.0.0" /> <PackageReference Include="FakeItEasy" Version="8.1.0" />
<PackageReference Include="FluentAssertions" Version="6.12.0" /> <PackageReference Include="FluentAssertions" Version="6.12.0" />
<PackageReference Include="Meziantou.Analyzer" Version="2.0.125"> <PackageReference Include="Meziantou.Analyzer" Version="2.0.136">
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference> </PackageReference>
@ -27,8 +27,8 @@
<PackageReference Include="NodaTime.Serialization.SystemTextJson" Version="1.1.2" /> <PackageReference Include="NodaTime.Serialization.SystemTextJson" Version="1.1.2" />
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118" PrivateAssets="all" /> <PackageReference Include="StyleCop.Analyzers" Version="1.1.118" PrivateAssets="all" />
<PackageReference Include="System.ValueTuple" Version="4.5.0" /> <PackageReference Include="System.ValueTuple" Version="4.5.0" />
<PackageReference Include="xunit" Version="2.6.3" /> <PackageReference Include="xunit" Version="2.6.5" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.5"> <PackageReference Include="xunit.runner.visualstudio" Version="2.5.6">
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference> </PackageReference>

17
backend/tests/Squidex.Domain.Apps.Entities.Tests/Assets/AssetChangedTriggerHandlerTests.cs

@ -18,6 +18,7 @@ using Squidex.Domain.Apps.Events;
using Squidex.Domain.Apps.Events.Assets; using Squidex.Domain.Apps.Events.Assets;
using Squidex.Domain.Apps.Events.Contents; using Squidex.Domain.Apps.Events.Contents;
using Squidex.Infrastructure.EventSourcing; using Squidex.Infrastructure.EventSourcing;
using Xunit;
namespace Squidex.Domain.Apps.Entities.Assets; namespace Squidex.Domain.Apps.Entities.Assets;
@ -28,6 +29,14 @@ public class AssetChangedTriggerHandlerTests : GivenContext
private readonly IAssetRepository assetRepository = A.Fake<IAssetRepository>(); private readonly IAssetRepository assetRepository = A.Fake<IAssetRepository>();
private readonly IRuleTriggerHandler sut; private readonly IRuleTriggerHandler sut;
public static readonly TheoryData<AssetEvent, EnrichedAssetEventType> TestEvents = new TheoryData<AssetEvent, EnrichedAssetEventType>
{
{ TestUtils.CreateEvent<AssetCreated>(), EnrichedAssetEventType.Created },
{ TestUtils.CreateEvent<AssetUpdated>(), EnrichedAssetEventType.Updated },
{ TestUtils.CreateEvent<AssetAnnotated>(), EnrichedAssetEventType.Annotated },
{ TestUtils.CreateEvent<AssetDeleted>(), EnrichedAssetEventType.Deleted }
};
public AssetChangedTriggerHandlerTests() public AssetChangedTriggerHandlerTests()
{ {
A.CallTo(() => scriptEngine.Evaluate(A<ScriptVars>._, "true", default)) A.CallTo(() => scriptEngine.Evaluate(A<ScriptVars>._, "true", default))
@ -39,14 +48,6 @@ public class AssetChangedTriggerHandlerTests : GivenContext
sut = new AssetChangedTriggerHandler(scriptEngine, assetLoader, assetRepository); sut = new AssetChangedTriggerHandler(scriptEngine, assetLoader, assetRepository);
} }
public static IEnumerable<object[]> TestEvents()
{
yield return new object[] { TestUtils.CreateEvent<AssetCreated>(), EnrichedAssetEventType.Created };
yield return new object[] { TestUtils.CreateEvent<AssetUpdated>(), EnrichedAssetEventType.Updated };
yield return new object[] { TestUtils.CreateEvent<AssetAnnotated>(), EnrichedAssetEventType.Annotated };
yield return new object[] { TestUtils.CreateEvent<AssetDeleted>(), EnrichedAssetEventType.Deleted };
}
[Fact] [Fact]
public void Should_return_true_if_asking_for_snapshot_support() public void Should_return_true_if_asking_for_snapshot_support()
{ {

25
backend/tests/Squidex.Domain.Apps.Entities.Tests/Assets/AssetUsageTrackerTests.cs

@ -25,6 +25,13 @@ public class AssetUsageTrackerTests : GivenContext
private readonly DomainId assetKey; private readonly DomainId assetKey;
private readonly AssetUsageTracker sut; private readonly AssetUsageTracker sut;
public static readonly TheoryData<AssetEvent, long, long> EventData = new TheoryData<AssetEvent, long, long>
{
{ new AssetCreated { FileSize = 128 }, 128, 1 },
{ new AssetUpdated { FileSize = 512 }, 512, 0 },
{ new AssetDeleted { DeletedSize = 512 }, -512, -1 }
};
public AssetUsageTrackerTests() public AssetUsageTrackerTests()
{ {
assetKey = DomainId.Combine(AppId, assetId); assetKey = DomainId.Combine(AppId, assetId);
@ -56,24 +63,6 @@ public class AssetUsageTrackerTests : GivenContext
Assert.True(sut.BatchSize > 1); Assert.True(sut.BatchSize > 1);
} }
public static IEnumerable<object[]> EventData()
{
yield return new object[]
{
new AssetCreated { FileSize = 128 }, 128, 1
};
yield return new object[]
{
new AssetUpdated { FileSize = 512 }, 512, 0
};
yield return new object[]
{
new AssetDeleted { DeletedSize = 512 }, -512, -1
};
}
[Theory] [Theory]
[MemberData(nameof(EventData))] [MemberData(nameof(EventData))]
public async Task Should_increase_usage_if_for_event(AssetEvent @event, long sizeDiff, long countDiff) public async Task Should_increase_usage_if_for_event(AssetEvent @event, long sizeDiff, long countDiff)

11
backend/tests/Squidex.Domain.Apps.Entities.Tests/Assets/AssetsFluidExtensionTests.cs

@ -26,6 +26,9 @@ public class AssetsFluidExtensionTests : GivenContext
private readonly IAssetThumbnailGenerator assetGenerator = A.Fake<IAssetThumbnailGenerator>(); private readonly IAssetThumbnailGenerator assetGenerator = A.Fake<IAssetThumbnailGenerator>();
private readonly FluidTemplateEngine sut; private readonly FluidTemplateEngine sut;
public static readonly TheoryData<string> Encodings =
new TheoryData<string>("ascii", "unicode", "utf8", "base64");
public AssetsFluidExtensionTests() public AssetsFluidExtensionTests()
{ {
var serviceProvider = var serviceProvider =
@ -45,14 +48,6 @@ public class AssetsFluidExtensionTests : GivenContext
sut = new FluidTemplateEngine(extensions); sut = new FluidTemplateEngine(extensions);
} }
public static IEnumerable<object[]> Encodings()
{
yield return new object[] { "ascii" };
yield return new object[] { "unicode" };
yield return new object[] { "utf8" };
yield return new object[] { "base64" };
}
public static byte[] Encode(string encoding, string text) public static byte[] Encode(string encoding, string text)
{ {
switch (encoding) switch (encoding)

11
backend/tests/Squidex.Domain.Apps.Entities.Tests/Assets/AssetsJintExtensionTests.cs

@ -32,6 +32,9 @@ public class AssetsJintExtensionTests : GivenContext, IClassFixture<Translations
private readonly IAssetThumbnailGenerator assetGenerator = A.Fake<IAssetThumbnailGenerator>(); private readonly IAssetThumbnailGenerator assetGenerator = A.Fake<IAssetThumbnailGenerator>();
private readonly JintScriptEngine sut; private readonly JintScriptEngine sut;
public static readonly TheoryData<string> Encodings =
new TheoryData<string>("ascii", "unicode", "utf8", "base64");
public AssetsJintExtensionTests() public AssetsJintExtensionTests()
{ {
var serviceProvider = var serviceProvider =
@ -57,14 +60,6 @@ public class AssetsJintExtensionTests : GivenContext, IClassFixture<Translations
extensions); extensions);
} }
public static IEnumerable<object[]> Encodings()
{
yield return new object[] { "ascii" };
yield return new object[] { "unicode" };
yield return new object[] { "utf8" };
yield return new object[] { "base64" };
}
public static byte[] Encode(string encoding, string text) public static byte[] Encode(string encoding, string text)
{ {
switch (encoding) switch (encoding)

24
backend/tests/Squidex.Domain.Apps.Entities.Tests/Assets/DefaultAssetFileStoreTests.cs

@ -23,23 +23,23 @@ public class DefaultAssetFileStoreTests : GivenContext
private readonly AssetOptions options = new AssetOptions(); private readonly AssetOptions options = new AssetOptions();
private readonly DefaultAssetFileStore sut; private readonly DefaultAssetFileStore sut;
public DefaultAssetFileStoreTests() public static readonly TheoryData<bool, string, string> PathCases = new TheoryData<bool, string, string>
{ {
sut = new DefaultAssetFileStore(assetStore, assetRepository, Options.Create(options)); { true, "resize=100", "{appId}/{assetId}_{assetFileVersion}_resize=100" },
} { true, string.Empty, "{appId}/{assetId}_{assetFileVersion}" },
{ false, "resize=100", "{appId}_{assetId}_{assetFileVersion}_resize=100" },
{ false, string.Empty, "{appId}_{assetId}_{assetFileVersion}" }
};
public static IEnumerable<object[]> PathCases() public static readonly TheoryData<string, string> PathCasesOld = new TheoryData<string, string>
{ {
yield return new object[] { true, "resize=100", "{appId}/{assetId}_{assetFileVersion}_resize=100" }; { "resize=100", "{assetId}_{assetFileVersion}_resize=100" },
yield return new object[] { true, string.Empty, "{appId}/{assetId}_{assetFileVersion}" }; { string.Empty, "{assetId}_{assetFileVersion}" }
yield return new object[] { false, "resize=100", "{appId}_{assetId}_{assetFileVersion}_resize=100" }; };
yield return new object[] { false, string.Empty, "{appId}_{assetId}_{assetFileVersion}" };
}
public static IEnumerable<object?[]> PathCasesOld() public DefaultAssetFileStoreTests()
{ {
yield return new object?[] { "resize=100", "{assetId}_{assetFileVersion}_resize=100" }; sut = new DefaultAssetFileStore(assetStore, assetRepository, Options.Create(options));
yield return new object?[] { string.Empty, "{assetId}_{assetFileVersion}" };
} }
[Theory] [Theory]

12
backend/tests/Squidex.Domain.Apps.Entities.Tests/Assets/MongoDb/AssetsQueryIntegrationTests.cs

@ -20,6 +20,12 @@ public class AssetsQueryIntegrationTests : IClassFixture<AssetsQueryFixture>, IA
{ {
private readonly ProfilerCollection profiler; private readonly ProfilerCollection profiler;
public static readonly TheoryData<DomainId?> ParentIds = new TheoryData<DomainId?>
{
{ null },
{ DomainId.Empty }
};
public AssetsQueryFixture _ { get; } public AssetsQueryFixture _ { get; }
public AssetsQueryIntegrationTests(AssetsQueryFixture fixture) public AssetsQueryIntegrationTests(AssetsQueryFixture fixture)
@ -172,12 +178,6 @@ public class AssetsQueryIntegrationTests : IClassFixture<AssetsQueryFixture>, IA
Assert.NotEmpty(assets); Assert.NotEmpty(assets);
} }
public static IEnumerable<object?[]> ParentIds()
{
yield return new object?[] { null };
yield return new object?[] { DomainId.Empty };
}
private async Task<IResultList<Asset>> QueryAsync(DomainId? parentId, ClrQuery clrQuery, private async Task<IResultList<Asset>> QueryAsync(DomainId? parentId, ClrQuery clrQuery,
int top = 1000, int top = 1000,
int skip = 100) int skip = 100)

20
backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/ContentChangedTriggerHandlerTests.cs

@ -33,6 +33,16 @@ public class ContentChangedTriggerHandlerTests : GivenContext
private readonly NamedId<DomainId> schemaNotMatching = NamedId.Of(DomainId.NewGuid(), "my-schema2"); private readonly NamedId<DomainId> schemaNotMatching = NamedId.Of(DomainId.NewGuid(), "my-schema2");
private readonly IRuleTriggerHandler sut; private readonly IRuleTriggerHandler sut;
public static readonly TheoryData<ContentEvent, EnrichedContentEventType> TestEvents = new TheoryData<ContentEvent, EnrichedContentEventType>()
{
{ TestUtils.CreateEvent<ContentCreated>(), EnrichedContentEventType.Created },
{ TestUtils.CreateEvent<ContentUpdated>(), EnrichedContentEventType.Updated },
{ TestUtils.CreateEvent<ContentDeleted>(), EnrichedContentEventType.Deleted },
{ TestUtils.CreateEvent<ContentStatusChanged>(x => x.Change = StatusChange.Change), EnrichedContentEventType.StatusChanged },
{ TestUtils.CreateEvent<ContentStatusChanged>(x => x.Change = StatusChange.Published), EnrichedContentEventType.Published },
{ TestUtils.CreateEvent<ContentStatusChanged>(x => x.Change = StatusChange.Unpublished), EnrichedContentEventType.Unpublished }
};
public ContentChangedTriggerHandlerTests() public ContentChangedTriggerHandlerTests()
{ {
A.CallTo(() => scriptEngine.Evaluate(A<ScriptVars>._, "true", default)) A.CallTo(() => scriptEngine.Evaluate(A<ScriptVars>._, "true", default))
@ -44,16 +54,6 @@ public class ContentChangedTriggerHandlerTests : GivenContext
sut = new ContentChangedTriggerHandler(scriptEngine, contentLoader, contentRepository); sut = new ContentChangedTriggerHandler(scriptEngine, contentLoader, contentRepository);
} }
public static IEnumerable<object[]> TestEvents()
{
yield return new object[] { TestUtils.CreateEvent<ContentCreated>(), EnrichedContentEventType.Created };
yield return new object[] { TestUtils.CreateEvent<ContentUpdated>(), EnrichedContentEventType.Updated };
yield return new object[] { TestUtils.CreateEvent<ContentDeleted>(), EnrichedContentEventType.Deleted };
yield return new object[] { TestUtils.CreateEvent<ContentStatusChanged>(x => x.Change = StatusChange.Change), EnrichedContentEventType.StatusChanged };
yield return new object[] { TestUtils.CreateEvent<ContentStatusChanged>(x => x.Change = StatusChange.Published), EnrichedContentEventType.Published };
yield return new object[] { TestUtils.CreateEvent<ContentStatusChanged>(x => x.Change = StatusChange.Unpublished), EnrichedContentEventType.Unpublished };
}
[Fact] [Fact]
public void Should_return_true_if_asking_for_snapshot_support() public void Should_return_true_if_asking_for_snapshot_support()
{ {

23
backend/tests/Squidex.Domain.Apps.Entities.Tests/Schemas/DomainObject/Guards/GuardSchemaFieldTests.cs

@ -11,6 +11,7 @@ using Squidex.Domain.Apps.Core.TestHelpers;
using Squidex.Domain.Apps.Entities.Schemas.Commands; using Squidex.Domain.Apps.Entities.Schemas.Commands;
using Squidex.Domain.Apps.Entities.TestHelpers; using Squidex.Domain.Apps.Entities.TestHelpers;
using Squidex.Infrastructure; using Squidex.Infrastructure;
using Squidex.Infrastructure.Translations;
using Squidex.Infrastructure.Validation; using Squidex.Infrastructure.Validation;
#pragma warning disable SA1310 // Field names must not contain underscore #pragma warning disable SA1310 // Field names must not contain underscore
@ -22,6 +23,17 @@ public class GuardSchemaFieldTests : GivenContext, IClassFixture<TranslationsFix
private readonly StringFieldProperties validProperties = new StringFieldProperties(); private readonly StringFieldProperties validProperties = new StringFieldProperties();
private readonly StringFieldProperties invalidProperties = new StringFieldProperties { MinLength = 10, MaxLength = 5 }; private readonly StringFieldProperties invalidProperties = new StringFieldProperties { MinLength = 10, MaxLength = 5 };
public static IEnumerable<object[]> FieldCommandData()
{
yield return new object[] { A<EnableField>(GuardSchemaField.CanEnable) };
yield return new object[] { A<DeleteField>(GuardSchemaField.CanDelete) };
yield return new object[] { A<DisableField>(GuardSchemaField.CanDisable) };
yield return new object[] { A<HideField>(GuardSchemaField.CanHide) };
yield return new object[] { A<LockField>(GuardSchemaField.CanLock) };
yield return new object[] { A<ShowField>(GuardSchemaField.CanShow) };
yield return new object[] { A<UpdateField>(GuardSchemaField.CanUpdate) };
}
public GuardSchemaFieldTests() public GuardSchemaFieldTests()
{ {
Schema = Schema Schema = Schema
@ -37,17 +49,6 @@ public class GuardSchemaFieldTests : GivenContext, IClassFixture<TranslationsFix
return method; return method;
} }
public static IEnumerable<object[]> FieldCommandData()
{
yield return new object[] { A<EnableField>(GuardSchemaField.CanEnable) };
yield return new object[] { A<DeleteField>(GuardSchemaField.CanDelete) };
yield return new object[] { A<DisableField>(GuardSchemaField.CanDisable) };
yield return new object[] { A<HideField>(GuardSchemaField.CanHide) };
yield return new object[] { A<LockField>(GuardSchemaField.CanLock) };
yield return new object[] { A<ShowField>(GuardSchemaField.CanShow) };
yield return new object[] { A<UpdateField>(GuardSchemaField.CanUpdate) };
}
[Theory] [Theory]
[MemberData(nameof(FieldCommandData))] [MemberData(nameof(FieldCommandData))]
public void Commands_should_throw_exception_if_field_not_found<T>(Action<T, Schema> action) where T : FieldCommand, new() public void Commands_should_throw_exception_if_field_not_found<T>(Action<T, Schema> action) where T : FieldCommand, new()

18
backend/tests/Squidex.Domain.Apps.Entities.Tests/Schemas/SchemaChangedTriggerHandlerTests.cs

@ -24,6 +24,15 @@ public class SchemaChangedTriggerHandlerTests : GivenContext
private readonly IScriptEngine scriptEngine = A.Fake<IScriptEngine>(); private readonly IScriptEngine scriptEngine = A.Fake<IScriptEngine>();
private readonly IRuleTriggerHandler sut; private readonly IRuleTriggerHandler sut;
public static readonly TheoryData<SchemaEvent, EnrichedSchemaEventType> TestEvents = new ()
{
{ TestUtils.CreateEvent<SchemaCreated>(), EnrichedSchemaEventType.Created },
{ TestUtils.CreateEvent<SchemaUpdated>(), EnrichedSchemaEventType.Updated },
{ TestUtils.CreateEvent<SchemaDeleted>(), EnrichedSchemaEventType.Deleted },
{ TestUtils.CreateEvent<SchemaPublished>(), EnrichedSchemaEventType.Published },
{ TestUtils.CreateEvent<SchemaUnpublished>(), EnrichedSchemaEventType.Unpublished },
};
public SchemaChangedTriggerHandlerTests() public SchemaChangedTriggerHandlerTests()
{ {
A.CallTo(() => scriptEngine.Evaluate(A<ScriptVars>._, "true", default)) A.CallTo(() => scriptEngine.Evaluate(A<ScriptVars>._, "true", default))
@ -35,15 +44,6 @@ public class SchemaChangedTriggerHandlerTests : GivenContext
sut = new SchemaChangedTriggerHandler(scriptEngine); sut = new SchemaChangedTriggerHandler(scriptEngine);
} }
public static IEnumerable<object[]> TestEvents()
{
yield return new object[] { TestUtils.CreateEvent<SchemaCreated>(), EnrichedSchemaEventType.Created };
yield return new object[] { TestUtils.CreateEvent<SchemaUpdated>(), EnrichedSchemaEventType.Updated };
yield return new object[] { TestUtils.CreateEvent<SchemaDeleted>(), EnrichedSchemaEventType.Deleted };
yield return new object[] { TestUtils.CreateEvent<SchemaPublished>(), EnrichedSchemaEventType.Published };
yield return new object[] { TestUtils.CreateEvent<SchemaUnpublished>(), EnrichedSchemaEventType.Unpublished };
}
[Fact] [Fact]
public void Should_return_false_if_asking_for_snapshot_support() public void Should_return_false_if_asking_for_snapshot_support()
{ {

12
backend/tests/Squidex.Domain.Apps.Entities.Tests/Squidex.Domain.Apps.Entities.Tests.csproj

@ -22,26 +22,26 @@
<ProjectReference Include="..\Squidex.Infrastructure.Tests\Squidex.Infrastructure.Tests.csproj" /> <ProjectReference Include="..\Squidex.Infrastructure.Tests\Squidex.Infrastructure.Tests.csproj" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="FakeItEasy" Version="8.0.0" /> <PackageReference Include="FakeItEasy" Version="8.1.0" />
<PackageReference Include="FluentAssertions" Version="6.12.0" /> <PackageReference Include="FluentAssertions" Version="6.12.0" />
<PackageReference Include="GraphQL" Version="7.7.2" /> <PackageReference Include="GraphQL" Version="7.7.2" />
<PackageReference Include="GraphQL.SystemTextJson" Version="7.7.2" /> <PackageReference Include="GraphQL.SystemTextJson" Version="7.7.2" />
<PackageReference Include="Lorem.Universal.Net" Version="4.0.80" /> <PackageReference Include="Lorem.Universal.Net" Version="4.0.80" />
<PackageReference Include="Meziantou.Analyzer" Version="2.0.125"> <PackageReference Include="Meziantou.Analyzer" Version="2.0.136">
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference> </PackageReference>
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="8.0.0" /> <PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Options" Version="8.0.0" /> <PackageReference Include="Microsoft.Extensions.Options" Version="8.0.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" /> <PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageReference Include="NodaTime.Serialization.JsonNet" Version="3.1.0" /> <PackageReference Include="NodaTime.Serialization.JsonNet" Version="3.1.0" />
<PackageReference Include="Squidex.YDotNet.Native" Version="0.2.9" /> <PackageReference Include="Squidex.YDotNet.Native" Version="0.2.9" />
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118" PrivateAssets="all" /> <PackageReference Include="StyleCop.Analyzers" Version="1.1.118" PrivateAssets="all" />
<PackageReference Include="System.Reactive.Linq" Version="6.0.0" /> <PackageReference Include="System.Reactive.Linq" Version="6.0.0" />
<PackageReference Include="System.ValueTuple" Version="4.5.0" /> <PackageReference Include="System.ValueTuple" Version="4.5.0" />
<PackageReference Include="Verify.Xunit" Version="22.8.0" /> <PackageReference Include="Verify.Xunit" Version="22.11.5" />
<PackageReference Include="xunit" Version="2.6.3" /> <PackageReference Include="xunit" Version="2.6.5" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.5"> <PackageReference Include="xunit.runner.visualstudio" Version="2.5.6">
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference> </PackageReference>

2
backend/tests/Squidex.Domain.Apps.Entities.Tests/TestHelpers/GivenContext.cs

@ -115,7 +115,7 @@ public abstract class GivenContext
}; };
} }
public Instant Timestamp() public static Instant Timestamp()
{ {
return SystemClock.Instance.GetCurrentInstant(); return SystemClock.Instance.GetCurrentInstant();
} }

8
backend/tests/Squidex.Domain.Users.Tests/Squidex.Domain.Users.Tests.csproj

@ -14,17 +14,17 @@
<ProjectReference Include="..\..\src\Squidex.Shared\Squidex.Shared.csproj" /> <ProjectReference Include="..\..\src\Squidex.Shared\Squidex.Shared.csproj" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="FakeItEasy" Version="8.0.0" /> <PackageReference Include="FakeItEasy" Version="8.1.0" />
<PackageReference Include="FluentAssertions" Version="6.12.0" /> <PackageReference Include="FluentAssertions" Version="6.12.0" />
<PackageReference Include="Meziantou.Analyzer" Version="2.0.125"> <PackageReference Include="Meziantou.Analyzer" Version="2.0.136">
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference> </PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" /> <PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118" PrivateAssets="all" /> <PackageReference Include="StyleCop.Analyzers" Version="1.1.118" PrivateAssets="all" />
<PackageReference Include="System.ValueTuple" Version="4.5.0" /> <PackageReference Include="System.ValueTuple" Version="4.5.0" />
<PackageReference Include="xunit" Version="2.6.3" /> <PackageReference Include="xunit" Version="2.6.5" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.5"> <PackageReference Include="xunit.runner.visualstudio" Version="2.5.6">
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference> </PackageReference>

20
backend/tests/Squidex.Infrastructure.Tests/HashExtensionsTests.cs

@ -12,13 +12,8 @@ namespace Squidex.Infrastructure;
public class HashExtensionsTests public class HashExtensionsTests
{ {
public static IEnumerable<object[]> InputLengths() public static readonly TheoryData<int> InputLengths =
{ new TheoryData<int>(1, 20, 50, 500);
yield return new object[] { 1 };
yield return new object[] { 20 };
yield return new object[] { 50 };
yield return new object[] { 500 };
}
[Fact] [Fact]
public void Should_calculate_hex_code_from_empty_array() public void Should_calculate_hex_code_from_empty_array()
@ -197,14 +192,11 @@ public class HashExtensionsTests
private static string WebhookHash(string value) private static string WebhookHash(string value)
{ {
using (var sha = SHA256.Create()) var bytesArray = Encoding.UTF8.GetBytes(value);
{ var bytesHash = SHA256.HashData(bytesArray);
var bytesArray = Encoding.UTF8.GetBytes(value);
var bytesHash = sha.ComputeHash(bytesArray);
var result = Convert.ToBase64String(bytesHash); var result = Convert.ToBase64String(bytesHash);
return result; return result;
}
} }
} }

8
backend/tests/Squidex.Infrastructure.Tests/Json/Objects/JsonValuesSerializationTests.cs

@ -18,11 +18,11 @@ public class JsonValuesSerializationTests
Bson Bson
} }
public static IEnumerable<object[]> Serializers() public static readonly TheoryData<SerializerMode> Serializers = new TheoryData<SerializerMode>
{ {
yield return new object[] { SerializerMode.Json }; { SerializerMode.Json },
yield return new object[] { SerializerMode.Bson }; { SerializerMode.Bson }
} };
private static T Serialize<T>(T input, SerializerMode mode) private static T Serialize<T>(T input, SerializerMode mode)
{ {

8
backend/tests/Squidex.Infrastructure.Tests/NamedIdTests.cs

@ -20,11 +20,11 @@ public class NamedIdTests
public NamedId<long> Value { get; set; } public NamedId<long> Value { get; set; }
} }
public static IEnumerable<object[]> Serializers() public static readonly TheoryData<SerializerMode> Serializers = new TheoryData<SerializerMode>
{ {
yield return new object[] { SerializerMode.Json }; { SerializerMode.Json },
yield return new object[] { SerializerMode.Bson }; { SerializerMode.Bson }
} };
private static T Serialize<T>(T input, SerializerMode mode) private static T Serialize<T>(T input, SerializerMode mode)
{ {

71
backend/tests/Squidex.Infrastructure.Tests/Queries/QueryFromJsonTests.cs

@ -9,6 +9,7 @@ using Squidex.Infrastructure.Collections;
using Squidex.Infrastructure.Json.Objects; using Squidex.Infrastructure.Json.Objects;
using Squidex.Infrastructure.Queries.Json; using Squidex.Infrastructure.Queries.Json;
using Squidex.Infrastructure.TestHelpers; using Squidex.Infrastructure.TestHelpers;
using Squidex.Infrastructure.Translations;
using Squidex.Infrastructure.Validation; using Squidex.Infrastructure.Validation;
namespace Squidex.Infrastructure.Queries; namespace Squidex.Infrastructure.Queries;
@ -71,7 +72,7 @@ public sealed class QueryFromJsonTests
public class DateTime public class DateTime
{ {
public static IEnumerable<object[]> ValidTests() public static TheoryData<string, string, string, string> ValidTests()
{ {
const string value = "2012-11-10T09:08:07Z"; const string value = "2012-11-10T09:08:07Z";
@ -122,7 +123,7 @@ public sealed class QueryFromJsonTests
public class Guid public class Guid
{ {
public static IEnumerable<object[]> ValidTests() public static TheoryData<string, string, string, string> ValidTests()
{ {
const string value = "bf57d32c-d4dd-4217-8c16-6dcb16975cf3"; const string value = "bf57d32c-d4dd-4217-8c16-6dcb16975cf3";
@ -173,14 +174,14 @@ public sealed class QueryFromJsonTests
public class String public class String
{ {
public static IEnumerable<object[]> ValidTests() public static TheoryData<string, string, string, string> ValidTests()
{ {
const string value = "Hello"; const string value = "Hello";
return BuildTests("string", x => true, value, $"'{value}'"); return BuildTests("string", x => true, value, $"'{value}'");
} }
public static IEnumerable<object[]> ValidInTests() public static TheoryData<string, string, string> ValidInTests()
{ {
const string value = "Hello"; const string value = "Hello";
@ -253,18 +254,18 @@ public sealed class QueryFromJsonTests
return op is "lt" or "exists"; return op is "lt" or "exists";
} }
public static IEnumerable<object[]> ValidTests() public static TheoryData<string, string, object, string> ValidTests()
{ {
var value = new { longitude = 10, latitude = 20, distance = 30 }; var value = new { longitude = 10, latitude = 20, distance = 30 };
return BuildFlatTests("geo", ValidOperator, value, $"Radius({value.longitude}, {value.latitude}, {value.distance})"); return BuildFlatTests<object>("geo", ValidOperator, value, $"Radius({value.longitude}, {value.latitude}, {value.distance})");
} }
public static IEnumerable<object[]> InvalidTests() public static TheoryData<string, string, object, string> InvalidTests()
{ {
var value = new { longitude = 10, latitude = 20, distance = 30 }; var value = new { longitude = 10, latitude = 20, distance = 30 };
return BuildInvalidOperatorTests("geo", ValidOperator, value); return BuildInvalidOperatorTests<object>("geo", ValidOperator, value);
} }
[Theory] [Theory]
@ -309,21 +310,21 @@ public sealed class QueryFromJsonTests
return op.Length == 2 || op == "exists"; return op.Length == 2 || op == "exists";
} }
public static IEnumerable<object[]> ValidTests() public static TheoryData<string, string, int, string> ValidTests()
{ {
const int value = 12; const int value = 12;
return BuildTests("number", ValidOperator, value, $"{value}"); return BuildTests("number", ValidOperator, value, $"{value}");
} }
public static IEnumerable<object[]> InvalidTests() public static TheoryData<string, string, int, string> InvalidTests()
{ {
const int value = 12; const int value = 12;
return BuildInvalidOperatorTests("number", ValidOperator, $"{value}"); return BuildInvalidOperatorTests("number", ValidOperator, value);
} }
public static IEnumerable<object[]> ValidInTests() public static TheoryData<string, int, string> ValidInTests()
{ {
const int value = 12; const int value = 12;
@ -389,21 +390,21 @@ public sealed class QueryFromJsonTests
return op is "eq" or "ne" or "exists"; return op is "eq" or "ne" or "exists";
} }
public static IEnumerable<object[]> ValidTests() public static TheoryData<string, string, bool, string> ValidTests()
{ {
const bool value = true; const bool value = true;
return BuildTests("boolean", ValidOperator, value, $"{value}"); return BuildTests("boolean", ValidOperator, value, $"{value}");
} }
public static IEnumerable<object[]> InvalidTests() public static TheoryData<string, string, bool, string> InvalidTests()
{ {
const bool value = true; const bool value = true;
return BuildInvalidOperatorTests("boolean", ValidOperator, value); return BuildInvalidOperatorTests("boolean", ValidOperator, value);
} }
public static IEnumerable<object[]> ValidInTests() public static TheoryData<string, bool, string> ValidInTests()
{ {
const bool value = true; const bool value = true;
@ -469,14 +470,14 @@ public sealed class QueryFromJsonTests
return op is "eq" or "ne" or "empty" or "exists"; return op is "eq" or "ne" or "empty" or "exists";
} }
public static IEnumerable<object[]> ValidTests() public static TheoryData<string, string, string, string> ValidTests()
{ {
const string value = "Hello"; const string value = "Hello";
return BuildTests("stringArray", ValidOperator, value, $"'{value}'"); return BuildTests("stringArray", ValidOperator, value, $"'{value}'");
} }
public static IEnumerable<object[]> ValidInTests() public static TheoryData<string, string, string> ValidInTests()
{ {
const string value = "Hello"; const string value = "Hello";
@ -694,13 +695,15 @@ public sealed class QueryFromJsonTests
return jsonFilter.ToString(); return jsonFilter.ToString();
} }
public static IEnumerable<object[]> BuildFlatTests(string field, Predicate<string> opFilter, object value, string valueString) public static TheoryData<string, string, T, string> BuildFlatTests<T>(string field, Predicate<string> opFilter, T value, string valueString)
{ {
var fields = new[] var fields = new[]
{ {
$"{field}" $"{field}"
}; };
var data = new TheoryData<string, string, T, string>();
foreach (var fieldName in fields) foreach (var fieldName in fields)
{ {
foreach (var (_, op, output) in AllOps.Where(x => opFilter(x.Operator))) foreach (var (_, op, output) in AllOps.Where(x => opFilter(x.Operator)))
@ -710,12 +713,14 @@ public sealed class QueryFromJsonTests
.Replace("$FIELD", fieldName, StringComparison.Ordinal) .Replace("$FIELD", fieldName, StringComparison.Ordinal)
.Replace("$VALUE", valueString, StringComparison.Ordinal); .Replace("$VALUE", valueString, StringComparison.Ordinal);
yield return new[] { fieldName, op, value, expected }; data.Add(fieldName, op, value, expected);
} }
} }
return data;
} }
public static IEnumerable<object[]> BuildTests(string field, Predicate<string> opFilter, object value, string valueString) public static TheoryData<string, string, T, string> BuildTests<T>(string field, Predicate<string> opFilter, T value, string valueString)
{ {
var fields = new[] var fields = new[]
{ {
@ -724,6 +729,8 @@ public sealed class QueryFromJsonTests
$"json.nested.{field}" $"json.nested.{field}"
}; };
var data = new TheoryData<string, string, T, string>();
foreach (var fieldName in fields) foreach (var fieldName in fields)
{ {
foreach (var (_, op, output) in AllOps.Where(x => opFilter(x.Operator))) foreach (var (_, op, output) in AllOps.Where(x => opFilter(x.Operator)))
@ -733,12 +740,14 @@ public sealed class QueryFromJsonTests
.Replace("$FIELD", fieldName, StringComparison.Ordinal) .Replace("$FIELD", fieldName, StringComparison.Ordinal)
.Replace("$VALUE", valueString, StringComparison.Ordinal); .Replace("$VALUE", valueString, StringComparison.Ordinal);
yield return new[] { fieldName, op, value, expected }; data.Add(fieldName, op, value, expected);
} }
} }
return data;
} }
public static IEnumerable<object[]> BuildInTests(string field, object value, string valueString) public static TheoryData<string, T, string> BuildInTests<T>(string field, T value, string valueString)
{ {
var fields = new[] var fields = new[]
{ {
@ -747,19 +756,27 @@ public sealed class QueryFromJsonTests
$"json.nested.{field}" $"json.nested.{field}"
}; };
foreach (var f in fields) var data = new TheoryData<string, T, string>();
foreach (var fieldName in fields)
{ {
var expected = $"{f} in [{valueString}]"; var expected = $"{fieldName} in [{valueString}]";
yield return new[] { f, value, expected }; data.Add(fieldName, value, expected);
} }
return data;
} }
public static IEnumerable<object[]> BuildInvalidOperatorTests(string field, Predicate<string> opFilter, object value) public static TheoryData<string, string, T, string> BuildInvalidOperatorTests<T>(string field, Predicate<string> opFilter, T value)
{ {
var data = new TheoryData<string, string, T, string>();
foreach (var (name, op, _) in AllOps.Where(x => !opFilter(x.Operator))) foreach (var (name, op, _) in AllOps.Where(x => !opFilter(x.Operator)))
{ {
yield return new[] { field, op, value, name }; data.Add(field, op, value, name);
} }
return data;
} }
} }

8
backend/tests/Squidex.Infrastructure.Tests/Squidex.Infrastructure.Tests.csproj

@ -14,9 +14,9 @@
<ProjectReference Include="..\..\src\Squidex.Infrastructure\Squidex.Infrastructure.csproj" /> <ProjectReference Include="..\..\src\Squidex.Infrastructure\Squidex.Infrastructure.csproj" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="FakeItEasy" Version="8.0.0" /> <PackageReference Include="FakeItEasy" Version="8.1.0" />
<PackageReference Include="FluentAssertions" Version="6.12.0" /> <PackageReference Include="FluentAssertions" Version="6.12.0" />
<PackageReference Include="Meziantou.Analyzer" Version="2.0.125"> <PackageReference Include="Meziantou.Analyzer" Version="2.0.136">
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference> </PackageReference>
@ -28,8 +28,8 @@
<PackageReference Include="NodaTime.Serialization.SystemTextJson" Version="1.1.2" /> <PackageReference Include="NodaTime.Serialization.SystemTextJson" Version="1.1.2" />
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118" PrivateAssets="all" /> <PackageReference Include="StyleCop.Analyzers" Version="1.1.118" PrivateAssets="all" />
<PackageReference Include="System.ValueTuple" Version="4.5.0" /> <PackageReference Include="System.ValueTuple" Version="4.5.0" />
<PackageReference Include="xunit" Version="2.6.3" /> <PackageReference Include="xunit" Version="2.6.5" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.5"> <PackageReference Include="xunit.runner.visualstudio" Version="2.5.6">
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference> </PackageReference>

8
backend/tests/Squidex.Web.Tests/Squidex.Web.Tests.csproj

@ -14,16 +14,16 @@
<ProjectReference Include="..\Squidex.Domain.Apps.Entities.Tests\Squidex.Domain.Apps.Entities.Tests.csproj" /> <ProjectReference Include="..\Squidex.Domain.Apps.Entities.Tests\Squidex.Domain.Apps.Entities.Tests.csproj" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="FakeItEasy" Version="8.0.0" /> <PackageReference Include="FakeItEasy" Version="8.1.0" />
<PackageReference Include="FluentAssertions" Version="6.12.0" /> <PackageReference Include="FluentAssertions" Version="6.12.0" />
<PackageReference Include="Meziantou.Analyzer" Version="2.0.125"> <PackageReference Include="Meziantou.Analyzer" Version="2.0.136">
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference> </PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" /> <PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118" PrivateAssets="all" /> <PackageReference Include="StyleCop.Analyzers" Version="1.1.118" PrivateAssets="all" />
<PackageReference Include="xunit" Version="2.6.3" /> <PackageReference Include="xunit" Version="2.6.5" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.5"> <PackageReference Include="xunit.runner.visualstudio" Version="2.5.6">
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference> </PackageReference>

6
tools/TestSuite/TestSuite.ApiTests/TestSuite.ApiTests.csproj

@ -11,16 +11,16 @@
<PackageReference Include="FluentAssertions" Version="6.12.0" /> <PackageReference Include="FluentAssertions" Version="6.12.0" />
<PackageReference Include="GraphQL.Client" Version="6.0.2" /> <PackageReference Include="GraphQL.Client" Version="6.0.2" />
<PackageReference Include="GraphQL.Client.Serializer.Newtonsoft" Version="6.0.2" /> <PackageReference Include="GraphQL.Client.Serializer.Newtonsoft" Version="6.0.2" />
<PackageReference Include="Meziantou.Analyzer" Version="2.0.135"> <PackageReference Include="Meziantou.Analyzer" Version="2.0.136">
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference> </PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" /> <PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageReference Include="NSwag.Core" Version="14.0.0" /> <PackageReference Include="NSwag.Core" Version="14.0.1" />
<PackageReference Include="PuppeteerSharp" Version="13.0.2" /> <PackageReference Include="PuppeteerSharp" Version="13.0.2" />
<PackageReference Include="Squidex.Assets" Version="6.3.5" /> <PackageReference Include="Squidex.Assets" Version="6.3.5" />
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118" PrivateAssets="all" /> <PackageReference Include="StyleCop.Analyzers" Version="1.1.118" PrivateAssets="all" />
<PackageReference Include="Verify.Xunit" Version="22.11.4" /> <PackageReference Include="Verify.Xunit" Version="22.11.5" />
<PackageReference Include="xunit" Version="2.6.5" /> <PackageReference Include="xunit" Version="2.6.5" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.6"> <PackageReference Include="xunit.runner.visualstudio" Version="2.5.6">
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>

10
tools/TestSuite/TestSuite.LoadTests/ReadingBenchmarks.cs

@ -27,7 +27,7 @@ public class ReadingBenchmarks : IClassFixture<CreatedAppFixture>
_ = fixture; _ = fixture;
} }
public static IEnumerable<object[]> Loads() public static TheoryData<int, int> Loads()
{ {
int[] users = int[] users =
{ {
@ -50,15 +50,19 @@ public class ReadingBenchmarks : IClassFixture<CreatedAppFixture>
1000 1000
}; };
var data = new TheoryData<int, int>();
foreach (var user in users) foreach (var user in users)
{ {
foreach (var load in loads) foreach (var load in loads)
{ {
yield return new object[] { user, load }; data.Add(user, load);
} }
} }
yield return new object[] { 1, 20000 }; data.Add(1, 20_0000);
return data;
} }
[Theory] [Theory]

10
tools/TestSuite/TestSuite.LoadTests/ReadingContentBenchmarks.cs

@ -21,7 +21,7 @@ public class ReadingContentBenchmarks : IClassFixture<ReadingFixture>
_ = fixture; _ = fixture;
} }
public static IEnumerable<object[]> Loads() public static TheoryData<int, int> Loads()
{ {
int[] users = int[] users =
{ {
@ -44,15 +44,19 @@ public class ReadingContentBenchmarks : IClassFixture<ReadingFixture>
1000 1000
}; };
var data = new TheoryData<int, int>();
foreach (var user in users) foreach (var user in users)
{ {
foreach (var load in loads) foreach (var load in loads)
{ {
yield return new object[] { user, load }; data.Add(user, load);
} }
} }
yield return new object[] { 1, 20000 }; data.Add(1, 20000);
return data;
} }
[Theory] [Theory]

2
tools/TestSuite/TestSuite.LoadTests/TestSuite.LoadTests.csproj

@ -7,7 +7,7 @@
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Meziantou.Analyzer" Version="2.0.135"> <PackageReference Include="Meziantou.Analyzer" Version="2.0.136">
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference> </PackageReference>

10
tools/TestSuite/TestSuite.LoadTests/WritingBenchmarks.cs

@ -22,7 +22,7 @@ public class WritingBenchmarks : IClassFixture<WritingFixture>
_ = fixture; _ = fixture;
} }
public static IEnumerable<object[]> Loads() public static TheoryData<int, int> Loads()
{ {
int[] users = int[] users =
{ {
@ -43,15 +43,19 @@ public class WritingBenchmarks : IClassFixture<WritingFixture>
100 100
}; };
var data = new TheoryData<int, int>();
foreach (var user in users) foreach (var user in users)
{ {
foreach (var load in loads) foreach (var load in loads)
{ {
yield return new object[] { user, load }; data.Add(user, load);
} }
} }
yield return new object[] { 1, 50000 }; data.Add(1, 50_0000);
return data;
} }
[Theory] [Theory]

8
tools/TestSuite/TestSuite.Shared/TestSuite.Shared.csproj

@ -7,7 +7,7 @@
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Meziantou.Analyzer" Version="2.0.135"> <PackageReference Include="Meziantou.Analyzer" Version="2.0.136">
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference> </PackageReference>
@ -18,10 +18,10 @@
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="8.0.0" /> <PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="8.0.0" />
<PackageReference Include="RefactoringEssentials" Version="5.6.0" PrivateAssets="all" /> <PackageReference Include="RefactoringEssentials" Version="5.6.0" PrivateAssets="all" />
<PackageReference Include="Squidex.Assets" Version="6.3.5" /> <PackageReference Include="Squidex.Assets" Version="6.3.5" />
<PackageReference Include="Squidex.ClientLibrary" Version="18.0.0" /> <PackageReference Include="Squidex.ClientLibrary" Version="19.0.0" />
<PackageReference Include="Squidex.ClientLibrary.ServiceExtensions" Version="18.0.0" /> <PackageReference Include="Squidex.ClientLibrary.ServiceExtensions" Version="19.0.0" />
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118" PrivateAssets="all" /> <PackageReference Include="StyleCop.Analyzers" Version="1.1.118" PrivateAssets="all" />
<PackageReference Include="Verify" Version="22.11.4" /> <PackageReference Include="Verify" Version="22.11.5" />
<PackageReference Include="xunit" Version="2.6.5" /> <PackageReference Include="xunit" Version="2.6.5" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

Loading…
Cancel
Save