Browse Source

Code analyzer fixes.

pull/768/head
Sebastian 4 years ago
parent
commit
b557469f95
  1. 1
      backend/src/Squidex.Domain.Apps.Core.Operations/Scripting/JintUser.cs
  2. 1
      backend/src/Squidex.Domain.Apps.Entities.MongoDb/Contents/MongoContentCollection.cs
  3. 1
      backend/src/Squidex.Domain.Apps.Entities.MongoDb/Contents/MongoContentRepository.cs
  4. 1
      backend/src/Squidex.Domain.Apps.Entities.MongoDb/Contents/Operations/QueryScheduled.cs
  5. 1
      backend/src/Squidex.Domain.Apps.Entities/Apps/Indexes/AppsIndex.cs
  6. 3
      backend/src/Squidex.Domain.Apps.Entities/Assets/DomainObject/Guards/ScriptMetadataWrapper.cs
  7. 4
      backend/src/Squidex.Domain.Apps.Entities/Backup/BackupGrain.cs
  8. 1
      backend/src/Squidex.Domain.Apps.Entities/Backup/BackupReader.cs
  9. 2
      backend/src/Squidex.Domain.Apps.Entities/Comments/CommentTriggerHandler.cs
  10. 1
      backend/src/Squidex.Domain.Apps.Entities/Contents/ContentSchedulerGrain.cs
  11. 2
      backend/src/Squidex.Domain.Apps.Entities/Contents/Queries/ContentEnricher.cs
  12. 1
      backend/src/Squidex.Domain.Apps.Entities/Contents/Repositories/IContentRepository.cs
  13. 1
      backend/src/Squidex.Domain.Apps.Entities/Schemas/Indexes/SchemasIndex.cs
  14. 2
      backend/src/Squidex.Web/Pipeline/SetupMiddleware.cs
  15. 4
      backend/src/Squidex/Areas/Api/Controllers/Backups/BackupsController.cs
  16. 2
      backend/src/Squidex/Areas/Api/Controllers/Backups/RestoreController.cs
  17. 16
      backend/src/Squidex/Areas/Api/Controllers/Users/UserManagementController.cs
  18. 6
      backend/src/Squidex/Areas/IdentityServer/Config/CreateAdminInitializer.cs
  19. 14
      backend/src/Squidex/Areas/IdentityServer/Controllers/Account/AccountController.cs
  20. 4
      backend/src/Squidex/Areas/IdentityServer/Controllers/Connect/ConnectController.cs
  21. 28
      backend/src/Squidex/Areas/IdentityServer/Controllers/Profile/ProfileController.cs
  22. 6
      backend/src/Squidex/Areas/IdentityServer/Controllers/Setup/SetupController.cs
  23. 2
      backend/src/Squidex/Areas/IdentityServer/Controllers/UserInfo/UserInfoController.cs
  24. 1
      backend/src/Squidex/Config/Domain/AppsServices.cs
  25. 2
      backend/tests/Squidex.Domain.Apps.Entities.Tests/Apps/DefaultAppLogStoreTests.cs
  26. 2
      backend/tests/Squidex.Domain.Apps.Entities.Tests/Apps/DomainObject/AppDomainObjectTests.cs
  27. 7
      backend/tests/Squidex.Domain.Apps.Entities.Tests/Assets/AssetsFluidExtensionTests.cs
  28. 6
      backend/tests/Squidex.Domain.Apps.Entities.Tests/Assets/AssetsJintExtensionTests.cs
  29. 1
      backend/tests/Squidex.Domain.Apps.Entities.Tests/Assets/BackupAssetsTests.cs
  30. 18
      backend/tests/Squidex.Domain.Apps.Entities.Tests/Assets/DefaultAssetFileStoreTests.cs
  31. 2
      backend/tests/Squidex.Domain.Apps.Entities.Tests/Assets/DomainObject/AssetDomainObjectTests.cs
  32. 2
      backend/tests/Squidex.Domain.Apps.Entities.Tests/Assets/DomainObject/AssetFolderDomainObjectTests.cs
  33. 4
      backend/tests/Squidex.Domain.Apps.Entities.Tests/Assets/MongoDb/AssetQueryTests.cs
  34. 7
      backend/tests/Squidex.Domain.Apps.Entities.Tests/Assets/MongoDb/AssetsQueryFixture.cs
  35. 15
      backend/tests/Squidex.Domain.Apps.Entities.Tests/Backup/BackupReaderWriterTests.cs
  36. 14
      backend/tests/Squidex.Domain.Apps.Entities.Tests/Comments/DomainObject/CommentsGrainTests.cs
  37. 1
      backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/ContentSchedulerGrainTests.cs
  38. 2
      backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/DomainObject/ContentDomainObjectTests.cs
  39. 15
      backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/GraphQL/GraphQLMutationTests.cs
  40. 27
      backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/GraphQL/GraphQLQueriesTests.cs
  41. 4
      backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/MongoDb/ContentQueryTests.cs
  42. 3
      backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/MongoDb/ContentsQueryFixture.cs
  43. 7
      backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/ReferencesFluidExtensionTests.cs
  44. 6
      backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/ReferencesJintExtensionTests.cs
  45. 2
      backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/Text/TextIndexerTests_Elastic.cs
  46. 2
      backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/Text/TextIndexerTests_Mongo.cs
  47. 2
      backend/tests/Squidex.Domain.Apps.Entities.Tests/Rules/DomainObject/RuleDomainObjectTests.cs
  48. 2
      backend/tests/Squidex.Domain.Apps.Entities.Tests/Schemas/DomainObject/SchemaDomainObjectTests.cs
  49. 4
      backend/tests/Squidex.Domain.Apps.Entities.Tests/Schemas/Indexes/SchemasIndexTests.cs
  50. 5
      backend/tests/Squidex.Domain.Apps.Entities.Tests/Squidex.Domain.Apps.Entities.Tests.csproj
  51. 2
      backend/tests/Squidex.Domain.Apps.Entities.Tests/TestHelpers/AExtensions.cs
  52. 4
      backend/tests/Squidex.Domain.Apps.Entities.Tests/TestHelpers/HandlerTestBase.cs
  53. 2
      backend/tests/Squidex.Infrastructure.Tests/Reflection/SimpleMapperTests.cs

1
backend/src/Squidex.Domain.Apps.Core.Operations/Scripting/JintUser.cs

@ -10,7 +10,6 @@ using System.Linq;
using System.Security.Claims; using System.Security.Claims;
using Jint; using Jint;
using Jint.Native; using Jint.Native;
using Jint.Runtime.Interop;
using Squidex.Infrastructure; using Squidex.Infrastructure;
using Squidex.Infrastructure.Security; using Squidex.Infrastructure.Security;
using Squidex.Shared.Identity; using Squidex.Shared.Identity;

1
backend/src/Squidex.Domain.Apps.Entities.MongoDb/Contents/MongoContentCollection.cs

@ -5,7 +5,6 @@
// All rights reserved. Licensed under the MIT license. // All rights reserved. Licensed under the MIT license.
// ========================================================================== // ==========================================================================
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Threading; using System.Threading;

1
backend/src/Squidex.Domain.Apps.Entities.MongoDb/Contents/MongoContentRepository.cs

@ -5,7 +5,6 @@
// All rights reserved. Licensed under the MIT license. // All rights reserved. Licensed under the MIT license.
// ========================================================================== // ==========================================================================
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;

1
backend/src/Squidex.Domain.Apps.Entities.MongoDb/Contents/Operations/QueryScheduled.cs

@ -5,7 +5,6 @@
// All rights reserved. Licensed under the MIT license. // All rights reserved. Licensed under the MIT license.
// ========================================================================== // ==========================================================================
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Threading; using System.Threading;

1
backend/src/Squidex.Domain.Apps.Entities/Apps/Indexes/AppsIndex.cs

