Browse Source

Scripting fixes (#1000)

* Fix scripting.
* Fix content type.
* Fix schema names.
* Update client library.
pull/1003/head
Sebastian Stehle 3 years ago
committed by GitHub
parent
commit
2a5473720b
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      .github/workflows/dev.yml
  2. 2
      backend/i18n/source/backend_en.json
  3. 2
      backend/i18n/translator/Squidex.Translator/Commands.cs
  4. 2
      backend/src/Squidex.Domain.Apps.Core.Operations/ConvertContent/AddSchemaNames.cs
  5. 84
      backend/src/Squidex.Domain.Apps.Core.Operations/Scripting/Extensions/HttpJintExtension.cs
  6. 75
      backend/src/Squidex.Domain.Apps.Core.Operations/Scripting/JintScriptEngine.cs
  7. 4
      backend/src/Squidex.Domain.Apps.Core.Operations/Squidex.Domain.Apps.Core.Operations.csproj
  8. 1
      backend/src/Squidex.Domain.Apps.Entities/Contents/ContentSchedulerProcess.cs
  9. 2
      backend/src/Squidex.Domain.Apps.Entities/Squidex.Domain.Apps.Entities.csproj
  10. 12
      backend/src/Squidex.Infrastructure/Squidex.Infrastructure.csproj
  11. 2
      backend/src/Squidex.Shared/Texts.resx
  12. 3
      backend/src/Squidex/Areas/Api/Controllers/News/Service/FeaturesService.cs
  13. 2
      backend/src/Squidex/Config/Web/WebExtensions.cs
  14. 28
      backend/src/Squidex/Squidex.csproj
  15. 2
      backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/ConvertContent/FieldConvertersTests.cs
  16. 10
      backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/ConvertContent/ValueConvertersTests.cs
  17. 71
      backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/Scripting/JintScriptEngineHelperTests.cs
  18. 4
      backend/tests/Squidex.Domain.Apps.Entities.Tests/Assets/MongoDb/AssetQueryTests.cs
  19. 2
      tools/TestSuite/TestSuite.ApiTests/AdminUsersTests.cs
  20. 2
      tools/TestSuite/TestSuite.ApiTests/AnonymousTests.cs
  21. 1
      tools/TestSuite/TestSuite.ApiTests/AppClientsTests.cs
  22. 3
      tools/TestSuite/TestSuite.ApiTests/AppContributorsTests.cs
  23. 4
      tools/TestSuite/TestSuite.ApiTests/AppCreationTests.cs
  24. 1
      tools/TestSuite/TestSuite.ApiTests/AppLanguagesTests.cs
  25. 6
      tools/TestSuite/TestSuite.ApiTests/AppRolesTests.cs
  26. 8
      tools/TestSuite/TestSuite.ApiTests/AppTests.cs
  27. 1
      tools/TestSuite/TestSuite.ApiTests/AppWorkflowsTests.cs
  28. 2
      tools/TestSuite/TestSuite.ApiTests/AssetFoldersTests.cs
  29. 2
      tools/TestSuite/TestSuite.ApiTests/AssetFormatTests.cs
  30. 10
      tools/TestSuite/TestSuite.ApiTests/AssetTests.cs
  31. 5
      tools/TestSuite/TestSuite.ApiTests/BackupTests.cs
  32. 2
      tools/TestSuite/TestSuite.ApiTests/CommentsTests.cs
  33. 1
      tools/TestSuite/TestSuite.ApiTests/ContentScriptingTests.cs
  34. 1
      tools/TestSuite/TestSuite.ApiTests/ContentUpdateTests.cs
  35. 3
      tools/TestSuite/TestSuite.ApiTests/GraphQLFixture.cs
  36. 1
      tools/TestSuite/TestSuite.ApiTests/GraphQLSubscriptionTests.cs
  37. 1
      tools/TestSuite/TestSuite.ApiTests/RuleEventsTests.cs
  38. 3
      tools/TestSuite/TestSuite.ApiTests/RuleRunnerTests.cs
  39. 2
      tools/TestSuite/TestSuite.ApiTests/RuleTests.cs
  40. 4
      tools/TestSuite/TestSuite.ApiTests/SchemaTests.cs
  41. 1
      tools/TestSuite/TestSuite.ApiTests/SearchTests.cs
  42. 2
      tools/TestSuite/TestSuite.ApiTests/Verify/AnonymousTests.Should_create_app_with_anonymous_read_access.verified.txt
  43. 2
      tools/TestSuite/TestSuite.ApiTests/Verify/AnonymousTests.Should_create_app_with_anonymous_write_access.verified.txt
  44. 2
      tools/TestSuite/TestSuite.ApiTests/Verify/AppClientsTests.Should_create_client.verified.txt
  45. 4
      tools/TestSuite/TestSuite.ApiTests/Verify/AppClientsTests.Should_delete_client.verified.txt
  46. 6
      tools/TestSuite/TestSuite.ApiTests/Verify/AppClientsTests.Should_update_client.verified.txt
  47. 2
      tools/TestSuite/TestSuite.ApiTests/Verify/AppContributorsTests.Should_invite_contributor.verified.txt
  48. 2
      tools/TestSuite/TestSuite.ApiTests/Verify/AppContributorsTests.Should_remove_contributor.verified.txt
  49. 2
      tools/TestSuite/TestSuite.ApiTests/Verify/AppCreationTests.Should_create_app.verified.txt
  50. 18
      tools/TestSuite/TestSuite.ApiTests/Verify/AppCreationTests.Should_create_app_from_templates.verified.txt
  51. 6
      tools/TestSuite/TestSuite.ApiTests/Verify/AppLanguagesTests.Should_add_custom_language.verified.txt
  52. 6
      tools/TestSuite/TestSuite.ApiTests/Verify/AppLanguagesTests.Should_add_language.verified.txt
  53. 4
      tools/TestSuite/TestSuite.ApiTests/Verify/AppLanguagesTests.Should_delete_language.verified.txt
  54. 6
      tools/TestSuite/TestSuite.ApiTests/Verify/AppLanguagesTests.Should_update_language.verified.txt
  55. 6
      tools/TestSuite/TestSuite.ApiTests/Verify/AppLanguagesTests.Should_update_master_language.verified.txt
  56. 2
      tools/TestSuite/TestSuite.ApiTests/Verify/AppRolesTests.Should_create_role.verified.txt
  57. 2
      tools/TestSuite/TestSuite.ApiTests/Verify/AppRolesTests.Should_create_role_with_buggy_name.verified.txt
  58. 2
      tools/TestSuite/TestSuite.ApiTests/Verify/AppRolesTests.Should_update_role.verified.txt
  59. 2
      tools/TestSuite/TestSuite.ApiTests/Verify/AppTests.Should_update_settings.verified.txt
  60. 2
      tools/TestSuite/TestSuite.ApiTests/Verify/AppWorkflowsTests.Should_create_workflow.verified.txt
  61. 2
      tools/TestSuite/TestSuite.ApiTests/Verify/AppWorkflowsTests.Should_delete_workflow.verified.txt
  62. 4
      tools/TestSuite/TestSuite.ApiTests/Verify/AppWorkflowsTests.Should_update_workflow.verified.txt
  63. 2
      tools/TestSuite/TestSuite.ApiTests/Verify/AssetFoldersTests.Should_create_folder.verified.txt
  64. 2
      tools/TestSuite/TestSuite.ApiTests/Verify/AssetFoldersTests.Should_update_folder.verified.txt
  65. 2
      tools/TestSuite/TestSuite.ApiTests/Verify/AssetFormatTests.Should_fix_orientation.verified.txt
  66. 2
      tools/TestSuite/TestSuite.ApiTests/Verify/AssetFormatTests.Should_upload_audio_mp3.verified.txt
  67. 2
      tools/TestSuite/TestSuite.ApiTests/Verify/AssetFormatTests.Should_upload_image_bmp_and_encode_to_webp.verified.txt
  68. 2
      tools/TestSuite/TestSuite.ApiTests/Verify/AssetFormatTests.Should_upload_image_bmp_and_resize.verified.txt
  69. 2
      tools/TestSuite/TestSuite.ApiTests/Verify/AssetFormatTests.Should_upload_image_gif_and_resize.verified.txt
  70. 2
      tools/TestSuite/TestSuite.ApiTests/Verify/AssetFormatTests.Should_upload_image_gif_without_extension.verified.txt
  71. 2
      tools/TestSuite/TestSuite.ApiTests/Verify/AssetFormatTests.Should_upload_image_jpg_and_resize.verified.txt
  72. 2
      tools/TestSuite/TestSuite.ApiTests/Verify/AssetFormatTests.Should_upload_image_png_and_resize.verified.txt
  73. 2
      tools/TestSuite/TestSuite.ApiTests/Verify/AssetFormatTests.Should_upload_image_tga_and_resize.verified.txt
  74. 2
      tools/TestSuite/TestSuite.ApiTests/Verify/AssetFormatTests.Should_upload_image_tiff_and_resize.verified.txt
  75. 2
      tools/TestSuite/TestSuite.ApiTests/Verify/AssetFormatTests.Should_upload_image_webp_and_resize.verified.txt
  76. 2
      tools/TestSuite/TestSuite.ApiTests/Verify/AssetFormatTests.Should_upload_video_3gp.verified.txt
  77. 2
      tools/TestSuite/TestSuite.ApiTests/Verify/AssetFormatTests.Should_upload_video_flv.verified.txt
  78. 2
      tools/TestSuite/TestSuite.ApiTests/Verify/AssetFormatTests.Should_upload_video_mkv.verified.txt
  79. 2
      tools/TestSuite/TestSuite.ApiTests/Verify/AssetFormatTests.Should_upload_video_mp4.verified.txt
  80. 2
      tools/TestSuite/TestSuite.ApiTests/Verify/AssetTests.Should_annotate_asset_in_parallel.verified.txt
  81. 2
      tools/TestSuite/TestSuite.ApiTests/Verify/AssetTests.Should_annote_asset_file_name.verified.txt
  82. 2
      tools/TestSuite/TestSuite.ApiTests/Verify/AssetTests.Should_annote_asset_metadata.verified.txt
  83. 2
      tools/TestSuite/TestSuite.ApiTests/Verify/AssetTests.Should_annote_asset_slug.verified.txt
  84. 2
      tools/TestSuite/TestSuite.ApiTests/Verify/AssetTests.Should_annote_asset_tags.verified.txt
  85. 2
      tools/TestSuite/TestSuite.ApiTests/Verify/AssetTests.Should_protect_asset.verified.txt
  86. 2
      tools/TestSuite/TestSuite.ApiTests/Verify/AssetTests.Should_protect_asset_with_script.verified.txt
  87. 2
      tools/TestSuite/TestSuite.ApiTests/Verify/AssetTests.Should_replace_asset.verified.txt
  88. 2
      tools/TestSuite/TestSuite.ApiTests/Verify/AssetTests.Should_upload_asset.verified.txt
  89. 2
      tools/TestSuite/TestSuite.ApiTests/Verify/AssetTests.Should_upload_asset_with_custom_id.verified.txt
  90. 2
      tools/TestSuite/TestSuite.ApiTests/Verify/RuleTests.Should_create_rule.verified.txt
  91. 2
      tools/TestSuite/TestSuite.ApiTests/Verify/RuleTests.Should_update_rule.verified.txt
  92. 2
      tools/TestSuite/TestSuite.ApiTests/Verify/SchemaTests.Should_create_singleton_schema.verified.txt
  93. 2
      tools/TestSuite/TestSuite.ApiTests/Verify/SchemaTests.Should_create_singleton_schema_with_obsolete_property.verified.txt
  94. 5
      tools/TestSuite/TestSuite.Shared/ClientExtensions.cs
  95. 1
      tools/TestSuite/TestSuite.Shared/Fixtures/ClientFixture.cs
  96. 6
      tools/TestSuite/TestSuite.Shared/Fixtures/CreatedAppFixture.cs
  97. 3
      tools/TestSuite/TestSuite.Shared/Fixtures/TestSchemaFixtureBase.cs
  98. 3
      tools/TestSuite/TestSuite.Shared/Fixtures/TestSchemaWithReferencesFixtureBase.cs
  99. 1
      tools/TestSuite/TestSuite.Shared/Model/TestEntity.cs
  100. 1
      tools/TestSuite/TestSuite.Shared/Model/TestEntityWithReferences.cs

6
.github/workflows/dev.yml

@ -101,6 +101,12 @@ jobs:
run: |
echo "BUILD_NUMBER=$(($BUILD_NUMBER + 6000))" >> $GITHUB_ENV
- name: Publish - Login to Docker Hub
uses: docker/login-action@v2.1.0
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Publish - Rename Tags
if: github.event_name != 'pull_request'
run: |

2
backend/i18n/source/backend_en.json

@ -68,7 +68,7 @@
"common.httpOnlyAsUser": "Not allowed for clients.",
"common.httpValidationError": "Validation error",
"common.initialStep": "Initial step",
"common.jsError": "Failed to execute script with Javascript error: {message}",
"common.jsError": "Failed to execute script with Javascript runtime error: {message}",
"common.jsNotAllowed": "Script has forbidden the operation.",
"common.jsParseError": "Failed to execute script with Javascript syntax error: {message}",
"common.jsRejected": "Script rejected the operation.",

2
backend/i18n/translator/Squidex.Translator/Commands.cs

@ -140,7 +140,7 @@ public class Commands
throw new ArgumentException("Folder does not exist.", nameof(arguments));
}
var supportedLocales = new string[] { "en", "nl", "it", "zh", "pt","fr" };
var supportedLocales = new string[] { "en", "nl", "it", "zh", "pt", "fr" };
var locales = supportedLocales;