@ -22,7 +22,6 @@ using Squidex.Infrastructure.Security;
using Squidex.Infrastructure.Translations; using Squidex.Infrastructure.Translations;
using Squidex.Infrastructure.Validation; using Squidex.Infrastructure.Validation;
using Squidex.Shared; using Squidex.Shared;
using Squidex.Text;
namespace Squidex.Domain.Apps.Entities.Apps.Indexes namespace Squidex.Domain.Apps.Entities.Apps.Indexes
{ {

3
backend/src/Squidex.Domain.Apps.Entities/Assets/DomainObject/Guards/ScriptMetadataWrapper.cs

@ -5,7 +5,6 @@
// All rights reserved. Licensed under the MIT license. // All rights reserved. Licensed under the MIT license.
// ========================================================================== // ==========================================================================
using System;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis; using System.Diagnostics.CodeAnalysis;
@ -31,7 +30,7 @@ namespace Squidex.Domain.Apps.Entities.Assets.DomainObject.Guards
public ICollection<object?> Values public ICollection<object?> Values
{ {
get => metadata.Values.Select(x => (object?)x).ToList(); get => metadata.Values.Cast<object?>().ToList();
} }
public object? this[string key] public object? this[string key]

4
backend/src/Squidex.Domain.Apps.Entities/Backup/BackupGrain.cs

@ -166,7 +166,7 @@ namespace Squidex.Domain.Apps.Entities.Backup
await handler.BackupEventAsync(@event, context, ct); await handler.BackupEventAsync(@event, context, ct);
} }
writer.WriteEvent(storedEvent); writer.WriteEvent(storedEvent, ct);
job.HandledEvents = writer.WrittenEvents; job.HandledEvents = writer.WrittenEvents;
job.HandledAssets = writer.WrittenAttachments; job.HandledAssets = writer.WrittenAttachments;
@ -188,7 +188,7 @@ namespace Squidex.Domain.Apps.Entities.Backup
await handler.CompleteBackupAsync(context); await handler.CompleteBackupAsync(context);
} }
await userMapping.StoreAsync(writer, userResolver); await userMapping.StoreAsync(writer, userResolver, ct);
} }
stream.Position = 0; stream.Position = 0;

1
backend/src/Squidex.Domain.Apps.Entities/Backup/BackupReader.cs

@ -5,7 +5,6 @@
// All rights reserved. Licensed under the MIT license. // All rights reserved. Licensed under the MIT license.
// ========================================================================== // ==========================================================================
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.IO.Compression; using System.IO.Compression;

2
backend/src/Squidex.Domain.Apps.Entities/Comments/CommentTriggerHandler.cs

@ -47,7 +47,7 @@ namespace Squidex.Domain.Apps.Entities.Comments
if (commentCreated.Mentions?.Length > 0) if (commentCreated.Mentions?.Length > 0)
{ {
var users = await userResolver.QueryManyAsync(commentCreated.Mentions); var users = await userResolver.QueryManyAsync(commentCreated.Mentions, ct);
if (users.Count > 0) if (users.Count > 0)
{ {

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

@ -6,7 +6,6 @@
// ========================================================================== // ==========================================================================
using System; using System;
using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using NodaTime; using NodaTime;
using Orleans; using Orleans;

2
backend/src/Squidex.Domain.Apps.Entities/Contents/Queries/ContentEnricher.cs

@ -91,7 +91,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.Queries
throw new DomainObjectNotFoundException(x.ToString()); throw new DomainObjectNotFoundException(x.ToString());
} }
var components = await appProvider.GetComponentsAsync(schema); var components = await appProvider.GetComponentsAsync(schema, ct);
return (schema, components); return (schema, components);
}); });

1
backend/src/Squidex.Domain.Apps.Entities/Contents/Repositories/IContentRepository.cs

@ -5,7 +5,6 @@
// All rights reserved. Licensed under the MIT license. // All rights reserved. Licensed under the MIT license.
// ========================================================================== // ==========================================================================
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;

1
backend/src/Squidex.Domain.Apps.Entities/Schemas/Indexes/SchemasIndex.cs

@ -18,7 +18,6 @@ using Squidex.Infrastructure;
using Squidex.Infrastructure.Commands; using Squidex.Infrastructure.Commands;
using Squidex.Infrastructure.Translations; using Squidex.Infrastructure.Translations;
using Squidex.Infrastructure.Validation; using Squidex.Infrastructure.Validation;
using Squidex.Text;
namespace Squidex.Domain.Apps.Entities.Schemas.Indexes namespace Squidex.Domain.Apps.Entities.Schemas.Indexes
{ {

2
backend/src/Squidex.Web/Pipeline/SetupMiddleware.cs

@ -23,7 +23,7 @@ namespace Squidex.Web.Pipeline
public async Task InvokeAsync(HttpContext context, IUserService userService) public async Task InvokeAsync(HttpContext context, IUserService userService)
{ {
if (!isUserFound && await userService.IsEmptyAsync()) if (!isUserFound && await userService.IsEmptyAsync(context.RequestAborted))
{ {
var url = context.Request.PathBase.Add("/identity-server/setup"); var url = context.Request.PathBase.Add("/identity-server/setup");

4
backend/src/Squidex/Areas/Api/Controllers/Backups/BackupsController.cs

@ -49,7 +49,7 @@ namespace Squidex.Areas.Api.Controllers.Backups
[ApiCosts(0)] [ApiCosts(0)]
public async Task<IActionResult> GetBackups(string app) public async Task<IActionResult> GetBackups(string app)
{ {
var jobs = await backupService.GetBackupsAsync(AppId); var jobs = await backupService.GetBackupsAsync(AppId, HttpContext.RequestAborted);
var response = BackupJobsDto.FromBackups(jobs, Resources); var response = BackupJobsDto.FromBackups(jobs, Resources);
@ -93,7 +93,7 @@ namespace Squidex.Areas.Api.Controllers.Backups
[ApiCosts(0)] [ApiCosts(0)]
public async Task<IActionResult> DeleteBackup(string app, DomainId id) public async Task<IActionResult> DeleteBackup(string app, DomainId id)
{ {
await backupService.DeleteBackupAsync(AppId, id); await backupService.DeleteBackupAsync(AppId, id, HttpContext.RequestAborted);
return NoContent(); return NoContent();
} }

2
backend/src/Squidex/Areas/Api/Controllers/Backups/RestoreController.cs

@ -44,7 +44,7 @@ namespace Squidex.Areas.Api.Controllers.Backups
[ApiPermission(Permissions.AdminRestore)] [ApiPermission(Permissions.AdminRestore)]
public async Task<IActionResult> GetRestoreJob() public async Task<IActionResult> GetRestoreJob()
{ {
var job = await backupService.GetRestoreAsync(); var job = await backupService.GetRestoreAsync(HttpContext.RequestAborted);
if (job == null) if (job == null)
{ {

16
backend/src/Squidex/Areas/Api/Controllers/Users/UserManagementController.cs

@ -1,4 +1,4 @@
// ========================================================================== // ==========================================================================
// Squidex Headless CMS // Squidex Headless CMS
// ========================================================================== // ==========================================================================
// Copyright (c) Squidex UG (haftungsbeschraenkt) // Copyright (c) Squidex UG (haftungsbeschraenkt)
@ -35,7 +35,7 @@ namespace Squidex.Areas.Api.Controllers.Users
[ApiPermission(Permissions.AdminUsersRead)] [ApiPermission(Permissions.AdminUsersRead)]
public async Task<IActionResult> GetUsers([FromQuery] string? query = null, [FromQuery] int skip = 0, [FromQuery] int take = 10) public async Task<IActionResult> GetUsers([FromQuery] string? query = null, [FromQuery] int skip = 0, [FromQuery] int take = 10)
{ {
var users = await userService.QueryAsync(query, take, skip); var users = await userService.QueryAsync(query, take, skip, HttpContext.RequestAborted);
var response = UsersDto.FromResults(users, users.Total, Resources); var response = UsersDto.FromResults(users, users.Total, Resources);
@ -48,7 +48,7 @@ namespace Squidex.Areas.Api.Controllers.Users
[ApiPermission(Permissions.AdminUsersRead)] [ApiPermission(Permissions.AdminUsersRead)]
public async Task<IActionResult> GetUser(string id) public async Task<IActionResult> GetUser(string id)
{ {
var user = await userService.FindByIdAsync(id); var user = await userService.FindByIdAsync(id, HttpContext.RequestAborted);
if (user == null) if (user == null)
{ {
@ -66,7 +66,7 @@ namespace Squidex.Areas.Api.Controllers.Users
[ApiPermission(Permissions.AdminUsersCreate)] [ApiPermission(Permissions.AdminUsersCreate)]
public async Task<IActionResult> PostUser([FromBody] CreateUserDto request) public async Task<IActionResult> PostUser([FromBody] CreateUserDto request)
{ {
var user = await userService.CreateAsync(request.Email, request.ToValues()); var user = await userService.CreateAsync(request.Email, request.ToValues(), ct: HttpContext.RequestAborted);
var response = UserDto.FromUser(user, Resources); var response = UserDto.FromUser(user, Resources);
@ -79,7 +79,7 @@ namespace Squidex.Areas.Api.Controllers.Users
[ApiPermission(Permissions.AdminUsersUpdate)] [ApiPermission(Permissions.AdminUsersUpdate)]
public async Task<IActionResult> PutUser(string id, [FromBody] UpdateUserDto request) public async Task<IActionResult> PutUser(string id, [FromBody] UpdateUserDto request)
{ {
var user = await userService.UpdateAsync(id, request.ToValues()); var user = await userService.UpdateAsync(id, request.ToValues(), ct: HttpContext.RequestAborted);
var response = UserDto.FromUser(user, Resources); var response = UserDto.FromUser(user, Resources);
@ -97,7 +97,7 @@ namespace Squidex.Areas.Api.Controllers.Users
throw new DomainForbiddenException(T.Get("users.lockYourselfError")); throw new DomainForbiddenException(T.Get("users.lockYourselfError"));
} }
var user = await userService.LockAsync(id); var user = await userService.LockAsync(id, HttpContext.RequestAborted);
var response = UserDto.FromUser(user, Resources); var response = UserDto.FromUser(user, Resources);
@ -115,7 +115,7 @@ namespace Squidex.Areas.Api.Controllers.Users
throw new DomainForbiddenException(T.Get("users.unlockYourselfError")); throw new DomainForbiddenException(T.Get("users.unlockYourselfError"));
} }
var user = await userService.UnlockAsync(id); var user = await userService.UnlockAsync(id, HttpContext.RequestAborted);
var response = UserDto.FromUser(user, Resources); var response = UserDto.FromUser(user, Resources);
@ -133,7 +133,7 @@ namespace Squidex.Areas.Api.Controllers.Users
throw new DomainForbiddenException(T.Get("users.deleteYourselfError")); throw new DomainForbiddenException(T.Get("users.deleteYourselfError"));
} }
await userService.DeleteAsync(id); await userService.DeleteAsync(id, HttpContext.RequestAborted);
return NoContent(); return NoContent();
} }

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

@ -56,7 +56,7 @@ namespace Squidex.Areas.IdentityServer.Config
{ {
try try
{ {
var user = await userService.FindByEmailAsync(adminEmail); var user = await userService.FindByEmailAsync(adminEmail, ct);
if (user != null) if (user != null)
{ {
@ -70,7 +70,7 @@ namespace Squidex.Areas.IdentityServer.Config
Permissions = permissions Permissions = permissions
}; };
await userService.UpdateAsync(user.Id, values); await userService.UpdateAsync(user.Id, values, ct: ct);
} }
} }
else else
@ -84,7 +84,7 @@ namespace Squidex.Areas.IdentityServer.Config
DisplayName = adminEmail DisplayName = adminEmail
}; };
await userService.CreateAsync(adminEmail, values); await userService.CreateAsync(adminEmail, values, ct: ct);
} }
} }
catch (Exception ex) catch (Exception ex)

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

@ -98,7 +98,7 @@ namespace Squidex.Areas.IdentityServer.Controllers.Account
return View(vm); return View(vm);
} }
var user = await userService.GetAsync(User); var user = await userService.GetAsync(User, HttpContext.RequestAborted);
if (user == null) if (user == null)
{ {
@ -111,7 +111,7 @@ namespace Squidex.Areas.IdentityServer.Controllers.Account
ConsentForEmails = model.ConsentToAutomatedEmails ConsentForEmails = model.ConsentToAutomatedEmails
}; };
await userService.UpdateAsync(user.Id, update); await userService.UpdateAsync(user.Id, update, ct: HttpContext.RequestAborted);
return RedirectToReturnUrl(returnUrl); return RedirectToReturnUrl(returnUrl);
} }
@ -238,7 +238,7 @@ namespace Squidex.Areas.IdentityServer.Controllers.Account
if (isLoggedIn) if (isLoggedIn)
{ {
user = await userService.FindByLoginAsync(externalLogin.LoginProvider, externalLogin.ProviderKey); user = await userService.FindByLoginAsync(externalLogin.LoginProvider, externalLogin.ProviderKey, HttpContext.RequestAborted);
} }
else else
{ {
@ -249,22 +249,22 @@ namespace Squidex.Areas.IdentityServer.Controllers.Account
throw new DomainException("User has no exposed email address."); throw new DomainException("User has no exposed email address.");
} }
user = await userService.FindByEmailAsync(email); user = await userService.FindByEmailAsync(email, HttpContext.RequestAborted);
if (user != null) if (user != null)
{ {
var update = CreateUserValues(externalLogin, email, user); var update = CreateUserValues(externalLogin, email, user);
await userService.UpdateAsync(user.Id, update); await userService.UpdateAsync(user.Id, update, ct: HttpContext.RequestAborted);
} }
else else
{ {
var update = CreateUserValues(externalLogin, email); var update = CreateUserValues(externalLogin, email);
user = await userService.CreateAsync(email, update, identityOptions.LockAutomatically); user = await userService.CreateAsync(email, update, identityOptions.LockAutomatically, HttpContext.RequestAborted);
} }
await userService.AddLoginAsync(user.Id, externalLogin); await userService.AddLoginAsync(user.Id, externalLogin, HttpContext.RequestAborted);
var (success, locked) = await LoginAsync(externalLogin); var (success, locked) = await LoginAsync(externalLogin);

4
backend/src/Squidex/Areas/IdentityServer/Controllers/Connect/ConnectController.cs

@ -63,7 +63,7 @@ namespace Notifo.Areas.Account.Controllers
throw new InvalidOperationException("The user details cannot be retrieved."); throw new InvalidOperationException("The user details cannot be retrieved.");
} }
var user = await userService.GetAsync(principal); var user = await userService.GetAsync(principal, HttpContext.RequestAborted);
if (user == null) if (user == null)
{ {
@ -153,7 +153,7 @@ namespace Notifo.Areas.Account.Controllers
}); });
} }
var user = await userService.GetAsync(User); var user = await userService.GetAsync(User, HttpContext.RequestAborted);
if (user == null) if (user == null)
{ {

28
backend/src/Squidex/Areas/IdentityServer/Controllers/Profile/ProfileController.cs

@ -1,4 +1,4 @@
// ========================================================================== // ==========================================================================
// Squidex Headless CMS // Squidex Headless CMS
// ========================================================================== // ==========================================================================
// Copyright (c) Squidex UG (haftungsbeschraenkt) // Copyright (c) Squidex UG (haftungsbeschraenkt)
@ -54,7 +54,7 @@ namespace Squidex.Areas.IdentityServer.Controllers.Profile
[Route("/account/profile/")] [Route("/account/profile/")]
public async Task<IActionResult> Profile(string? successMessage = null) public async Task<IActionResult> Profile(string? successMessage = null)
{ {
var user = await userService.GetAsync(User); var user = await userService.GetAsync(User, HttpContext.RequestAborted);
return View(await GetVM<None>(user, successMessage: successMessage)); return View(await GetVM<None>(user, successMessage: successMessage));
} }
@ -67,7 +67,7 @@ namespace Squidex.Areas.IdentityServer.Controllers.Profile
var properties = var properties =
SignInManager.ConfigureExternalAuthenticationProperties(provider, SignInManager.ConfigureExternalAuthenticationProperties(provider,
Url.Action(nameof(AddLoginCallback)), userService.GetUserId(User)); Url.Action(nameof(AddLoginCallback)), userService.GetUserId(User, HttpContext.RequestAborted));
return Challenge(properties, provider); return Challenge(properties, provider);
} }
@ -84,7 +84,7 @@ namespace Squidex.Areas.IdentityServer.Controllers.Profile
[Route("/account/profile/update/")] [Route("/account/profile/update/")]
public Task<IActionResult> UpdateProfile(ChangeProfileModel model) public Task<IActionResult> UpdateProfile(ChangeProfileModel model)
{ {
return MakeChangeAsync(id => userService.UpdateAsync(id, model.ToValues()), return MakeChangeAsync(id => userService.UpdateAsync(id, model.ToValues(), ct: HttpContext.RequestAborted),
T.Get("users.profile.updateProfileDone"), model); T.Get("users.profile.updateProfileDone"), model);
} }
@ -92,7 +92,7 @@ namespace Squidex.Areas.IdentityServer.Controllers.Profile
[Route("/account/profile/properties/")] [Route("/account/profile/properties/")]
public Task<IActionResult> UpdateProperties(ChangePropertiesModel model) public Task<IActionResult> UpdateProperties(ChangePropertiesModel model)
{ {
return MakeChangeAsync(id => userService.UpdateAsync(id, model.ToValues()), return MakeChangeAsync(id => userService.UpdateAsync(id, model.ToValues(), ct: HttpContext.RequestAborted),
T.Get("users.profile.updatePropertiesDone"), model); T.Get("users.profile.updatePropertiesDone"), model);
} }
@ -100,7 +100,7 @@ namespace Squidex.Areas.IdentityServer.Controllers.Profile
[Route("/account/profile/login-remove/")] [Route("/account/profile/login-remove/")]
public Task<IActionResult> RemoveLogin(RemoveLoginModel model) public Task<IActionResult> RemoveLogin(RemoveLoginModel model)
{ {
return MakeChangeAsync(id => userService.RemoveLoginAsync(id, model.LoginProvider, model.ProviderKey), return MakeChangeAsync(id => userService.RemoveLoginAsync(id, model.LoginProvider, model.ProviderKey, HttpContext.RequestAborted),
T.Get("users.profile.removeLoginDone"), model); T.Get("users.profile.removeLoginDone"), model);
} }
@ -108,7 +108,7 @@ namespace Squidex.Areas.IdentityServer.Controllers.Profile
[Route("/account/profile/password-set/")] [Route("/account/profile/password-set/")]
public Task<IActionResult> SetPassword(SetPasswordModel model) public Task<IActionResult> SetPassword(SetPasswordModel model)
{ {
return MakeChangeAsync(id => userService.SetPasswordAsync(id, model.Password), return MakeChangeAsync(id => userService.SetPasswordAsync(id, model.Password, ct: HttpContext.RequestAborted),
T.Get("users.profile.setPasswordDone"), model); T.Get("users.profile.setPasswordDone"), model);
} }
@ -116,7 +116,7 @@ namespace Squidex.Areas.IdentityServer.Controllers.Profile
[Route("/account/profile/password-change/")] [Route("/account/profile/password-change/")]
public Task<IActionResult> ChangePassword(ChangePasswordModel model) public Task<IActionResult> ChangePassword(ChangePasswordModel model)
{ {
return MakeChangeAsync(id => userService.SetPasswordAsync(id, model.Password, model.OldPassword), return MakeChangeAsync(id => userService.SetPasswordAsync(id, model.Password, model.OldPassword, HttpContext.RequestAborted),
T.Get("users.profile.changePasswordDone"), model); T.Get("users.profile.changePasswordDone"), model);
} }
@ -140,14 +140,14 @@ namespace Squidex.Areas.IdentityServer.Controllers.Profile
{ {
var update = new UserValues { ClientSecret = RandomHash.New() }; var update = new UserValues { ClientSecret = RandomHash.New() };
await userService.UpdateAsync(id, update); await userService.UpdateAsync(id, update, ct: HttpContext.RequestAborted);
} }
private async Task AddLoginAsync(string id) private async Task AddLoginAsync(string id)
{ {
var externalLogin = await SignInManager.GetExternalLoginInfoWithDisplayNameAsync(id); var externalLogin = await SignInManager.GetExternalLoginInfoWithDisplayNameAsync(id);
await userService.AddLoginAsync(id, externalLogin); await userService.AddLoginAsync(id, externalLogin, HttpContext.RequestAborted);
} }
private async Task UpdatePictureAsync(List<IFormFile> file, string id) private async Task UpdatePictureAsync(List<IFormFile> file, string id)
@ -175,12 +175,12 @@ namespace Squidex.Areas.IdentityServer.Controllers.Profile
var update = new UserValues { PictureUrl = SquidexClaimTypes.PictureUrlStore }; var update = new UserValues { PictureUrl = SquidexClaimTypes.PictureUrlStore };
await userService.UpdateAsync(id, update); await userService.UpdateAsync(id, update, ct: HttpContext.RequestAborted);
} }
private async Task<IActionResult> MakeChangeAsync<TModel>(Func<string, Task> action, string successMessage, TModel? model = null) where TModel : class private async Task<IActionResult> MakeChangeAsync<TModel>(Func<string, Task> action, string successMessage, TModel? model = null) where TModel : class
{ {
var user = await userService.GetAsync(User); var user = await userService.GetAsync(User, HttpContext.RequestAborted);
if (user == null) if (user == null)
{ {
@ -222,8 +222,8 @@ namespace Squidex.Areas.IdentityServer.Controllers.Profile
var (providers, hasPassword, logins) = await AsyncHelper.WhenAll( var (providers, hasPassword, logins) = await AsyncHelper.WhenAll(
SignInManager.GetExternalProvidersAsync(), SignInManager.GetExternalProvidersAsync(),
userService.HasPasswordAsync(user), userService.HasPasswordAsync(user, HttpContext.RequestAborted),
userService.GetLoginsAsync(user)); userService.GetLoginsAsync(user, HttpContext.RequestAborted));
var vm = new ProfileVM var vm = new ProfileVM
{ {

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

@ -50,7 +50,7 @@ namespace Squidex.Areas.IdentityServer.Controllers.Setup
[Route("setup/")] [Route("setup/")]
public async Task<IActionResult> Setup() public async Task<IActionResult> Setup()
{ {
if (!await userService.IsEmptyAsync()) if (!await userService.IsEmptyAsync(HttpContext.RequestAborted))
{ {
return RedirectToReturnUrl(null); return RedirectToReturnUrl(null);
} }
@ -62,7 +62,7 @@ namespace Squidex.Areas.IdentityServer.Controllers.Setup
[Route("setup/")] [Route("setup/")]
public async Task<IActionResult> Setup(CreateUserModel model) public async Task<IActionResult> Setup(CreateUserModel model)
{ {
if (!await userService.IsEmptyAsync()) if (!await userService.IsEmptyAsync(HttpContext.RequestAborted))
{ {
return RedirectToReturnUrl(null); return RedirectToReturnUrl(null);
} }
@ -78,7 +78,7 @@ namespace Squidex.Areas.IdentityServer.Controllers.Setup
var user = await userService.CreateAsync(model.Email, new UserValues var user = await userService.CreateAsync(model.Email, new UserValues
{ {
Password = model.Password Password = model.Password
}); }, ct: HttpContext.RequestAborted);
await SignInManager.SignInAsync((IdentityUser)user.Identity, true); await SignInManager.SignInAsync((IdentityUser)user.Identity, true);

2
backend/src/Squidex/Areas/IdentityServer/Controllers/UserInfo/UserInfoController.cs

@ -33,7 +33,7 @@ namespace Squidex.Areas.IdentityServer.Controllers.UserInfo
[Produces("application/json")] [Produces("application/json")]
public async Task<IActionResult> UserInfo() public async Task<IActionResult> UserInfo()
{ {
var user = await userService.GetAsync(User); var user = await userService.GetAsync(User, HttpContext.RequestAborted);
if (user == null) if (user == null)
{ {

1
backend/src/Squidex/Config/Domain/AppsServices.cs

@ -14,7 +14,6 @@ using Squidex.Domain.Apps.Core.Apps;
using Squidex.Domain.Apps.Entities; using Squidex.Domain.Apps.Entities;
using Squidex.Domain.Apps.Entities.Apps; using Squidex.Domain.Apps.Entities.Apps;
using Squidex.Domain.Apps.Entities.Apps.DomainObject; using Squidex.Domain.Apps.Entities.Apps.DomainObject;
using Squidex.Domain.Apps.Entities.Assets;
using Squidex.Domain.Apps.Entities.History; using Squidex.Domain.Apps.Entities.History;
using Squidex.Domain.Apps.Entities.Search; using Squidex.Domain.Apps.Entities.Search;
using Squidex.Infrastructure.Collections; using Squidex.Infrastructure.Collections;

2
backend/tests/Squidex.Domain.Apps.Entities.Tests/Apps/DefaultAppLogStoreTests.cs

@ -101,7 +101,7 @@ namespace Squidex.Domain.Apps.Entities.Apps
Contains(request.CacheServer, recordedRequest); Contains(request.CacheServer, recordedRequest);
Contains(request.CacheStatus, recordedRequest); Contains(request.CacheStatus, recordedRequest);
Contains(request.CacheTTL, recordedRequest); Contains(request.CacheTTL, recordedRequest);
Contains(request.ElapsedMs.ToString(), recordedRequest); Contains(request.ElapsedMs.ToString(CultureInfo.InvariantCulture), recordedRequest);
Contains(request.RequestMethod, recordedRequest); Contains(request.RequestMethod, recordedRequest);
Contains(request.RequestPath, recordedRequest); Contains(request.RequestPath, recordedRequest);
Contains(request.StatusCode, recordedRequest); Contains(request.StatusCode, recordedRequest);

2
backend/tests/Squidex.Domain.Apps.Entities.Tests/Apps/DomainObject/AppDomainObjectTests.cs

@ -70,7 +70,9 @@ namespace Squidex.Domain.Apps.Entities.Apps.DomainObject
}; };
sut = new AppDomainObject(PersistenceFactory, A.Dummy<ISemanticLog>(), initialSettings, appPlansProvider, appPlansBillingManager, userResolver); sut = new AppDomainObject(PersistenceFactory, A.Dummy<ISemanticLog>(), initialSettings, appPlansProvider, appPlansBillingManager, userResolver);
#pragma warning disable MA0056 // Do not call overridable members in constructor
sut.Setup(Id); sut.Setup(Id);
#pragma warning restore MA0056 // Do not call overridable members in constructor
} }
[Fact] [Fact]

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

@ -5,6 +5,7 @@
// All rights reserved. Licensed under the MIT license. // All rights reserved. Licensed under the MIT license.
// ========================================================================== // ==========================================================================
using System;
using System.IO; using System.IO;
using System.Text; using System.Text;
using System.Threading; using System.Threading;
@ -368,9 +369,9 @@ namespace Squidex.Domain.Apps.Entities.Assets
private static string Cleanup(string text) private static string Cleanup(string text)
{ {
return text return text
.Replace("\r", string.Empty) .Replace("\r", string.Empty, StringComparison.Ordinal)
.Replace("\n", string.Empty) .Replace("\n", string.Empty, StringComparison.Ordinal)
.Replace(" ", string.Empty); .Replace(" ", string.Empty, StringComparison.Ordinal);
} }
} }
} }

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

@ -406,9 +406,9 @@ namespace Squidex.Domain.Apps.Entities.Assets
private static string Cleanup(string text) private static string Cleanup(string text)
{ {
return text return text
.Replace("\r", string.Empty) .Replace("\r", string.Empty, StringComparison.Ordinal)
.Replace("\n", string.Empty) .Replace("\n", string.Empty, StringComparison.Ordinal)
.Replace(" ", string.Empty); .Replace(" ", string.Empty, StringComparison.Ordinal);
} }
} }
} }

1
backend/tests/Squidex.Domain.Apps.Entities.Tests/Assets/BackupAssetsTests.cs

@ -5,7 +5,6 @@
// All rights reserved. Licensed under the MIT license. // All rights reserved. Licensed under the MIT license.
// ========================================================================== // ==========================================================================
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Threading; using System.Threading;

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

@ -5,7 +5,9 @@
// All rights reserved. Licensed under the MIT license. // All rights reserved. Licensed under the MIT license.
// ========================================================================== // ==========================================================================
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Globalization;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Threading; using System.Threading;
@ -81,10 +83,10 @@ namespace Squidex.Domain.Apps.Entities.Assets
var size = 1024L; var size = 1024L;
A.CallTo(() => assetStore.GetSizeAsync(fullName, default)) A.CallTo(() => assetStore.GetSizeAsync(fullName, ct))
.Returns(size); .Returns(size);
var result = await sut.GetFileSizeAsync(appId, assetId, assetFileVersion, suffix); var result = await sut.GetFileSizeAsync(appId, assetId, assetFileVersion, suffix, ct);
Assert.Equal(size, result); Assert.Equal(size, result);
} }
@ -97,13 +99,13 @@ namespace Squidex.Domain.Apps.Entities.Assets
var size = 1024L; var size = 1024L;
A.CallTo(() => assetStore.GetSizeAsync(A<string>._, default)) A.CallTo(() => assetStore.GetSizeAsync(A<string>._, ct))
.Throws(new AssetNotFoundException(assetId.ToString())); .Throws(new AssetNotFoundException(assetId.ToString()));
A.CallTo(() => assetStore.GetSizeAsync(fullName, default)) A.CallTo(() => assetStore.GetSizeAsync(fullName, ct))
.Returns(size); .Returns(size);
var result = await sut.GetFileSizeAsync(appId, assetId, assetFileVersion, suffix); var result = await sut.GetFileSizeAsync(appId, assetId, assetFileVersion, suffix, ct);
Assert.Equal(size, result); Assert.Equal(size, result);
} }
@ -272,9 +274,9 @@ namespace Squidex.Domain.Apps.Entities.Assets
private string GetFullName(string fileName) private string GetFullName(string fileName)
{ {
return fileName return fileName
.Replace("{appId}", appId.ToString()) .Replace("{appId}", appId.ToString(), StringComparison.Ordinal)
.Replace("{assetId}", assetId.ToString()) .Replace("{assetId}", assetId.ToString(), StringComparison.Ordinal)
.Replace("{assetFileVersion}", assetFileVersion.ToString()); .Replace("{assetFileVersion}", assetFileVersion.ToString(CultureInfo.InvariantCulture), StringComparison.Ordinal);
} }
} }
} }