2
backend/src/Squidex.Domain.Apps.Core.Operations/ConvertContent/AddSchemaNames.cs

@ -21,7 +21,7 @@ public sealed class AddSchemaNames : IContentItemConverter
this.components = components;
}
public JsonObject ConvertItemBefore(IField parentField, JsonObject source, IEnumerable<IField> schema)
public JsonObject ConvertItemAfter(IField parentField, JsonObject source, IEnumerable<IField> schema)
{
if (parentField is IArrayField)
{

84
backend/src/Squidex.Domain.Apps.Core.Operations/Scripting/Extensions/HttpJintExtension.cs

@ -11,13 +11,14 @@ using Jint.Native;
using Jint.Native.Json;
using Jint.Runtime;
using Squidex.Domain.Apps.Core.Properties;
using Squidex.Infrastructure;
namespace Squidex.Domain.Apps.Core.Scripting.Extensions;
public sealed class HttpJintExtension : IJintExtension, IScriptDescriptor
{
private delegate void HttpJson(string url, Action<JsValue> callback, JsValue? headers = null);
private delegate void HttpJsonWithBody(string url, JsValue post, Action<JsValue> callback, JsValue? headers = null);
private delegate void HttpJson(string url, Action<JsValue> callback, JsValue? headers = null, bool ignoreError = false);
private delegate void HttpJsonWithBody(string url, JsValue post, Action<JsValue> callback, JsValue? headers = null, bool ignoreError = false);
private readonly IHttpClientFactory httpClientFactory;
public HttpJintExtension(IHttpClientFactory httpClientFactory)
@ -41,27 +42,27 @@ public sealed class HttpJintExtension : IJintExtension, IScriptDescriptor
return;
}
describe(JsonType.Function, "getJSON(url, callback, headers?)",
describe(JsonType.Function, "getJSON(url, callback, headers?, ignoreError?)",
Resources.ScriptingGetJSON);
describe(JsonType.Function, "postJSON(url, body, callback, headers?)",
describe(JsonType.Function, "postJSON(url, body, callback, headers?, ignoreError?)",
Resources.ScriptingPostJSON);
describe(JsonType.Function, "putJSON(url, body, callback, headers?)",
describe(JsonType.Function, "putJSON(url, body, callback, headers?, ignoreError?)",
Resources.ScriptingPutJson);
describe(JsonType.Function, "patchJSON(url, body, callback, headers?)",
describe(JsonType.Function, "patchJSON(url, body, callback, headers?, ignoreError?)",
Resources.ScriptingPatchJson);
describe(JsonType.Function, "deleteJSON(url, callback, headers?)",
describe(JsonType.Function, "deleteJSON(url, callback, headers?, ignoreError?)",
Resources.ScriptingDeleteJson);
}
private void AddMethod(ScriptExecutionContext context, HttpMethod method, string name)
{
var action = new HttpJson((url, callback, headers) =>
var action = new HttpJson((url, callback, headers, ignoreError) =>
{
Request(context, method, url, null, callback, headers);
Request(context, method, url, null, callback, headers, ignoreError);
});
context.Engine.SetValue(name, action);
@ -69,15 +70,15 @@ public sealed class HttpJintExtension : IJintExtension, IScriptDescriptor
private void AddBodyMethod(ScriptExecutionContext context, HttpMethod method, string name)
{
var action = new HttpJsonWithBody((url, body, callback, headers) =>
var action = new HttpJsonWithBody((url, body, callback, headers, ignoreError) =>
{
Request(context, method, url, body, callback, headers);
Request(context, method, url, body, callback, headers, ignoreError);
});
context.Engine.SetValue(name, action);
}
private void Request(ScriptExecutionContext context, HttpMethod method, string url, JsValue? body, Action<JsValue> callback, JsValue? headers)
private void Request(ScriptExecutionContext context, HttpMethod method, string url, JsValue? body, Action<JsValue> callback, JsValue? headers, bool ignoreError)
{
context.Schedule(async (scheduler, ct) =>
{
@ -86,19 +87,53 @@ public sealed class HttpJintExtension : IJintExtension, IScriptDescriptor
throw new JavaScriptException("URL is not valid.");
}
var httpClient = httpClientFactory.CreateClient("Jint");
if (callback == null)
{
throw new JavaScriptException("Callback is not defined.");
}
var request = CreateRequest(context, method, uri, body, headers);
var response = await httpClient.SendAsync(request, ct);
try
{
response.EnsureSuccessStatusCode();
var httpClient = httpClientFactory.CreateClient("Jint");
var responseObject = await ParseResponseasync(context, response, ct);
var request = CreateRequest(context, method, uri, body, headers);
var response = await httpClient.SendAsync(request, ct);
if (!ignoreError)
{
response.EnsureSuccessStatusCode();
}
JsValue responseObject;
if (ignoreError && !response.IsSuccessStatusCode)
{
var responseString = await response.Content.ReadAsStringAsync(ct);
responseObject = JsValue.FromObject(context.Engine, new Dictionary<string, object?>
{
["statusCode"] = (int)response.StatusCode,
["headers"] =
response.Content.Headers
.Concat(response.Headers)
.Concat(response.TrailingHeaders)
.GroupBy(x => x.Key)
.ToDictionary(x => x.Key, x => x.Last().Value.First()),
["body"] = responseString,
});
}
else
{
responseObject = await ParseResponseAsync(context, response, ct);
}
if (callback != null)
{
scheduler.Run(callback, responseObject);
}
catch (Exception ex)
{
throw new JavaScriptException(ex.Message);
}
});
}
@ -108,13 +143,12 @@ public sealed class HttpJintExtension : IJintExtension, IScriptDescriptor
if (body != null)
{
var serializer = new JsonSerializer(context.Engine);
var json = serializer.Serialize(body, JsValue.Undefined, JsValue.Undefined)?.ToString();
var jsonWriter = new JsonSerializer(context.Engine);
var jsonContent = jsonWriter.Serialize(body, JsValue.Undefined, JsValue.Undefined)?.ToString();
if (json != null)
if (jsonContent != null)
{
request.Content = new StringContent(json, Encoding.UTF8, "text/json");
request.Content = new StringContent(jsonContent, Encoding.UTF8, "application/json");
}
}
@ -138,7 +172,7 @@ public sealed class HttpJintExtension : IJintExtension, IScriptDescriptor
return request;
}
private static async Task<JsValue> ParseResponseasync(ScriptExecutionContext context, HttpResponseMessage response,
private static async Task<JsValue> ParseResponseAsync(ScriptExecutionContext context, HttpResponseMessage response,
CancellationToken ct)
{
var responseString = await response.Content.ReadAsStringAsync(ct);

75
backend/src/Squidex.Domain.Apps.Core.Operations/Scripting/JintScriptEngine.cs

@ -46,7 +46,8 @@ public sealed class JintScriptEngine : IScriptEngine, IScriptDescriptor
Guard.NotNull(vars);
Guard.NotNullOrEmpty(script);
using (var combined = CancellationTokenSource.CreateLinkedTokenSource(ct))
using var combined = CancellationTokenSource.CreateLinkedTokenSource(ct);
try
{
// Enforce a timeout after a configured time span.
combined.CancelAfter(timeoutExecution);
@ -66,6 +67,10 @@ public sealed class JintScriptEngine : IScriptEngine, IScriptDescriptor
return await context.CompleteAsync() ?? JsonMapper.Map(result);
}
catch (Exception ex)
{
throw MapException(ex);
}
}
public async Task<ContentData> TransformAsync(DataScriptVars vars, string script, ScriptOptions options = default,
@ -74,7 +79,8 @@ public sealed class JintScriptEngine : IScriptEngine, IScriptDescriptor
Guard.NotNull(vars);
Guard.NotNullOrEmpty(script);
using (var combined = CancellationTokenSource.CreateLinkedTokenSource(ct))
using var combined = CancellationTokenSource.CreateLinkedTokenSource(ct);
try
{
// Enforce a timeout after a configured time span.
combined.CancelAfter(timeoutExecution);
@ -107,6 +113,10 @@ public sealed class JintScriptEngine : IScriptEngine, IScriptDescriptor
return await context.CompleteAsync() ?? vars.Data!;
}
catch (Exception ex)
{
throw MapException(ex);
}
}
public JsonValue Execute(ScriptVars vars, string script, ScriptOptions options = default)
@ -114,14 +124,21 @@ public sealed class JintScriptEngine : IScriptEngine, IScriptDescriptor
Guard.NotNull(vars);
Guard.NotNullOrEmpty(script);
var context =
CreateEngine<object>(options, default)
.Extend(vars, options)
.Extend(extensions);
try
{
var context =
CreateEngine<object>(options, default)
.Extend(vars, options)
.Extend(extensions);
var result = Execute(context.Engine, script);
var result = Execute(context.Engine, script);
return JsonMapper.Map(result);
return JsonMapper.Map(result);
}
catch (Exception ex)
{
throw MapException(ex);
}
}
private ScriptExecutionContext<T> CreateEngine<T>(ScriptOptions options, CancellationToken ct)
@ -164,34 +181,28 @@ public sealed class JintScriptEngine : IScriptEngine, IScriptDescriptor
private JsValue Execute(Engine engine, string script)
{
try
{
var program = parser.Parse(script);
var program = parser.Parse(script);
lock (engine)
{
return engine.Evaluate(program);
}
}
catch (ArgumentException ex)
{
throw new ValidationException(T.Get("common.jsParseError", new { error = ex.Message }));
}
catch (JavaScriptException ex)
lock (engine)
{
throw new ValidationException(T.Get("common.jsError", new { message = ex.Message }));
return engine.Evaluate(program);
}
catch (ParserException ex)
{
throw new ValidationException(T.Get("common.jsError", new { message = ex.Message }));
}
catch (DomainException)
{
throw;
}
catch (Exception ex)
}
private static Exception MapException(Exception inner)
{
switch (inner)
{
throw new ValidationException(T.Get("common.jsError", new { message = ex.GetType().Name }), ex);
case ArgumentException:
return new ValidationException(T.Get("common.jsParseError", new { error = inner.Message }));
case JavaScriptException:
return new ValidationException(T.Get("common.jsError", new { message = inner.Message }));
case ParserException:
return new ValidationException(T.Get("common.jsError", new { message = inner.Message }));
case DomainException:
return inner;
default:
return new ValidationException(T.Get("common.jsError", new { message = inner.GetType().Name }), inner);
}
}

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

@ -26,9 +26,9 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Extensions.Http" Version="7.0.0" />
<PackageReference Include="NJsonSchema" Version="10.8.0" />
<PackageReference Include="NJsonSchema" Version="10.9.0" />
<PackageReference Include="RefactoringEssentials" Version="5.6.0" PrivateAssets="all" />
<PackageReference Include="Squidex.Messaging.Subscriptions" Version="5.4.0" />
<PackageReference Include="Squidex.Messaging.Subscriptions" Version="5.5.0" />
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118" PrivateAssets="all" />
<PackageReference Include="System.Collections.Immutable" Version="7.0.0" />
<PackageReference Include="System.Linq.Async" Version="6.0.1" />

1
backend/src/Squidex.Domain.Apps.Entities/Contents/ContentSchedulerProcess.cs

@ -7,7 +7,6 @@
using Microsoft.Extensions.Logging;
using NodaTime;
using Squidex.ClientLibrary;
using Squidex.Domain.Apps.Entities.Contents.Commands;
using Squidex.Domain.Apps.Entities.Contents.Repositories;
using Squidex.Hosting;

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

@ -29,7 +29,7 @@
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="7.0.0" />
<PackageReference Include="Notifo.SDK" Version="1.7.4" />
<PackageReference Include="RefactoringEssentials" Version="5.6.0" PrivateAssets="all" />
<PackageReference Include="Squidex.CLI.Core" Version="10.0.0" />
<PackageReference Include="Squidex.CLI.Core" Version="10.3.0" />
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118" PrivateAssets="all" />
<PackageReference Include="System.Collections.Immutable" Version="7.0.0" />
<PackageReference Include="System.ValueTuple" Version="4.5.0" />

12
backend/src/Squidex.Infrastructure/Squidex.Infrastructure.csproj

@ -24,12 +24,12 @@
<PackageReference Include="NodaTime" Version="3.1.6" />
<PackageReference Include="OpenTelemetry.Api" Version="1.4.0" />
<PackageReference Include="RefactoringEssentials" Version="5.6.0" PrivateAssets="all" />
<PackageReference Include="Squidex.Assets" Version="5.4.0" />
<PackageReference Include="Squidex.Caching" Version="5.4.0" />
<PackageReference Include="Squidex.Hosting.Abstractions" Version="5.4.0" />
<PackageReference Include="Squidex.Log" Version="5.4.0" />
<PackageReference Include="Squidex.Messaging" Version="5.4.0" />
<PackageReference Include="Squidex.Text" Version="5.4.0" />
<PackageReference Include="Squidex.Assets" Version="5.5.0" />
<PackageReference Include="Squidex.Caching" Version="5.5.0" />
<PackageReference Include="Squidex.Hosting.Abstractions" Version="5.5.0" />
<PackageReference Include="Squidex.Log" Version="5.5.0" />
<PackageReference Include="Squidex.Messaging" Version="5.5.0" />
<PackageReference Include="Squidex.Text" Version="5.5.0" />
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118" PrivateAssets="all" />
<PackageReference Include="System.Collections.Immutable" Version="7.0.0" />
<PackageReference Include="System.ComponentModel.Annotations" Version="5.0.0" />

2
backend/src/Squidex.Shared/Texts.resx

@ -290,7 +290,7 @@
<value>Initial step</value>
</data>
<data name="common.jsError" xml:space="preserve">
<value>Failed to execute script with Javascript error: {message}</value>
<value>Failed to execute script with Javascript runtime error: {message}</value>
</data>
<data name="common.jsNotAllowed" xml:space="preserve">
<value>Script has forbidden the operation.</value>

3
backend/src/Squidex/Areas/Api/Controllers/News/Service/FeaturesService.cs

@ -6,8 +6,9 @@
// ==========================================================================
using Microsoft.Extensions.Options;
using Squidex.Areas.Api.Controllers.News.Models;
using Squidex.ClientLibrary;
using FeatureDto = Squidex.Areas.Api.Controllers.News.Models.FeatureDto;
using FeaturesDto = Squidex.Areas.Api.Controllers.News.Models.FeaturesDto;
#pragma warning disable RECS0022 // A catch clause that catches System.Exception and has an empty body

2
backend/src/Squidex/Config/Web/WebExtensions.cs

@ -91,7 +91,7 @@ public static class WebExtensions
var json = serializer.Serialize(response);
httpContext.Response.Headers[HeaderNames.ContentType] = "text/json";
httpContext.Response.Headers[HeaderNames.ContentType] = "application/json";
return httpContext.Response.WriteAsync(json);
});

28
backend/src/Squidex/Squidex.csproj

@ -54,26 +54,26 @@
<PackageReference Include="MongoDB.Driver" Version="2.19.0" />
<PackageReference Include="MongoDB.Driver.Core.Extensions.OpenTelemetry" Version="1.0.0" />
<PackageReference Include="NetTopologySuite.IO.GeoJSON4STJ" Version="3.0.0" />
<PackageReference Include="NJsonSchema" Version="10.8.0" />
<PackageReference Include="NJsonSchema" Version="10.9.0" />
<PackageReference Include="NodaTime.Serialization.SystemTextJson" Version="1.0.0" />
<PackageReference Include="NSwag.AspNetCore" Version="13.18.2" />
<PackageReference Include="NSwag.AspNetCore" Version="13.19.0" />
<PackageReference Include="OpenCover" Version="4.7.1221" PrivateAssets="all" />
<PackageReference Include="OpenTelemetry.Instrumentation.AspNetCore" Version="1.0.0-rc7" />
<PackageReference Include="OpenTelemetry.Instrumentation.Http" Version="1.0.0-rc7" />
<PackageReference Include="RefactoringEssentials" Version="5.6.0" PrivateAssets="all" />
<PackageReference Include="ReportGenerator" Version="5.1.19" PrivateAssets="all" />
<PackageReference Include="Squidex.Assets.Azure" Version="5.4.0" />
<PackageReference Include="Squidex.Assets.GoogleCloud" Version="5.4.0" />
<PackageReference Include="Squidex.Assets.FTP" Version="5.4.0" />
<PackageReference Include="Squidex.Assets.ImageMagick" Version="5.4.0" />
<PackageReference Include="Squidex.Assets.ImageSharp" Version="5.4.0" />
<PackageReference Include="Squidex.Assets.Mongo" Version="5.4.0" />
<PackageReference Include="Squidex.Assets.S3" Version="5.4.0" />
<PackageReference Include="Squidex.Assets.TusAdapter" Version="5.4.0" />
<PackageReference Include="Squidex.ClientLibrary" Version="15.0.0" />
<PackageReference Include="Squidex.Hosting" Version="5.4.0" />
<PackageReference Include="Squidex.Messaging.All" Version="5.4.0" />
<PackageReference Include="Squidex.Messaging.Subscriptions" Version="5.4.0" />
<PackageReference Include="Squidex.Assets.Azure" Version="5.5.0" />
<PackageReference Include="Squidex.Assets.GoogleCloud" Version="5.5.0" />
<PackageReference Include="Squidex.Assets.FTP" Version="5.5.0" />
<PackageReference Include="Squidex.Assets.ImageMagick" Version="5.5.0" />
<PackageReference Include="Squidex.Assets.ImageSharp" Version="5.5.0" />
<PackageReference Include="Squidex.Assets.Mongo" Version="5.5.0" />
<PackageReference Include="Squidex.Assets.S3" Version="5.5.0" />
<PackageReference Include="Squidex.Assets.TusAdapter" Version="5.5.0" />
<PackageReference Include="Squidex.ClientLibrary" Version="16.0.0" />
<PackageReference Include="Squidex.Hosting" Version="5.5.0" />
<PackageReference Include="Squidex.Messaging.All" Version="5.5.0" />
<PackageReference Include="Squidex.Messaging.Subscriptions" Version="5.5.0" />
<PackageReference Include="Squidex.OpenIddict.MongoDb" Version="4.0.1-dev" />
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118" PrivateAssets="all" />
</ItemGroup>

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

@ -625,7 +625,7 @@ public class FieldConvertersTests
var actual =
new AddSchemaNames(components)
.ConvertItemBefore(field, source, Enumerable.Empty<IField>());
.ConvertItemAfter(field, source, Enumerable.Empty<IField>());
Assert.Equal(expected, actual);
}

10
backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/ConvertContent/ValueConvertersTests.cs

@ -167,7 +167,7 @@ public class ValueConvertersTests
var actual =
new AddSchemaNames(components)
.ConvertItemBefore(field, source, Enumerable.Empty<IField>());
.ConvertItemAfter(field, source, Enumerable.Empty<IField>());
var expected =
JsonValue.Object()
@ -196,7 +196,7 @@ public class ValueConvertersTests
var actual =
new AddSchemaNames(components)
.ConvertItemBefore(field, source, Enumerable.Empty<IField>());
.ConvertItemAfter(field, source, Enumerable.Empty<IField>());
var expected = source;
@ -221,7 +221,7 @@ public class ValueConvertersTests
var actual =
new AddSchemaNames(components)
.ConvertItemBefore(field, source, Enumerable.Empty<IField>());
.ConvertItemAfter(field, source, Enumerable.Empty<IField>());
var expected = source;
@ -245,7 +245,7 @@ public class ValueConvertersTests
var actual =
new AddSchemaNames(components)
.ConvertItemBefore(field, source, Enumerable.Empty<IField>());
.ConvertItemAfter(field, source, Enumerable.Empty<IField>());
var expected = source;
@ -265,7 +265,7 @@ public class ValueConvertersTests
var actual =
new AddSchemaNames(ResolvedComponents.Empty)
.ConvertItemBefore(field, source, Enumerable.Empty<IField>());
.ConvertItemAfter(field, source, Enumerable.Empty<IField>());
var expected = source;

71
backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/Scripting/JintScriptEngineHelperTests.cs

@ -6,7 +6,7 @@
// ==========================================================================
using System.Net;
using Jint.Runtime;
using System.Text;
using Microsoft.Extensions.Caching.Memory;
using Microsoft.Extensions.Options;
using Squidex.Domain.Apps.Core.Scripting;
@ -363,7 +363,25 @@ public class JintScriptEngineHelperTests : IClassFixture<TranslationsFixture>
});
";
await Assert.ThrowsAsync<JavaScriptException>(() => sut.ExecuteAsync(vars, script));
await Assert.ThrowsAsync<ValidationException>(() => sut.ExecuteAsync(vars, script));
}
[Fact]
public async Task Should_throw_exception_if_getJson_request_fails()
{
var vars = new ScriptVars
{
};
const string script = @"
var url = 'http://squidex.io';
postJSON(url, {}, function(actual) {
complete(actual);
});
";
await Assert.ThrowsAsync<ValidationException>(() => sut.ExecuteAsync(vars, script));
}
[Fact]
@ -379,7 +397,38 @@ public class JintScriptEngineHelperTests : IClassFixture<TranslationsFixture>
getJSON(url, null);
";
await Assert.ThrowsAsync<JavaScriptException>(() => sut.ExecuteAsync(vars, script));
await Assert.ThrowsAsync<ValidationException>(() => sut.ExecuteAsync(vars, script));
}
[Fact]
public async Task Should_not_throw_exception_if_getJson_request_fails_and_flag_is_true()
{
SetupRequest(HttpStatusCode.BadRequest);
var vars = new ScriptVars
{
};
const string script = @"
var url = 'http://squidex.io/invalid.json';
postJSON(url, {}, function(actual) {
complete(actual);
}, undefined, true);
";
var actual = await sut.ExecuteAsync(vars, script);
var expectedResult =
JsonValue.Object()
.Add("statusCode", 400)
.Add("headers",
JsonValue.Object()
.Add("Content-Type", "application/json; charset=utf-8")
.Add("Content-Length", "13"))
.Add("body", "{ \"key\": 42 }");
Assert.Equal(expectedResult, actual);
}
[Fact]
@ -404,7 +453,9 @@ public class JintScriptEngineHelperTests : IClassFixture<TranslationsFixture>
httpHandler.ShouldBeMethod(HttpMethod.Get);
httpHandler.ShouldBeUrl("http://squidex.io/");
var expectedResult = JsonValue.Object().Add("key", 42);
var expectedResult =
JsonValue.Object()
.Add("key", 42);
Assert.Equal(expectedResult, actual);
}
@ -493,7 +544,7 @@ public class JintScriptEngineHelperTests : IClassFixture<TranslationsFixture>
httpHandler.ShouldBeMethod(HttpMethod.Patch);
httpHandler.ShouldBeUrl("http://squidex.io/");
httpHandler.ShouldBeBody("{\"key\":42}", "text/json");
httpHandler.ShouldBeBody("{\"key\":42}", "application/json");
var expectedResult = JsonValue.Object().Add("key", 42);
@ -523,7 +574,7 @@ public class JintScriptEngineHelperTests : IClassFixture<TranslationsFixture>
httpHandler.ShouldBeMethod(HttpMethod.Post);
httpHandler.ShouldBeUrl("http://squidex.io/");
httpHandler.ShouldBeBody("{\"key\":42}", "text/json");
httpHandler.ShouldBeBody("{\"key\":42}", "application/json");
var expectedResult = JsonValue.Object().Add("key", 42);
@ -553,18 +604,18 @@ public class JintScriptEngineHelperTests : IClassFixture<TranslationsFixture>
httpHandler.ShouldBeMethod(HttpMethod.Put);
httpHandler.ShouldBeUrl("http://squidex.io/");
httpHandler.ShouldBeBody("{\"key\":42}", "text/json");
httpHandler.ShouldBeBody("{\"key\":42}", "application/json");
var expectedResult = JsonValue.Object().Add("key", 42);
Assert.Equal(expectedResult, actual);
}
private MockupHttpHandler SetupRequest()
private MockupHttpHandler SetupRequest(HttpStatusCode statusCode = HttpStatusCode.OK)
{
var httpResponse = new HttpResponseMessage(HttpStatusCode.OK)
var httpResponse = new HttpResponseMessage(statusCode)
{
Content = new StringContent("{ \"key\": 42 }")
Content = new StringContent("{ \"key\": 42 }", Encoding.UTF8, "application/json")
};
var httpHandler = new MockupHttpHandler(httpResponse);

4
backend/tests/Squidex.Domain.Apps.Entities.Tests/Assets/MongoDb/AssetQueryTests.cs

@ -146,9 +146,9 @@ public class AssetQueryTests
[Fact]
public void Should_make_query_with_mimeType()
{
var filter = ClrFilter.Eq("mimeType", "text/json");
var filter = ClrFilter.Eq("mimeType", "application/json");
AssertQuery("{ 'mm' : 'text/json' }", filter);
AssertQuery("{ 'mm' : 'application/json' }", filter);
}
[Fact]

2
tools/TestSuite/TestSuite.ApiTests/AdminUsersTests.cs

@ -5,7 +5,7 @@
// All rights reserved. Licensed under the MIT license.
// ==========================================================================
using Squidex.ClientLibrary.Management;
using Squidex.ClientLibrary;
using TestSuite.Fixtures;
#pragma warning disable SA1300 // Element should begin with upper-case letter

2
tools/TestSuite/TestSuite.ApiTests/AnonymousTests.cs

@ -6,7 +6,7 @@
// ==========================================================================
using System.Net;
using Squidex.ClientLibrary.Management;
using Squidex.ClientLibrary;
using TestSuite.Fixtures;
#pragma warning disable SA1300 // Element should begin with upper-case letter

1
tools/TestSuite/TestSuite.ApiTests/AppClientsTests.cs

@ -6,7 +6,6 @@
// ==========================================================================
using Squidex.ClientLibrary;
using Squidex.ClientLibrary.Management;
using TestSuite.Fixtures;
#pragma warning disable SA1300 // Element should begin with upper-case letter

3
tools/TestSuite/TestSuite.ApiTests/AppContributorsTests.cs

@ -6,7 +6,6 @@
// ==========================================================================
using Squidex.ClientLibrary;
using Squidex.ClientLibrary.Management;
using TestSuite.Fixtures;
#pragma warning disable SA1300 // Element should begin with upper-case letter
@ -39,7 +38,7 @@ public sealed class AppContributorsTests : IClassFixture<ClientFixture>
ContributorId = "test@squidex.io"
};
var ex = await Assert.ThrowsAnyAsync<SquidexManagementException>(() =>
var ex = await Assert.ThrowsAnyAsync<SquidexException>(() =>
{
return app.Apps.PostContributorAsync(createRequest);
});

4
tools/TestSuite/TestSuite.ApiTests/AppCreationTests.cs

@ -5,7 +5,7 @@
// All rights reserved. Licensed under the MIT license.
// ==========================================================================
using Squidex.ClientLibrary.Management;
using Squidex.ClientLibrary;
using TestSuite.Fixtures;
#pragma warning disable SA1300 // Element should begin with upper-case letter
@ -66,7 +66,7 @@ public class AppCreationTests : IClassFixture<ClientFixture>
// STEP 2: Create again and fail.
var ex = await Assert.ThrowsAnyAsync<SquidexManagementException>(() =>
var ex = await Assert.ThrowsAnyAsync<SquidexException>(() =>
{
return _.PostAppAsync(appName);
});

1
tools/TestSuite/TestSuite.ApiTests/AppLanguagesTests.cs

@ -6,7 +6,6 @@
// ==========================================================================
using Squidex.ClientLibrary;
using Squidex.ClientLibrary.Management;
using TestSuite.Fixtures;
#pragma warning disable SA1300 // Element should begin with upper-case letter

6
tools/TestSuite/TestSuite.ApiTests/AppRolesTests.cs

@ -5,7 +5,7 @@
// All rights reserved. Licensed under the MIT license.
// ==========================================================================
using Squidex.ClientLibrary.Management;
using Squidex.ClientLibrary;
using TestSuite.Fixtures;
#pragma warning disable SA1300 // Element should begin with upper-case letter
@ -102,7 +102,7 @@ public sealed class AppRolesTests : IClassFixture<CreatedAppFixture>
// STEP 4: Try to delete role.
var ex = await Assert.ThrowsAnyAsync<SquidexManagementException>(() =>
var ex = await Assert.ThrowsAnyAsync<SquidexException>(() =>
{
return _.Client.Apps.DeleteRoleAsync(roleName);
});
@ -137,7 +137,7 @@ public sealed class AppRolesTests : IClassFixture<CreatedAppFixture>
// STEP 4: Try to delete role..
var ex = await Assert.ThrowsAnyAsync<SquidexManagementException>(() =>
var ex = await Assert.ThrowsAnyAsync<SquidexException>(() =>
{
return _.Client.Apps.DeleteRoleAsync(roleName);
});

8
tools/TestSuite/TestSuite.ApiTests/AppTests.cs

@ -5,7 +5,7 @@
// All rights reserved. Licensed under the MIT license.
// ==========================================================================
using Squidex.ClientLibrary.Management;
using Squidex.ClientLibrary;
using TestSuite.Fixtures;
#pragma warning disable SA1300 // Element should begin with upper-case letter
@ -71,7 +71,7 @@ public sealed class AppTests : IClassFixture<CreatedAppFixture>
var app_1 = await _.Client.Apps.UploadImageAsync(file);
// Should contain image link.
Assert.True(app_1._links.ContainsKey("image"));
Assert.True(app_1.Links.ContainsKey("image"));
}
@ -103,7 +103,7 @@ public sealed class AppTests : IClassFixture<CreatedAppFixture>
var app_1 = await _.Client.Apps.UploadImageAsync(file);
// Should contain image link.
Assert.True(app_1._links.ContainsKey("image"));
Assert.True(app_1.Links.ContainsKey("image"));
}
@ -111,7 +111,7 @@ public sealed class AppTests : IClassFixture<CreatedAppFixture>
var app_2 = await _.Client.Apps.DeleteImageAsync();
// Should contain image link.
Assert.False(app_2._links.ContainsKey("image"));
Assert.False(app_2.Links.ContainsKey("image"));
}
[Fact]

1
tools/TestSuite/TestSuite.ApiTests/AppWorkflowsTests.cs

@ -6,7 +6,6 @@
// ==========================================================================
using Squidex.ClientLibrary;
using Squidex.ClientLibrary.Management;
using TestSuite.Fixtures;
#pragma warning disable SA1300 // Element should begin with upper-case letter

2
tools/TestSuite/TestSuite.ApiTests/AssetFoldersTests.cs

@ -5,7 +5,7 @@
// All rights reserved. Licensed under the MIT license.
// ==========================================================================
using Squidex.ClientLibrary.Management;
using Squidex.ClientLibrary;
using TestSuite.Fixtures;
#pragma warning disable SA1300 // Element should begin with upper-case letter

2
tools/TestSuite/TestSuite.ApiTests/AssetFormatTests.cs

@ -5,7 +5,7 @@
// All rights reserved. Licensed under the MIT license.
// ==========================================================================
using Squidex.ClientLibrary.Management;
using Squidex.ClientLibrary;
using TestSuite.Fixtures;
#pragma warning disable SA1300 // Element should begin with upper-case letter

10
tools/TestSuite/TestSuite.ApiTests/AssetTests.cs

@ -7,7 +7,7 @@
using System.Net;
using Squidex.Assets;
using Squidex.ClientLibrary.Management;
using Squidex.ClientLibrary;
using TestSuite.Fixtures;
#pragma warning disable SA1300 // Element should begin with upper-case letter
@ -131,7 +131,7 @@ public class AssetTests : IClassFixture<CreatedAppFixture>
// STEP 2: Create a new item with a custom id.
var ex = await Assert.ThrowsAnyAsync<SquidexManagementException>(() =>
var ex = await Assert.ThrowsAnyAsync<SquidexException>(() =>
{
return _.Client.Assets.UploadFileAsync("Assets/logo-squared.png", "image/png", id: id);
});
@ -153,7 +153,7 @@ public class AssetTests : IClassFixture<CreatedAppFixture>
});
// Client library cannot catch this exception properly.
Assert.True(ex is HttpRequestException || ex is SquidexManagementException);
Assert.True(ex is HttpRequestException || ex is SquidexException);
}
[Fact]
@ -354,7 +354,7 @@ public class AssetTests : IClassFixture<CreatedAppFixture>
await _.Client.Assets.PutAssetAsync(asset_1.Id, randomMetadataRequest);
}
catch (SquidexManagementException ex) when (ex.StatusCode is 409 or 412)
catch (SquidexException ex) when (ex.StatusCode is 409 or 412)
{
return;
}
@ -645,7 +645,7 @@ public class AssetTests : IClassFixture<CreatedAppFixture>
await _.Client.Assets.DeleteAssetAsync(asset.Id, permanent: permanent);
// Should return 404 when asset deleted.
var ex = await Assert.ThrowsAnyAsync<SquidexManagementException>(() =>
var ex = await Assert.ThrowsAnyAsync<SquidexException>(() =>
{
return _.Client.Assets.GetAssetAsync(asset.Id);
});

5
tools/TestSuite/TestSuite.ApiTests/BackupTests.cs

@ -6,7 +6,6 @@
// ==========================================================================
using Squidex.ClientLibrary;
using Squidex.ClientLibrary.Management;
using TestSuite.Fixtures;
using TestSuite.Model;
using TestSuite.Utils;
@ -53,7 +52,7 @@ public class BackupTests : IClassFixture<ClientFixture>
// STEP 3: Restore backup.
var uri = new Uri(new Uri(backupUrl), backup._links["download"].Href);
var uri = new Uri(new Uri(backupUrl), backup.Links["download"].Href);
var restoreRequest = new RestoreRequestDto
{
@ -99,7 +98,7 @@ public class BackupTests : IClassFixture<ClientFixture>
// STEP 4: Restore backup.
var uri = new Uri(new Uri(backupUrl), backup._links["download"].Href);
var uri = new Uri(new Uri(backupUrl), backup.Links["download"].Href);
var restoreRequest = new RestoreRequestDto
{

2
tools/TestSuite/TestSuite.ApiTests/CommentsTests.cs

@ -5,7 +5,7 @@
// All rights reserved. Licensed under the MIT license.
// ==========================================================================
using Squidex.ClientLibrary.Management;
using Squidex.ClientLibrary;
using TestSuite.Fixtures;
#pragma warning disable SA1300 // Element should begin with upper-case letter

1
tools/TestSuite/TestSuite.ApiTests/ContentScriptingTests.cs

@ -6,7 +6,6 @@
// ==========================================================================
using Squidex.ClientLibrary;
using Squidex.ClientLibrary.Management;
using TestSuite.Fixtures;
using TestSuite.Model;

1
tools/TestSuite/TestSuite.ApiTests/ContentUpdateTests.cs

@ -8,7 +8,6 @@
using Newtonsoft.Json.Linq;
using Squidex.ClientLibrary;
using Squidex.ClientLibrary.EnrichedEvents;
using Squidex.ClientLibrary.Management;
using TestSuite.Model;
#pragma warning disable CS0618 // Type or member is obsolete

3
tools/TestSuite/TestSuite.ApiTests/GraphQLFixture.cs

@ -6,7 +6,6 @@
// ==========================================================================
using Squidex.ClientLibrary;
using Squidex.ClientLibrary.Management;
#pragma warning disable SA1507 // Code should not contain multiple blank lines in a row
@ -51,7 +50,7 @@ public sealed class GraphQLFixture : ContentFixture
return response.Id;
}
catch (SquidexManagementException ex)
catch (SquidexException ex)
{
if (ex.StatusCode != 400)
{

1
tools/TestSuite/TestSuite.ApiTests/GraphQLSubscriptionTests.cs

@ -10,7 +10,6 @@ using GraphQL;
using GraphQL.Client.Http;
using GraphQL.Client.Serializer.Newtonsoft;
using Squidex.ClientLibrary;
using Squidex.ClientLibrary.Management;
using TestSuite.Model;
namespace TestSuite.ApiTests;

1
tools/TestSuite/TestSuite.ApiTests/RuleEventsTests.cs

@ -6,7 +6,6 @@
// ==========================================================================
using Squidex.ClientLibrary;
using Squidex.ClientLibrary.Management;
using TestSuite.Fixtures;
#pragma warning disable SA1300 // Element should begin with upper-case letter

3
tools/TestSuite/TestSuite.ApiTests/RuleRunnerTests.cs

@ -6,7 +6,6 @@
// ==========================================================================
using Squidex.ClientLibrary;
using Squidex.ClientLibrary.Management;
using TestSuite.Fixtures;
using TestSuite.Model;
@ -201,7 +200,7 @@ public class RuleRunnerTests : IClassFixture<ClientFixture>, IClassFixture<Webho
Action = new ScriptRuleActionDto
{
Script = $@"
postJSON('{url}', {{ schemaName: event.schemaId.Name }})
postJSON('{url}', {{ schemaName: event.schemaId.Name }}, function () {{}})
"
},
Trigger = new ContentChangedRuleTriggerDto

2
tools/TestSuite/TestSuite.ApiTests/RuleTests.cs

@ -5,7 +5,7 @@
// All rights reserved. Licensed under the MIT license.
// ==========================================================================
using Squidex.ClientLibrary.Management;
using Squidex.ClientLibrary;
using TestSuite.Fixtures;
#pragma warning disable SA1300 // Element should begin with upper-case letter

4
tools/TestSuite/TestSuite.ApiTests/SchemaTests.cs

@ -5,7 +5,7 @@
// All rights reserved. Licensed under the MIT license.
// ==========================================================================
using Squidex.ClientLibrary.Management;
using Squidex.ClientLibrary;
using TestSuite.Fixtures;
#pragma warning disable CS0618 // Type or member is obsolete
@ -61,7 +61,7 @@ public class SchemaTests : IClassFixture<CreatedAppFixture>
// STEP 2: Create again and fail.
var ex = await Assert.ThrowsAnyAsync<SquidexManagementException>(() =>
var ex = await Assert.ThrowsAnyAsync<SquidexException>(() =>
{
return _.Client.Schemas.PostSchemaAsync(createRequest);
});

1
tools/TestSuite/TestSuite.ApiTests/SearchTests.cs

@ -6,7 +6,6 @@
// ==========================================================================
using Squidex.ClientLibrary;
using Squidex.ClientLibrary.Management;
using TestSuite.Model;
#pragma warning disable SA1300 // Element should begin with upper-case letter

2
tools/TestSuite/TestSuite.ApiTests/Verify/AnonymousTests.Should_create_app_with_anonymous_read_access.verified.txt

@ -3,7 +3,7 @@
Name: Guid_2,
Version: 2,
CanAccessContent: true,
_links: {
Links: {
assets: {
Method: GET
},

2
tools/TestSuite/TestSuite.ApiTests/Verify/AnonymousTests.Should_create_app_with_anonymous_write_access.verified.txt

@ -3,7 +3,7 @@
Name: Guid_2,
Version: 2,
CanAccessContent: true,
_links: {
Links: {
assets: {
Method: GET
},

2
tools/TestSuite/TestSuite.ApiTests/Verify/AppClientsTests.Should_create_client.verified.txt

@ -3,7 +3,7 @@
Name: Guid_1,
Role: Editor,
AllowAnonymous: false,
_links: {
Links: {
delete: {
Method: DELETE
},

4
tools/TestSuite/TestSuite.ApiTests/Verify/AppClientsTests.Should_delete_client.verified.txt

@ -5,7 +5,7 @@
Name: default,
Role: Owner,
AllowAnonymous: false,
_links: {
Links: {
delete: {
Method: DELETE
},
@ -15,7 +15,7 @@
}
}
],
_links: {
Links: {
create: {
Method: POST
},

6
tools/TestSuite/TestSuite.ApiTests/Verify/AppClientsTests.Should_update_client.verified.txt

@ -5,7 +5,7 @@
Name: default,
Role: Owner,
AllowAnonymous: false,
_links: {
Links: {
delete: {
Method: DELETE
},
@ -21,7 +21,7 @@
ApiCallsLimit: 100,
ApiTrafficLimit: 200,
AllowAnonymous: true,
_links: {
Links: {
delete: {
Method: DELETE
},
@ -31,7 +31,7 @@
}
}
],
_links: {
Links: {
create: {
Method: POST
},

2
tools/TestSuite/TestSuite.ApiTests/Verify/AppContributorsTests.Should_invite_contributor.verified.txt

@ -1,6 +1,6 @@
{
Role: Developer,
_links: {
Links: {
delete: {
Method: DELETE
},

2
tools/TestSuite/TestSuite.ApiTests/Verify/AppContributorsTests.Should_remove_contributor.verified.txt

@ -1,6 +1,6 @@
{
MaxContributors: -1,
_links: {
Links: {
create: {
Method: POST
},

2
tools/TestSuite/TestSuite.ApiTests/Verify/AppCreationTests.Should_create_app.verified.txt

@ -3,7 +3,7 @@
Name: Guid_2,
Version: 2,
CanAccessContent: true,
_links: {
Links: {
assets: {
Method: GET
},

18
tools/TestSuite/TestSuite.ApiTests/Verify/AppCreationTests.Should_create_app_from_templates.verified.txt

@ -47,7 +47,7 @@
IsRequiredOnPublish: false,
IsHalfWidth: false
},
_links: {
Links: {
delete: {
Method: DELETE
},
@ -84,7 +84,7 @@
IsRequiredOnPublish: false,
IsHalfWidth: false
},
_links: {
Links: {
delete: {
Method: DELETE
},
@ -120,7 +120,7 @@
IsRequiredOnPublish: false,
IsHalfWidth: false
},
_links: {
Links: {
delete: {
Method: DELETE
},
@ -139,7 +139,7 @@
}
}
],
_links: {
Links: {
contents: {
Method: GET
},
@ -234,7 +234,7 @@
IsRequiredOnPublish: false,
IsHalfWidth: false
},
_links: {
Links: {
delete: {
Method: DELETE
},
@ -271,7 +271,7 @@
IsRequiredOnPublish: false,
IsHalfWidth: false
},
_links: {
Links: {
delete: {
Method: DELETE
},
@ -307,7 +307,7 @@
IsRequiredOnPublish: false,
IsHalfWidth: false
},
_links: {
Links: {
delete: {
Method: DELETE
},
@ -326,7 +326,7 @@
}
}
],
_links: {
Links: {
contents: {
Method: GET
},
@ -375,7 +375,7 @@
}
}
],
_links: {
Links: {
create: {
Method: POST
},

6
tools/TestSuite/TestSuite.ApiTests/Verify/AppLanguagesTests.Should_add_custom_language.verified.txt

@ -11,7 +11,7 @@
EnglishName: ,
IsMaster: false,
IsOptional: false,
_links: {
Links: {
delete: {
Method: DELETE
},
@ -25,7 +25,7 @@
EnglishName: ,
IsMaster: false,
IsOptional: false,
_links: {
Links: {
delete: {
Method: DELETE
},
@ -35,7 +35,7 @@
}
}
],
_links: {
Links: {
create: {
Method: POST
},

6
tools/TestSuite/TestSuite.ApiTests/Verify/AppLanguagesTests.Should_add_language.verified.txt

@ -11,7 +11,7 @@
EnglishName: German,
IsMaster: false,
IsOptional: false,
_links: {
Links: {
delete: {
Method: DELETE
},
@ -25,7 +25,7 @@
EnglishName: Italian,
IsMaster: false,
IsOptional: false,
_links: {
Links: {
delete: {
Method: DELETE
},
@ -35,7 +35,7 @@
}
}
],
_links: {
Links: {
create: {
Method: POST
},

4
tools/TestSuite/TestSuite.ApiTests/Verify/AppLanguagesTests.Should_delete_language.verified.txt

@ -11,7 +11,7 @@
EnglishName: Italian,
IsMaster: false,
IsOptional: true,
_links: {
Links: {
delete: {
Method: DELETE
},
@ -21,7 +21,7 @@
}
}
],
_links: {
Links: {
create: {
Method: POST
},

6
tools/TestSuite/TestSuite.ApiTests/Verify/AppLanguagesTests.Should_update_language.verified.txt

@ -14,7 +14,7 @@
],
IsMaster: false,
IsOptional: true,
_links: {
Links: {
delete: {
Method: DELETE
},
@ -28,7 +28,7 @@
EnglishName: Italian,
IsMaster: false,
IsOptional: false,
_links: {
Links: {
delete: {
Method: DELETE
},
@ -38,7 +38,7 @@
}
}
],
_links: {
Links: {
create: {
Method: POST
},

6
tools/TestSuite/TestSuite.ApiTests/Verify/AppLanguagesTests.Should_update_master_language.verified.txt

@ -11,7 +11,7 @@
EnglishName: German,
IsMaster: false,
IsOptional: false,
_links: {
Links: {
delete: {
Method: DELETE
},
@ -25,7 +25,7 @@
EnglishName: English,
IsMaster: false,
IsOptional: false,
_links: {
Links: {
delete: {
Method: DELETE
},
@ -35,7 +35,7 @@
}
}
],
_links: {
Links: {
create: {
Method: POST
},

2
tools/TestSuite/TestSuite.ApiTests/Verify/AppRolesTests.Should_create_role.verified.txt

@ -1,6 +1,6 @@
{
IsDefaultRole: false,
_links: {
Links: {
delete: {
Method: DELETE
},

2
tools/TestSuite/TestSuite.ApiTests/Verify/AppRolesTests.Should_create_role_with_buggy_name.verified.txt

@ -1,6 +1,6 @@
{
IsDefaultRole: false,
_links: {
Links: {
delete: {
Method: DELETE
},

2
tools/TestSuite/TestSuite.ApiTests/Verify/AppRolesTests.Should_update_role.verified.txt

@ -4,7 +4,7 @@
a,
b
],
_links: {
Links: {
delete: {
Method: DELETE
},

2
tools/TestSuite/TestSuite.ApiTests/Verify/AppTests.Should_update_settings.verified.txt

@ -13,7 +13,7 @@
],
HideScheduler: false,
HideDateTimeModeButton: false,
_links: {
Links: {
self: {
Method: GET
},

2
tools/TestSuite/TestSuite.ApiTests/Verify/AppWorkflowsTests.Should_create_workflow.verified.txt

@ -30,7 +30,7 @@
}
},
Initial: Draft,
_links: {
Links: {
delete: {
Method: DELETE
},

2
tools/TestSuite/TestSuite.ApiTests/Verify/AppWorkflowsTests.Should_delete_workflow.verified.txt

@ -1,5 +1,5 @@
{
_links: {
Links: {
create: {
Method: POST
},

4
tools/TestSuite/TestSuite.ApiTests/Verify/AppWorkflowsTests.Should_update_workflow.verified.txt

@ -17,7 +17,7 @@
}
},
Initial: Draft,
_links: {
Links: {
delete: {
Method: DELETE
},
@ -27,7 +27,7 @@
}
}
],
_links: {
Links: {
create: {
Method: POST
},

2
tools/TestSuite/TestSuite.ApiTests/Verify/AssetFoldersTests.Should_create_folder.verified.txt

@ -2,7 +2,7 @@
Id: Guid_1,
ParentId: Guid_Empty,
FolderName: Guid_2,
_links: {
Links: {
delete: {
Method: DELETE
},

2
tools/TestSuite/TestSuite.ApiTests/Verify/AssetFoldersTests.Should_update_folder.verified.txt

@ -3,7 +3,7 @@
ParentId: Guid_Empty,
FolderName: Guid_2,
Version: 1,
_links: {
Links: {
delete: {
Method: DELETE
},

2
tools/TestSuite/TestSuite.ApiTests/Verify/AssetFormatTests.Should_fix_orientation.verified.txt

@ -21,7 +21,7 @@
],
FileSize: 15425,
Type: Image,
_links: {
Links: {
content: {
Method: GET
},

2
tools/TestSuite/TestSuite.ApiTests/Verify/AssetFormatTests.Should_upload_audio_mp3.verified.txt

@ -20,7 +20,7 @@
],
FileSize: 443926,
Type: Audio,
_links: {
Links: {
content: {
Method: GET
},

2
tools/TestSuite/TestSuite.ApiTests/Verify/AssetFormatTests.Should_upload_image_bmp_and_encode_to_webp.verified.txt

@ -19,7 +19,7 @@
],
FileSize: 720054,
Type: Image,
_links: {
Links: {
content: {
Method: GET
},

2
tools/TestSuite/TestSuite.ApiTests/Verify/AssetFormatTests.Should_upload_image_bmp_and_resize.verified.txt

@ -19,7 +19,7 @@
],
FileSize: 720054,
Type: Image,
_links: {
Links: {
content: {
Method: GET
},

2
tools/TestSuite/TestSuite.ApiTests/Verify/AssetFormatTests.Should_upload_image_gif_and_resize.verified.txt

@ -20,7 +20,7 @@
],
FileSize: 157934,
Type: Image,
_links: {
Links: {
content: {
Method: GET
},

2
tools/TestSuite/TestSuite.ApiTests/Verify/AssetFormatTests.Should_upload_image_gif_without_extension.verified.txt

@ -16,7 +16,7 @@
],
FileSize: 157934,
Type: Image,
_links: {
Links: {
content: {
Method: GET
},

2
tools/TestSuite/TestSuite.ApiTests/Verify/AssetFormatTests.Should_upload_image_jpg_and_resize.verified.txt

@ -21,7 +21,7 @@
],
FileSize: 63507,
Type: Image,
_links: {
Links: {
content: {
Method: GET
},

2
tools/TestSuite/TestSuite.ApiTests/Verify/AssetFormatTests.Should_upload_image_png_and_resize.verified.txt

@ -20,7 +20,7 @@
],
FileSize: 439244,
Type: Image,
_links: {
Links: {
content: {
Method: GET
},

2
tools/TestSuite/TestSuite.ApiTests/Verify/AssetFormatTests.Should_upload_image_tga_and_resize.verified.txt

@ -19,7 +19,7 @@
],
FileSize: 631995,
Type: Image,
_links: {
Links: {
content: {
Method: GET
},

2
tools/TestSuite/TestSuite.ApiTests/Verify/AssetFormatTests.Should_upload_image_tiff_and_resize.verified.txt

@ -20,7 +20,7 @@
],
FileSize: 485012,
Type: Image,
_links: {
Links: {
content: {
Method: GET
},

2
tools/TestSuite/TestSuite.ApiTests/Verify/AssetFormatTests.Should_upload_image_webp_and_resize.verified.txt

@ -19,7 +19,7 @@
],
FileSize: 112138,
Type: Image,
_links: {
Links: {
content: {
Method: GET
},

2
tools/TestSuite/TestSuite.ApiTests/Verify/AssetFormatTests.Should_upload_video_3gp.verified.txt

@ -12,7 +12,7 @@
type/3gp
],
FileSize: 1038741,
_links: {
Links: {
content: {
Method: GET
},

2
tools/TestSuite/TestSuite.ApiTests/Verify/AssetFormatTests.Should_upload_video_flv.verified.txt

@ -12,7 +12,7 @@
type/flv
],
FileSize: 1051185,
_links: {
Links: {
content: {
Method: GET
},

2
tools/TestSuite/TestSuite.ApiTests/Verify/AssetFormatTests.Should_upload_video_mkv.verified.txt

@ -12,7 +12,7 @@
type/flv
],
FileSize: 1051185,
_links: {
Links: {
content: {
Method: GET
},

2
tools/TestSuite/TestSuite.ApiTests/Verify/AssetFormatTests.Should_upload_video_mp4.verified.txt

@ -22,7 +22,7 @@
],
FileSize: 1055736,
Type: Video,
_links: {
Links: {
content: {
Method: GET
},

2
tools/TestSuite/TestSuite.ApiTests/Verify/AssetTests.Should_annotate_asset_in_parallel.verified.txt

@ -15,7 +15,7 @@
},
FileSize: 19430,
Type: Image,
_links: {
Links: {
content: {
Method: GET
},

2
tools/TestSuite/TestSuite.ApiTests/Verify/AssetTests.Should_annote_asset_file_name.verified.txt

@ -21,7 +21,7 @@
FileSize: 19430,
Type: Image,
Version: 1,
_links: {
Links: {
content: {
Method: GET
},

2
tools/TestSuite/TestSuite.ApiTests/Verify/AssetTests.Should_annote_asset_metadata.verified.txt

@ -20,7 +20,7 @@
FileSize: 19430,
Type: Image,
Version: 1,
_links: {
Links: {
content: {
Method: GET
},

2
tools/TestSuite/TestSuite.ApiTests/Verify/AssetTests.Should_annote_asset_slug.verified.txt

@ -21,7 +21,7 @@
FileSize: 19430,
Type: Image,
Version: 1,
_links: {
Links: {
content: {
Method: GET
},

2
tools/TestSuite/TestSuite.ApiTests/Verify/AssetTests.Should_annote_asset_tags.verified.txt

@ -20,7 +20,7 @@
FileSize: 19430,
Type: Image,
Version: 1,
_links: {
Links: {
content: {
Method: GET
},

2
tools/TestSuite/TestSuite.ApiTests/Verify/AssetTests.Should_protect_asset.verified.txt

@ -21,7 +21,7 @@
FileSize: 19430,
Type: Image,
Version: 1,
_links: {
Links: {
content: {
Method: GET
},

2
tools/TestSuite/TestSuite.ApiTests/Verify/AssetTests.Should_protect_asset_with_script.verified.txt

@ -20,7 +20,7 @@
],
FileSize: 19430,
Type: Image,
_links: {
Links: {
content: {
Method: GET
},

2
tools/TestSuite/TestSuite.ApiTests/Verify/AssetTests.Should_replace_asset.verified.txt

@ -22,7 +22,7 @@
FileVersion: 1,
Type: Image,
Version: 1,
_links: {
Links: {
content: {
Method: GET
},

2
tools/TestSuite/TestSuite.ApiTests/Verify/AssetTests.Should_upload_asset.verified.txt

@ -20,7 +20,7 @@
],
FileSize: 19430,
Type: Image,
_links: {
Links: {
content: {
Method: GET
},

2
tools/TestSuite/TestSuite.ApiTests/Verify/AssetTests.Should_upload_asset_with_custom_id.verified.txt

@ -20,7 +20,7 @@
],
FileSize: 19430,
Type: Image,
_links: {
Links: {
content: {
Method: GET
},

2
tools/TestSuite/TestSuite.ApiTests/Verify/RuleTests.Should_create_rule.verified.txt

@ -7,7 +7,7 @@
Action: {
Url: http://squidex.io
},
_links: {
Links: {
delete: {
Method: DELETE
},

2
tools/TestSuite/TestSuite.ApiTests/Verify/RuleTests.Should_update_rule.verified.txt

@ -9,7 +9,7 @@
Action: {
Url: http://squidex.io
},
_links: {
Links: {
delete: {
Method: DELETE
},

2
tools/TestSuite/TestSuite.ApiTests/Verify/SchemaTests.Should_create_singleton_schema.verified.txt

@ -6,7 +6,7 @@
},
IsPublished: true,
Scripts: {},
_links: {
Links: {
contents: {
Method: GET
},

2
tools/TestSuite/TestSuite.ApiTests/Verify/SchemaTests.Should_create_singleton_schema_with_obsolete_property.verified.txt

@ -6,7 +6,7 @@
},
IsPublished: true,
Scripts: {},
_links: {
Links: {
contents: {
Method: GET
},

5
tools/TestSuite/TestSuite.Shared/ClientExtensions.cs

@ -6,7 +6,6 @@
// ==========================================================================
using Squidex.ClientLibrary;
using Squidex.ClientLibrary.Management;
using TestSuite.Fixtures;
namespace TestSuite;
@ -25,7 +24,7 @@ public static class ClientExtensions
{
await assetsClient.GetAssetAsync(id, cts.Token);
}
catch (SquidexManagementException ex) when (ex.StatusCode == 404)
catch (SquidexException ex) when (ex.StatusCode == 404)
{
return true;
}
@ -198,7 +197,7 @@ public static class ClientExtensions
{
httpClient.BaseAddress = new Uri(fixture.Url);
var url = asset._links["content"].Href[1..];
var url = asset.Links["content"].Href[1..];
if (version > 0)
{

1
tools/TestSuite/TestSuite.Shared/Fixtures/ClientFixture.cs

@ -7,7 +7,6 @@
using Microsoft.Extensions.DependencyInjection;
using Squidex.ClientLibrary;
using Squidex.ClientLibrary.Management;
using Xunit;
namespace TestSuite.Fixtures;

6
tools/TestSuite/TestSuite.Shared/Fixtures/CreatedAppFixture.cs

@ -5,7 +5,7 @@
// All rights reserved. Licensed under the MIT license.
// ==========================================================================
using Squidex.ClientLibrary.Management;
using Squidex.ClientLibrary;
namespace TestSuite.Fixtures;
@ -26,7 +26,7 @@ public class CreatedAppFixture : ClientFixture
await Client.Apps.PostLanguageAsync(createRequest);
}
catch (SquidexManagementException ex)
catch (SquidexException ex)
{
if (ex.StatusCode != 400)
{
@ -44,7 +44,7 @@ public class CreatedAppFixture : ClientFixture
Name = AppName
});
}
catch (SquidexManagementException ex)
catch (SquidexException ex)
{
if (ex.StatusCode != 400)
{

3
tools/TestSuite/TestSuite.Shared/Fixtures/TestSchemaFixtureBase.cs

@ -6,7 +6,6 @@
// ==========================================================================
using Squidex.ClientLibrary;
using Squidex.ClientLibrary.Management;
using TestSuite.Model;
namespace TestSuite.Fixtures;
@ -32,7 +31,7 @@ public abstract class TestSchemaFixtureBase : CreatedAppFixture
{
await TestEntity.CreateSchemaAsync(Client.Schemas, SchemaName);
}
catch (SquidexManagementException ex)
catch (SquidexException ex)
{
if (ex.StatusCode != 400)
{

3
tools/TestSuite/TestSuite.Shared/Fixtures/TestSchemaWithReferencesFixtureBase.cs

@ -6,7 +6,6 @@
// ==========================================================================
using Squidex.ClientLibrary;
using Squidex.ClientLibrary.Management;
using TestSuite.Model;
namespace TestSuite.Fixtures;
@ -32,7 +31,7 @@ public abstract class TestSchemaWithReferencesFixtureBase : CreatedAppFixture
{
await TestEntityWithReferences.CreateSchemaAsync(Client.Schemas, SchemaName);
}
catch (SquidexManagementException ex)
catch (SquidexException ex)
{
if (ex.StatusCode != 400)
{

1
tools/TestSuite/TestSuite.Shared/Model/TestEntity.cs

@ -9,7 +9,6 @@ using System.Globalization;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Squidex.ClientLibrary;
using Squidex.ClientLibrary.Management;
#pragma warning disable MA0048 // File name must match type name

1
tools/TestSuite/TestSuite.Shared/Model/TestEntityWithReferences.cs

@ -7,7 +7,6 @@
using Newtonsoft.Json;
using Squidex.ClientLibrary;
using Squidex.ClientLibrary.Management;
#pragma warning disable MA0048 // File name must match type name

Some files were not shown because too many files changed in this diff

Loading…
Cancel
Save