2
backend/tests/Squidex.Domain.Apps.Entities.Tests/Assets/DomainObject/AssetDomainObjectTests.cs

@ -83,7 +83,9 @@ namespace Squidex.Domain.Apps.Entities.Assets.DomainObject
.BuildServiceProvider(); .BuildServiceProvider();
sut = new AssetDomainObject(PersistenceFactory, log, serviceProvider); sut = new AssetDomainObject(PersistenceFactory, log, serviceProvider);
#pragma warning disable MA0056 // Do not call overridable members in constructor
sut.Setup(Id); sut.Setup(Id);
#pragma warning restore MA0056 // Do not call overridable members in constructor
} }
[Fact] [Fact]

2
backend/tests/Squidex.Domain.Apps.Entities.Tests/Assets/DomainObject/AssetFolderDomainObjectTests.cs

@ -57,7 +57,9 @@ namespace Squidex.Domain.Apps.Entities.Assets.DomainObject
.BuildServiceProvider(); .BuildServiceProvider();
sut = new AssetFolderDomainObject(PersistenceFactory, log, serviceProvider); sut = new AssetFolderDomainObject(PersistenceFactory, log, serviceProvider);
#pragma warning disable MA0056 // Do not call overridable members in constructor
sut.Setup(Id); sut.Setup(Id);
#pragma warning restore MA0056 // Do not call overridable members in constructor
} }
[Fact] [Fact]

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

@ -242,7 +242,7 @@ namespace Squidex.Domain.Apps.Entities.Assets.MongoDb
private static string Cleanup(string filter, object? arg = null) private static string Cleanup(string filter, object? arg = null)
{ {
return filter.Replace('\'', '"').Replace("[value]", arg?.ToString()); return filter.Replace('\'', '"').Replace("[value]", arg?.ToString(), StringComparison.Ordinal);
} }
} }
} }

7
backend/tests/Squidex.Domain.Apps.Entities.Tests/Assets/MongoDb/AssetsQueryFixture.cs

@ -7,6 +7,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Globalization;
using System.Threading.Tasks; using System.Threading.Tasks;
using MongoDB.Bson; using MongoDB.Bson;
using MongoDB.Driver; using MongoDB.Driver;
@ -77,11 +78,11 @@ namespace Squidex.Domain.Apps.Entities.Assets.MongoDb
{ {
for (var i = 0; i < numValues; i++) for (var i = 0; i < numValues; i++)
{ {
var fileName = i.ToString(); var fileName = i.ToString(CultureInfo.InvariantCulture);
for (var j = 0; j < numValues; j++) for (var j = 0; j < numValues; j++)
{ {
var tag = j.ToString(); var tag = j.ToString(CultureInfo.InvariantCulture);
var asset = new MongoAssetEntity var asset = new MongoAssetEntity
{ {
@ -129,7 +130,7 @@ namespace Squidex.Domain.Apps.Entities.Assets.MongoDb
public string RandomValue() public string RandomValue()
{ {
return random.Next(0, numValues).ToString(); return random.Next(0, numValues).ToString(CultureInfo.InvariantCulture);
} }
} }
} }

15
backend/tests/Squidex.Domain.Apps.Entities.Tests/Backup/BackupReaderWriterTests.cs

@ -7,6 +7,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Globalization;
using System.IO; using System.IO;
using System.Threading.Tasks; using System.Threading.Tasks;
using FakeItEasy; using FakeItEasy;
@ -163,15 +164,15 @@ namespace Squidex.Domain.Apps.Entities.Backup
var eventData = formatter.ToEventData(envelope, Guid.NewGuid(), true); var eventData = formatter.ToEventData(envelope, Guid.NewGuid(), true);
var eventStored = new StoredEvent(stream, "1", 2, eventData); var eventStored = new StoredEvent(stream, "1", 2, eventData);
var index = int.Parse(envelope.Headers["Index"].ToString()); var index = int.Parse(envelope.Headers["Index"].ToString(), NumberStyles.Integer, CultureInfo.InvariantCulture);
if (index % 17 == 0) if (index % 17 == 0)
{ {
await WriteGuidAsync(writer, index.ToString(), envelope.Payload.Id); await WriteGuidAsync(writer, index.ToString(CultureInfo.InvariantCulture), envelope.Payload.Id);
} }
else if (index % 37 == 0) else if (index % 37 == 0)
{ {
await WriteJsonGuidAsync(writer, index.ToString(), envelope.Payload.Id); await WriteJsonGuidAsync(writer, index.ToString(CultureInfo.InvariantCulture), envelope.Payload.Id);
} }
writer.WriteEvent(eventStored); writer.WriteEvent(eventStored);
@ -182,19 +183,19 @@ namespace Squidex.Domain.Apps.Entities.Backup
await foreach (var @event in reader.ReadEventsAsync(streamNameResolver, formatter)) await foreach (var @event in reader.ReadEventsAsync(streamNameResolver, formatter))
{ {
var index = int.Parse(@event.Event.Headers["Index"].ToString()); var index = int.Parse(@event.Event.Headers["Index"].ToString(), NumberStyles.Integer, CultureInfo.InvariantCulture);
var id = Guid.Parse(@event.Event.Headers["Id"].ToString()); var id = Guid.Parse(@event.Event.Headers["Id"].ToString());
if (index % 17 == 0) if (index % 17 == 0)
{ {
var guid = await ReadGuidAsync(reader, index.ToString()); var guid = await ReadGuidAsync(reader, index.ToString(CultureInfo.InvariantCulture));
Assert.Equal(id, guid); Assert.Equal(id, guid);
} }
else if (index % 37 == 0) else if (index % 37 == 0)
{ {
var guid = await ReadJsonGuidAsync(reader, index.ToString()); var guid = await ReadJsonGuidAsync(reader, index.ToString(CultureInfo.InvariantCulture));
Assert.Equal(id, guid); Assert.Equal(id, guid);
} }
@ -242,7 +243,7 @@ namespace Squidex.Domain.Apps.Entities.Backup
{ {
var buffer = new byte[16]; var buffer = new byte[16];
await stream.ReadAsync(buffer); _ = await stream.ReadAsync(buffer);
read = new Guid(buffer); read = new Guid(buffer);
} }

14
backend/tests/Squidex.Domain.Apps.Entities.Tests/Comments/DomainObject/CommentsGrainTests.cs

@ -57,12 +57,12 @@ namespace Squidex.Domain.Apps.Entities.Comments.DomainObject
result.Value.ShouldBeEquivalent(CommandResult.Empty(commentsId, 0, EtagVersion.Empty)); result.Value.ShouldBeEquivalent(CommandResult.Empty(commentsId, 0, EtagVersion.Empty));
sut.GetCommentsAsync(0).Result.Should().BeEquivalentTo(new CommentsResult (await sut.GetCommentsAsync(0)).Should().BeEquivalentTo(new CommentsResult
{ {
Version = 0 Version = 0
}); });
sut.GetCommentsAsync(-1).Result.Should().BeEquivalentTo(new CommentsResult (await sut.GetCommentsAsync(-1)).Should().BeEquivalentTo(new CommentsResult
{ {
CreatedComments = new List<Comment> CreatedComments = new List<Comment>
{ {
@ -88,7 +88,7 @@ namespace Squidex.Domain.Apps.Entities.Comments.DomainObject
result.Value.ShouldBeEquivalent(CommandResult.Empty(commentsId, 1, 0)); result.Value.ShouldBeEquivalent(CommandResult.Empty(commentsId, 1, 0));
sut.GetCommentsAsync(-1).Result.Should().BeEquivalentTo(new CommentsResult (await sut.GetCommentsAsync(-1)).Should().BeEquivalentTo(new CommentsResult
{ {
CreatedComments = new List<Comment> CreatedComments = new List<Comment>
{ {
@ -97,7 +97,7 @@ namespace Squidex.Domain.Apps.Entities.Comments.DomainObject
Version = 1 Version = 1
}); });
sut.GetCommentsAsync(0).Result.Should().BeEquivalentTo(new CommentsResult (await sut.GetCommentsAsync(0)).Should().BeEquivalentTo(new CommentsResult
{ {
UpdatedComments = new List<Comment> UpdatedComments = new List<Comment>
{ {
@ -124,12 +124,12 @@ namespace Squidex.Domain.Apps.Entities.Comments.DomainObject
result.Value.ShouldBeEquivalent(CommandResult.Empty(commentsId, 2, 1)); result.Value.ShouldBeEquivalent(CommandResult.Empty(commentsId, 2, 1));
sut.GetCommentsAsync(-1).Result.Should().BeEquivalentTo(new CommentsResult (await sut.GetCommentsAsync(-1)).Should().BeEquivalentTo(new CommentsResult
{ {
Version = 2 Version = 2
}); });
sut.GetCommentsAsync(0).Result.Should().BeEquivalentTo(new CommentsResult (await sut.GetCommentsAsync(0)).Should().BeEquivalentTo(new CommentsResult
{ {
DeletedComments = new List<DomainId> DeletedComments = new List<DomainId>
{ {
@ -138,7 +138,7 @@ namespace Squidex.Domain.Apps.Entities.Comments.DomainObject
Version = 2 Version = 2
}); });
sut.GetCommentsAsync(1).Result.Should().BeEquivalentTo(new CommentsResult (await sut.GetCommentsAsync(1)).Should().BeEquivalentTo(new CommentsResult
{ {
DeletedComments = new List<DomainId> DeletedComments = new List<DomainId>
{ {

1
backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/ContentSchedulerGrainTests.cs

@ -5,7 +5,6 @@
// All rights reserved. Licensed under the MIT license. // All rights reserved. Licensed under the MIT license.
// ========================================================================== // ==========================================================================
using System;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using FakeItEasy; using FakeItEasy;

2
backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/DomainObject/ContentDomainObjectTests.cs

@ -120,7 +120,9 @@ namespace Squidex.Domain.Apps.Entities.Contents.DomainObject
.BuildServiceProvider(); .BuildServiceProvider();
sut = new ContentDomainObject(PersistenceFactory, log, serviceProvider); sut = new ContentDomainObject(PersistenceFactory, log, serviceProvider);
#pragma warning disable MA0056 // Do not call overridable members in constructor
sut.Setup(Id); sut.Setup(Id);
#pragma warning restore MA0056 // Do not call overridable members in constructor
} }
[Fact] [Fact]

15
backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/GraphQL/GraphQLMutationTests.cs

@ -5,6 +5,7 @@
// All rights reserved. Licensed under the MIT license. // All rights reserved. Licensed under the MIT license.
// ========================================================================== // ==========================================================================
using System;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using System.Threading.Tasks; using System.Threading.Tasks;
using FakeItEasy; using FakeItEasy;
@ -730,19 +731,19 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL
private string CreateQuery(string query) private string CreateQuery(string query)
{ {
query = query query = query
.Replace("<ID>", contentId.ToString()) .Replace("<ID>", contentId.ToString(), StringComparison.Ordinal)
.Replace("'", "\"") .Replace("'", "\"", StringComparison.Ordinal)
.Replace("`", "\"") .Replace("`", "\"", StringComparison.Ordinal)
.Replace("<FIELDS>", TestContent.AllFields); .Replace("<FIELDS>", TestContent.AllFields, StringComparison.Ordinal);
if (query.Contains("<DATA>")) if (query.Contains("<DATA>", StringComparison.Ordinal))
{ {
var data = TestContent.Input(content, TestSchemas.Ref1.Id, TestSchemas.Ref2.Id); var data = TestContent.Input(content, TestSchemas.Ref1.Id, TestSchemas.Ref2.Id);
var dataJson = JsonConvert.SerializeObject(data, Formatting.Indented); var dataJson = JsonConvert.SerializeObject(data, Formatting.Indented);
var dataString = Regex.Replace(dataJson, "\"([^\"]+)\":", x => x.Groups[1].Value + ":").Replace(".0", string.Empty); var dataString = Regex.Replace(dataJson, "\"([^\"]+)\":", x => x.Groups[1].Value + ":").Replace(".0", string.Empty, StringComparison.Ordinal);
query = query.Replace("<DATA>", dataString); query = query.Replace("<DATA>", dataString, StringComparison.Ordinal);
} }
return query; return query;

27
backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/GraphQL/GraphQLQueriesTests.cs

@ -5,6 +5,7 @@
// All rights reserved. Licensed under the MIT license. // All rights reserved. Licensed under the MIT license.
// ========================================================================== // ==========================================================================
using System;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using FakeItEasy; using FakeItEasy;
@ -61,7 +62,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL
var asset = TestAsset.Create(DomainId.NewGuid()); var asset = TestAsset.Create(DomainId.NewGuid());
A.CallTo(() => assetQuery.QueryAsync(MatchsAssetContext(), null, A.CallTo(() => assetQuery.QueryAsync(MatchsAssetContext(), null,
A<Q>.That.Matches(x => x.QueryAsOdata == "?$top=30&$skip=5&$filter=my-query" && x.NoTotal == true), A<CancellationToken>._)) A<Q>.That.Matches(x => x.QueryAsOdata == "?$top=30&$skip=5&$filter=my-query" && x.NoTotal), A<CancellationToken>._))
.Returns(ResultList.CreateFrom(0, asset)); .Returns(ResultList.CreateFrom(0, asset));
var result = await ExecuteAsync(new ExecutionOptions { Query = query }); var result = await ExecuteAsync(new ExecutionOptions { Query = query });
@ -96,7 +97,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL
var asset = TestAsset.Create(DomainId.NewGuid()); var asset = TestAsset.Create(DomainId.NewGuid());
A.CallTo(() => assetQuery.QueryAsync(MatchsAssetContext(), null, A.CallTo(() => assetQuery.QueryAsync(MatchsAssetContext(), null,
A<Q>.That.Matches(x => x.QueryAsOdata == "?$top=30&$skip=5&$filter=my-query" && x.NoTotal == false), A<CancellationToken>._)) A<Q>.That.Matches(x => x.QueryAsOdata == "?$top=30&$skip=5&$filter=my-query" && !x.NoTotal), A<CancellationToken>._))
.Returns(ResultList.CreateFrom(10, asset)); .Returns(ResultList.CreateFrom(10, asset));
var result = await ExecuteAsync(new ExecutionOptions { Query = query }); var result = await ExecuteAsync(new ExecutionOptions { Query = query });
@ -190,7 +191,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL
var content = TestContent.Create(contentId); var content = TestContent.Create(contentId);
A.CallTo(() => contentQuery.QueryAsync(MatchsContentContext(), TestSchemas.Default.Id.ToString(), A.CallTo(() => contentQuery.QueryAsync(MatchsContentContext(), TestSchemas.Default.Id.ToString(),
A<Q>.That.Matches(x => x.QueryAsOdata == "?$top=30&$skip=5" && x.NoTotal == true), A<CancellationToken>._)) A<Q>.That.Matches(x => x.QueryAsOdata == "?$top=30&$skip=5" && x.NoTotal), A<CancellationToken>._))
.Returns(ResultList.CreateFrom(0, content)); .Returns(ResultList.CreateFrom(0, content));
var result = await ExecuteAsync(new ExecutionOptions { Query = query }); var result = await ExecuteAsync(new ExecutionOptions { Query = query });
@ -223,7 +224,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL
var content = TestContent.Create(contentId); var content = TestContent.Create(contentId);
A.CallTo(() => contentQuery.QueryAsync(MatchsContentContext(), TestSchemas.Default.Id.ToString(), A.CallTo(() => contentQuery.QueryAsync(MatchsContentContext(), TestSchemas.Default.Id.ToString(),
A<Q>.That.Matches(x => x.QueryAsOdata == "?$top=30&$skip=5" && x.NoTotal == true), A<CancellationToken>._)) A<Q>.That.Matches(x => x.QueryAsOdata == "?$top=30&$skip=5" && x.NoTotal), A<CancellationToken>._))
.Returns(ResultList.CreateFrom(0, content)); .Returns(ResultList.CreateFrom(0, content));
var result = await ExecuteAsync(new ExecutionOptions { Query = query }); var result = await ExecuteAsync(new ExecutionOptions { Query = query });
@ -259,7 +260,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL
var content = TestContent.Create(contentId); var content = TestContent.Create(contentId);
A.CallTo(() => contentQuery.QueryAsync(MatchsContentContext(), TestSchemas.Default.Id.ToString(), A.CallTo(() => contentQuery.QueryAsync(MatchsContentContext(), TestSchemas.Default.Id.ToString(),
A<Q>.That.Matches(x => x.QueryAsOdata == "?$top=30&$skip=5" && x.NoTotal == false), A<CancellationToken>._)) A<Q>.That.Matches(x => x.QueryAsOdata == "?$top=30&$skip=5" && !x.NoTotal), A<CancellationToken>._))
.Returns(ResultList.CreateFrom(10, content)); .Returns(ResultList.CreateFrom(10, content));
var result = await ExecuteAsync(new ExecutionOptions { Query = query }); var result = await ExecuteAsync(new ExecutionOptions { Query = query });
@ -466,7 +467,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL
.Returns(ResultList.CreateFrom(1, contentRef)); .Returns(ResultList.CreateFrom(1, contentRef));
A.CallTo(() => contentQuery.QueryAsync(MatchsContentContext(), content.SchemaId.Id.ToString(), A.CallTo(() => contentQuery.QueryAsync(MatchsContentContext(), content.SchemaId.Id.ToString(),
A<Q>.That.Matches(x => x.QueryAsOdata == "?$top=30&$skip=5" && x.Reference == contentRefId && x.NoTotal == true), A<CancellationToken>._)) A<Q>.That.Matches(x => x.QueryAsOdata == "?$top=30&$skip=5" && x.Reference == contentRefId && x.NoTotal), A<CancellationToken>._))
.Returns(ResultList.CreateFrom(1, content)); .Returns(ResultList.CreateFrom(1, content));
var result = await ExecuteAsync(new ExecutionOptions { Query = query }); var result = await ExecuteAsync(new ExecutionOptions { Query = query });
@ -530,7 +531,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL
.Returns(ResultList.CreateFrom(1, contentRef)); .Returns(ResultList.CreateFrom(1, contentRef));
A.CallTo(() => contentQuery.QueryAsync(MatchsContentContext(), content.SchemaId.Id.ToString(), A.CallTo(() => contentQuery.QueryAsync(MatchsContentContext(), content.SchemaId.Id.ToString(),
A<Q>.That.Matches(x => x.QueryAsOdata == "?$top=30&$skip=5" && x.Reference == contentRefId && x.NoTotal == false), A<CancellationToken>._)) A<Q>.That.Matches(x => x.QueryAsOdata == "?$top=30&$skip=5" && x.Reference == contentRefId && !x.NoTotal), A<CancellationToken>._))
.Returns(ResultList.CreateFrom(1, content)); .Returns(ResultList.CreateFrom(1, content));
var result = await ExecuteAsync(new ExecutionOptions { Query = query }); var result = await ExecuteAsync(new ExecutionOptions { Query = query });
@ -732,17 +733,17 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL
var json = serializer.Serialize(result); var json = serializer.Serialize(result);
Assert.Contains("\"errors\"", json); Assert.Contains("\"errors\"", json, StringComparison.Ordinal);
} }
private static string CreateQuery(string query, DomainId id = default) private static string CreateQuery(string query, DomainId id = default)
{ {
return query return query
.Replace("'", "\"") .Replace("'", "\"", StringComparison.Ordinal)
.Replace("<ID>", id.ToString()) .Replace("<ID>", id.ToString(), StringComparison.Ordinal)
.Replace("<FIELDS_ASSET>", TestAsset.AllFields) .Replace("<FIELDS_ASSET>", TestAsset.AllFields, StringComparison.Ordinal)
.Replace("<FIELDS_CONTENT>", TestContent.AllFields) .Replace("<FIELDS_CONTENT>", TestContent.AllFields, StringComparison.Ordinal)
.Replace("<FIELDS_CONTENT_FLAT>", TestContent.AllFlatFields); .Replace("<FIELDS_CONTENT_FLAT>", TestContent.AllFlatFields, StringComparison.Ordinal);
} }
private Context MatchsAssetContext() private Context MatchsAssetContext()

4
backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/MongoDb/ContentQueryTests.cs

@ -263,7 +263,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.MongoDb
private static string Cleanup(string filter, object? arg = null) private static string Cleanup(string filter, object? arg = null)
{ {
return filter.Replace('\'', '"').Replace("[value]", arg?.ToString()); return filter.Replace('\'', '"').Replace("[value]", arg?.ToString(), StringComparison.Ordinal);
} }
} }
} }

3
backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/MongoDb/ContentsQueryFixture.cs

@ -7,6 +7,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Globalization;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using FakeItEasy; using FakeItEasy;
@ -182,7 +183,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.MongoDb
public string RandomValue() public string RandomValue()
{ {
return random.Next(0, numValues).ToString(); return random.Next(0, numValues).ToString(CultureInfo.InvariantCulture);
} }
private static IAppEntity CreateApp(DomainId appId) private static IAppEntity CreateApp(DomainId appId)

7
backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/ReferencesFluidExtensionTests.cs

@ -5,6 +5,7 @@
// All rights reserved. Licensed under the MIT license. // All rights reserved. Licensed under the MIT license.
// ========================================================================== // ==========================================================================
using System;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using FakeItEasy; using FakeItEasy;
@ -156,9 +157,9 @@ namespace Squidex.Domain.Apps.Entities.Contents
private static string Cleanup(string text) private static string Cleanup(string text)
{ {
return text return text
.Replace("\r", string.Empty) .Replace("\r", string.Empty, StringComparison.Ordinal)
.Replace("\n", string.Empty) .Replace("\n", string.Empty, StringComparison.Ordinal)
.Replace(" ", string.Empty); .Replace(" ", string.Empty, StringComparison.Ordinal);
} }
} }
} }

6
backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/ReferencesJintExtensionTests.cs

@ -160,9 +160,9 @@ namespace Squidex.Domain.Apps.Entities.Contents
private static string Cleanup(string text) private static string Cleanup(string text)
{ {
return text return text
.Replace("\r", string.Empty) .Replace("\r", string.Empty, StringComparison.Ordinal)
.Replace("\n", string.Empty) .Replace("\n", string.Empty, StringComparison.Ordinal)
.Replace(" ", string.Empty); .Replace(" ", string.Empty, StringComparison.Ordinal);
} }
} }
} }

2
backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/Text/TextIndexerTests_Elastic.cs

@ -38,7 +38,9 @@ namespace Squidex.Domain.Apps.Entities.Contents.Text
public TextIndexerTests_Elastic() public TextIndexerTests_Elastic()
{ {
#pragma warning disable MA0056 // Do not call overridable members in constructor
SupportsQuerySyntax = true; SupportsQuerySyntax = true;
#pragma warning restore MA0056 // Do not call overridable members in constructor
} }
[Fact] [Fact]

2
backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/Text/TextIndexerTests_Mongo.cs

@ -51,8 +51,10 @@ namespace Squidex.Domain.Apps.Entities.Contents.Text
DomainIdSerializer.Register(); DomainIdSerializer.Register();
#pragma warning disable MA0056 // Do not call overridable members in constructor
SupportsQuerySyntax = false; SupportsQuerySyntax = false;
SupportsGeo = true; SupportsGeo = true;
#pragma warning restore MA0056 // Do not call overridable members in constructor
} }
[Fact] [Fact]

2
backend/tests/Squidex.Domain.Apps.Entities.Tests/Rules/DomainObject/RuleDomainObjectTests.cs

@ -39,7 +39,9 @@ namespace Squidex.Domain.Apps.Entities.Rules.DomainObject
public RuleDomainObjectTests() public RuleDomainObjectTests()
{ {
sut = new RuleDomainObject(PersistenceFactory, A.Dummy<ISemanticLog>(), appProvider, ruleEnqueuer); sut = new RuleDomainObject(PersistenceFactory, A.Dummy<ISemanticLog>(), appProvider, ruleEnqueuer);
#pragma warning disable MA0056 // Do not call overridable members in constructor
sut.Setup(Id); sut.Setup(Id);
#pragma warning restore MA0056 // Do not call overridable members in constructor
} }
[Fact] [Fact]

2
backend/tests/Squidex.Domain.Apps.Entities.Tests/Schemas/DomainObject/SchemaDomainObjectTests.cs

@ -39,7 +39,9 @@ namespace Squidex.Domain.Apps.Entities.Schemas.DomainObject
public SchemaDomainObjectTests() public SchemaDomainObjectTests()
{ {
sut = new SchemaDomainObject(PersistenceFactory, A.Dummy<ISemanticLog>()); sut = new SchemaDomainObject(PersistenceFactory, A.Dummy<ISemanticLog>());
#pragma warning disable MA0056 // Do not call overridable members in constructor
sut.Setup(Id); sut.Setup(Id);
#pragma warning restore MA0056 // Do not call overridable members in constructor
} }
[Fact] [Fact]

4
backend/tests/Squidex.Domain.Apps.Entities.Tests/Schemas/Indexes/SchemasIndexTests.cs

@ -38,11 +38,11 @@ namespace Squidex.Domain.Apps.Entities.Schemas.Indexes
A.CallTo(() => grainFactory.GetGrain<ISchemasCacheGrain>(appId.Id.ToString(), null)) A.CallTo(() => grainFactory.GetGrain<ISchemasCacheGrain>(appId.Id.ToString(), null))
.Returns(this.cache); .Returns(this.cache);
var cache = var localCache =
new ReplicatedCache(new MemoryCache(Options.Create(new MemoryCacheOptions())), new SimplePubSub(A.Fake<ILogger<SimplePubSub>>()), new ReplicatedCache(new MemoryCache(Options.Create(new MemoryCacheOptions())), new SimplePubSub(A.Fake<ILogger<SimplePubSub>>()),
Options.Create(new ReplicatedCacheOptions { Enable = true })); Options.Create(new ReplicatedCacheOptions { Enable = true }));
sut = new SchemasIndex(grainFactory, cache); sut = new SchemasIndex(grainFactory, localCache);
} }
[Fact] [Fact]

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

@ -4,6 +4,7 @@
<TargetFramework>net5.0</TargetFramework> <TargetFramework>net5.0</TargetFramework>
<RootNamespace>Squidex.Domain.Apps.Entities</RootNamespace> <RootNamespace>Squidex.Domain.Apps.Entities</RootNamespace>
<LangVersion>9.0</LangVersion> <LangVersion>9.0</LangVersion>
<NeutralLanguage>en</NeutralLanguage>
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
@ -22,6 +23,10 @@
<PackageReference Include="GraphQL" Version="4.5.0" /> <PackageReference Include="GraphQL" Version="4.5.0" />
<PackageReference Include="GraphQL.NewtonsoftJson" Version="4.5.0" /> <PackageReference Include="GraphQL.NewtonsoftJson" Version="4.5.0" />
<PackageReference Include="Lorem.Universal.Net" Version="4.0.80" /> <PackageReference Include="Lorem.Universal.Net" Version="4.0.80" />
<PackageReference Include="Meziantou.Analyzer" Version="1.0.670">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="5.0.0" /> <PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="5.0.0" />
<PackageReference Include="Microsoft.Extensions.Options" Version="5.0.0" /> <PackageReference Include="Microsoft.Extensions.Options" Version="5.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.10.0" /> <PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.10.0" />

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

@ -22,7 +22,7 @@ namespace Squidex.Domain.Apps.Entities.TestHelpers
public static Q HasIdsWithoutTotal(this INegatableArgumentConstraintManager<Q> that, params DomainId[] ids) public static Q HasIdsWithoutTotal(this INegatableArgumentConstraintManager<Q> that, params DomainId[] ids)
{ {
return that.Matches(x => x.Ids != null && x.Ids.SetEquals(ids) && x.NoTotal == true); return that.Matches(x => x.Ids != null && x.Ids.SetEquals(ids) && x.NoTotal);
} }
public static Q HasIds(this INegatableArgumentConstraintManager<Q> that, params DomainId[] ids) public static Q HasIds(this INegatableArgumentConstraintManager<Q> that, params DomainId[] ids)

4
backend/tests/Squidex.Domain.Apps.Entities.Tests/TestHelpers/HandlerTestBase.cs

@ -61,6 +61,7 @@ namespace Squidex.Domain.Apps.Entities.TestHelpers
protected HandlerTestBase() protected HandlerTestBase()
{ {
#pragma warning disable MA0056 // Do not call overridable members in constructor
A.CallTo(() => persistenceFactory.WithSnapshotsAndEventSourcing(A<Type>._, Id, A<HandleSnapshot<TState>>._, A<HandleEvent>._)) A.CallTo(() => persistenceFactory.WithSnapshotsAndEventSourcing(A<Type>._, Id, A<HandleSnapshot<TState>>._, A<HandleEvent>._))
.Returns(persistence); .Returns(persistence);
@ -72,6 +73,7 @@ namespace Squidex.Domain.Apps.Entities.TestHelpers
A.CallTo(() => persistence.DeleteAsync()) A.CallTo(() => persistence.DeleteAsync())
.Invokes(() => LastEvents = Enumerable.Empty<Envelope<IEvent>>()); .Invokes(() => LastEvents = Enumerable.Empty<Envelope<IEvent>>());
#pragma warning restore MA0056 // Do not call overridable members in constructor
} }
protected CommandContext CreateCommandContext<TCommand>(TCommand command) where TCommand : SquidexCommand protected CommandContext CreateCommandContext<TCommand>(TCommand command) where TCommand : SquidexCommand
@ -148,4 +150,4 @@ namespace Squidex.Domain.Apps.Entities.TestHelpers
return @event; return @event;
} }
} }
} }

2
backend/tests/Squidex.Infrastructure.Tests/Reflection/SimpleMapperTests.cs

@ -40,7 +40,9 @@ namespace Squidex.Infrastructure.Reflection
public class Writeonly<T> public class Writeonly<T>
{ {
#pragma warning disable MA0041 // Make property static
public T P1 public T P1
#pragma warning restore MA0041 // Make property static
{ {
set => Debug.WriteLine(value); set => Debug.WriteLine(value);
} }

Loading…
Cancel
Save