Browse Source

Verify (#908)

* Verify

* Tests fixed.

* Another test fix.

* Improved tests.

* Cleanup.

* Test fixes

* Another search fix.

* Remove slow test
pull/909/head
Sebastian Stehle 3 years ago
committed by GitHub
parent
commit
c925d48fa2
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      .dockerignore
  2. 4
      backend/src/Squidex/Areas/Api/Controllers/Backups/BackupsController.cs
  3. 2
      backend/src/Squidex/Areas/Api/Controllers/History/HistoryController.cs
  4. 2
      backend/src/Squidex/Areas/Api/Controllers/Rules/RulesController.cs
  5. 65
      backend/tools/TestSuite/TestSuite.ApiTests/AnonymousTests.Should_create_app_with_anonymous_read_access.verified.txt
  6. 65
      backend/tools/TestSuite/TestSuite.ApiTests/AnonymousTests.Should_create_app_with_anonymous_write_access.verified.txt
  7. 6
      backend/tools/TestSuite/TestSuite.ApiTests/AnonymousTests.cs
  8. 14
      backend/tools/TestSuite/TestSuite.ApiTests/AppClientsTests.Should_create_client.verified.txt
  9. 26
      backend/tools/TestSuite/TestSuite.ApiTests/AppClientsTests.Should_delete_client.verified.txt
  10. 42
      backend/tools/TestSuite/TestSuite.ApiTests/AppClientsTests.Should_update_client.verified.txt
  11. 11
      backend/tools/TestSuite/TestSuite.ApiTests/AppClientsTests.cs
  12. 11
      backend/tools/TestSuite/TestSuite.ApiTests/AppContributorsTests.Should_invite_contributor.verified.txt
  13. 11
      backend/tools/TestSuite/TestSuite.ApiTests/AppContributorsTests.Should_remove_contributor.verified.txt
  14. 27
      backend/tools/TestSuite/TestSuite.ApiTests/AppContributorsTests.Should_update_contributor.received.txt
  15. 1
      backend/tools/TestSuite/TestSuite.ApiTests/AppContributorsTests.Should_update_contributor.verified.txt
  16. 9
      backend/tools/TestSuite/TestSuite.ApiTests/AppContributorsTests.cs
  17. 65
      backend/tools/TestSuite/TestSuite.ApiTests/AppCreationTests.Should_create_app.verified.txt
  18. 396
      backend/tools/TestSuite/TestSuite.ApiTests/AppCreationTests.Should_create_app_from_templates.verified.txt
  19. 6
      backend/tools/TestSuite/TestSuite.ApiTests/AppCreationTests.cs
  20. 46
      backend/tools/TestSuite/TestSuite.ApiTests/AppLanguagesTests.Should_add_custom_language.verified.txt
  21. 46
      backend/tools/TestSuite/TestSuite.ApiTests/AppLanguagesTests.Should_add_language.verified.txt
  22. 32
      backend/tools/TestSuite/TestSuite.ApiTests/AppLanguagesTests.Should_delete_language.verified.txt
  23. 49
      backend/tools/TestSuite/TestSuite.ApiTests/AppLanguagesTests.Should_update_language.verified.txt
  24. 46
      backend/tools/TestSuite/TestSuite.ApiTests/AppLanguagesTests.Should_update_master_language.verified.txt
  25. 12
      backend/tools/TestSuite/TestSuite.ApiTests/AppLanguagesTests.cs
  26. 11
      backend/tools/TestSuite/TestSuite.ApiTests/AppRolesTests.Should_create_role.verified.txt
  27. 11
      backend/tools/TestSuite/TestSuite.ApiTests/AppRolesTests.Should_create_role_with_buggy_name.verified.txt
  28. 15
      backend/tools/TestSuite/TestSuite.ApiTests/AppRolesTests.Should_update_role.verified.txt
  29. 11
      backend/tools/TestSuite/TestSuite.ApiTests/AppRolesTests.cs
  30. 24
      backend/tools/TestSuite/TestSuite.ApiTests/AppTests.Should_update_settings.verified.txt
  31. 5
      backend/tools/TestSuite/TestSuite.ApiTests/AppTests.cs
  32. 41
      backend/tools/TestSuite/TestSuite.ApiTests/AppWorkflowsTests.Should_create_workflow.verified.txt
  33. 10
      backend/tools/TestSuite/TestSuite.ApiTests/AppWorkflowsTests.Should_delete_workflow.verified.txt
  34. 38
      backend/tools/TestSuite/TestSuite.ApiTests/AppWorkflowsTests.Should_update_workflow.verified.txt
  35. 9
      backend/tools/TestSuite/TestSuite.ApiTests/AppWorkflowsTests.cs
  36. 100
      backend/tools/TestSuite/TestSuite.ApiTests/AssetFixture.cs
  37. 47
      backend/tools/TestSuite/TestSuite.ApiTests/AssetFormatTests.Should_fix_orientation.verified.txt
  38. 46
      backend/tools/TestSuite/TestSuite.ApiTests/AssetFormatTests.Should_upload_audio_mp3.verified.txt
  39. 45
      backend/tools/TestSuite/TestSuite.ApiTests/AssetFormatTests.Should_upload_image_bmp_and_encode_to_webp.verified.txt
  40. 45
      backend/tools/TestSuite/TestSuite.ApiTests/AssetFormatTests.Should_upload_image_bmp_and_resize.verified.txt
  41. 46
      backend/tools/TestSuite/TestSuite.ApiTests/AssetFormatTests.Should_upload_image_gif_and_resize.verified.txt
  42. 42
      backend/tools/TestSuite/TestSuite.ApiTests/AssetFormatTests.Should_upload_image_gif_without_extension.verified.txt
  43. 47
      backend/tools/TestSuite/TestSuite.ApiTests/AssetFormatTests.Should_upload_image_jpg_and_resize.verified.txt
  44. 46
      backend/tools/TestSuite/TestSuite.ApiTests/AssetFormatTests.Should_upload_image_png_and_resize.verified.txt
  45. 45
      backend/tools/TestSuite/TestSuite.ApiTests/AssetFormatTests.Should_upload_image_tga_and_resize.verified.txt
  46. 46
      backend/tools/TestSuite/TestSuite.ApiTests/AssetFormatTests.Should_upload_image_tiff_and_resize.verified.txt
  47. 45
      backend/tools/TestSuite/TestSuite.ApiTests/AssetFormatTests.Should_upload_image_webp_and_resize.verified.txt
  48. 38
      backend/tools/TestSuite/TestSuite.ApiTests/AssetFormatTests.Should_upload_video_3gp.verified.txt
  49. 38
      backend/tools/TestSuite/TestSuite.ApiTests/AssetFormatTests.Should_upload_video_flv.verified.txt
  50. 38
      backend/tools/TestSuite/TestSuite.ApiTests/AssetFormatTests.Should_upload_video_mkv.verified.txt
  51. 48
      backend/tools/TestSuite/TestSuite.ApiTests/AssetFormatTests.Should_upload_video_mp4.verified.txt
  52. 60
      backend/tools/TestSuite/TestSuite.ApiTests/AssetFormatTests.cs
  53. 42
      backend/tools/TestSuite/TestSuite.ApiTests/AssetTests.Should_annotate_asset_in_parallel.verified.txt
  54. 47
      backend/tools/TestSuite/TestSuite.ApiTests/AssetTests.Should_annote_asset_file_name.verified.txt
  55. 46
      backend/tools/TestSuite/TestSuite.ApiTests/AssetTests.Should_annote_asset_metadata.verified.txt
  56. 47
      backend/tools/TestSuite/TestSuite.ApiTests/AssetTests.Should_annote_asset_slug.verified.txt
  57. 46
      backend/tools/TestSuite/TestSuite.ApiTests/AssetTests.Should_annote_asset_tags.verified.txt
  58. 47
      backend/tools/TestSuite/TestSuite.ApiTests/AssetTests.Should_protect_asset.verified.txt
  59. 48
      backend/tools/TestSuite/TestSuite.ApiTests/AssetTests.Should_replace_asset.verified.txt
  60. 46
      backend/tools/TestSuite/TestSuite.ApiTests/AssetTests.Should_upload_asset.verified.txt
  61. 46
      backend/tools/TestSuite/TestSuite.ApiTests/AssetTests.Should_upload_asset_with_custom_id.verified.txt
  62. 129
      backend/tools/TestSuite/TestSuite.ApiTests/AssetTests.cs
  63. 11
      backend/tools/TestSuite/TestSuite.ApiTests/BackupTests.cs
  64. 1
      backend/tools/TestSuite/TestSuite.ApiTests/CDNTests.cs
  65. 8
      backend/tools/TestSuite/TestSuite.ApiTests/CommentsTests.Should_create_comment.verified.txt
  66. 6
      backend/tools/TestSuite/TestSuite.ApiTests/CommentsTests.Should_delete_comment.verified.txt
  67. 9
      backend/tools/TestSuite/TestSuite.ApiTests/CommentsTests.Should_update_comment.verified.txt
  68. 11
      backend/tools/TestSuite/TestSuite.ApiTests/CommentsTests.cs
  69. 1
      backend/tools/TestSuite/TestSuite.ApiTests/ContentCleanupTests.cs
  70. 1
      backend/tools/TestSuite/TestSuite.ApiTests/ContentLanguageTests.cs
  71. 99
      backend/tools/TestSuite/TestSuite.ApiTests/ContentQueryTests.cs
  72. 1
      backend/tools/TestSuite/TestSuite.ApiTests/ContentReferencesTests.cs
  73. 1
      backend/tools/TestSuite/TestSuite.ApiTests/ContentScriptingTests.cs
  74. 17
      backend/tools/TestSuite/TestSuite.ApiTests/ContentUpdateTests.Should_create_non_published_content.verified.txt
  75. 26
      backend/tools/TestSuite/TestSuite.ApiTests/ContentUpdateTests.Should_create_null_text.verified.txt
  76. 24
      backend/tools/TestSuite/TestSuite.ApiTests/ContentUpdateTests.Should_create_strange_text.verified.txt
  77. 5
      backend/tools/TestSuite/TestSuite.ApiTests/ContentUpdateTests.Should_get_content_by_version.verified.txt
  78. 27
      backend/tools/TestSuite/TestSuite.ApiTests/ContentUpdateTests.Should_patch_content.verified.txt
  79. 20
      backend/tools/TestSuite/TestSuite.ApiTests/ContentUpdateTests.Should_patch_content_to_null.verified.txt
  80. 27
      backend/tools/TestSuite/TestSuite.ApiTests/ContentUpdateTests.Should_patch_content_with_bulk.verified.txt
  81. 27
      backend/tools/TestSuite/TestSuite.ApiTests/ContentUpdateTests.Should_patch_content_with_upsert.verified.txt
  82. 24
      backend/tools/TestSuite/TestSuite.ApiTests/ContentUpdateTests.Should_patch_id_data_value.verified.txt
  83. 40
      backend/tools/TestSuite/TestSuite.ApiTests/ContentUpdateTests.Should_recreate_deleted_content.verified.txt
  84. 40
      backend/tools/TestSuite/TestSuite.ApiTests/ContentUpdateTests.Should_recreate_deleted_content_with_upsert.verified.txt
  85. 21
      backend/tools/TestSuite/TestSuite.ApiTests/ContentUpdateTests.Should_update_singleton_content_with_special_id.verified.txt
  86. 22
      backend/tools/TestSuite/TestSuite.ApiTests/ContentUpdateTests.cs
  87. 29
      backend/tools/TestSuite/TestSuite.ApiTests/DiagnosticsTests.cs
  88. 1
      backend/tools/TestSuite/TestSuite.ApiTests/FrontendTests.cs
  89. 1
      backend/tools/TestSuite/TestSuite.ApiTests/GraphQLTests.cs
  90. 31
      backend/tools/TestSuite/TestSuite.ApiTests/HistoryTests.cs
  91. 1
      backend/tools/TestSuite/TestSuite.ApiTests/LanguagesTests.cs
  92. 1
      backend/tools/TestSuite/TestSuite.ApiTests/OpenApiTests.cs
  93. 1
      backend/tools/TestSuite/TestSuite.ApiTests/PingTests.cs
  94. 31
      backend/tools/TestSuite/TestSuite.ApiTests/PlansTests.cs
  95. 1
      backend/tools/TestSuite/TestSuite.ApiTests/RuleRunnerTests.cs
  96. 29
      backend/tools/TestSuite/TestSuite.ApiTests/RuleTests.Should_create_rule.verified.txt
  97. 31
      backend/tools/TestSuite/TestSuite.ApiTests/RuleTests.Should_update_rule.verified.txt
  98. 6
      backend/tools/TestSuite/TestSuite.ApiTests/RuleTests.cs
  99. 50
      backend/tools/TestSuite/TestSuite.ApiTests/SchemaTests.Should_create_singleton_schema.verified.txt
  100. 50
      backend/tools/TestSuite/TestSuite.ApiTests/SchemaTests.Should_create_singleton_schema_with_obsolete_property.verified.txt

1
.dockerignore

@ -3,6 +3,7 @@
*.user *.user
*.vs *.vs
*.log *.log
*.received.txt
.vs .vs
.git .git

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

@ -63,7 +63,7 @@ namespace Squidex.Areas.Api.Controllers.Backups
/// </returns> /// </returns>
[HttpPost] [HttpPost]
[Route("apps/{app}/backups/")] [Route("apps/{app}/backups/")]
[ProducesResponseType(typeof(List<BackupJobDto>), StatusCodes.Status200OK)] [ProducesResponseType(typeof(BackupJobDto[]), StatusCodes.Status200OK)]
[ApiPermissionOrAnonymous(Permissions.AppBackupsCreate)] [ApiPermissionOrAnonymous(Permissions.AppBackupsCreate)]
[ApiCosts(0)] [ApiCosts(0)]
public async Task<IActionResult> PostBackup(string app) public async Task<IActionResult> PostBackup(string app)
@ -84,7 +84,7 @@ namespace Squidex.Areas.Api.Controllers.Backups
/// </returns> /// </returns>
[HttpDelete] [HttpDelete]
[Route("apps/{app}/backups/{id}")] [Route("apps/{app}/backups/{id}")]
[ProducesResponseType(typeof(List<BackupJobDto>), StatusCodes.Status200OK)] [ProducesResponseType(typeof(BackupJobDto[]), StatusCodes.Status200OK)]
[ApiPermissionOrAnonymous(Permissions.AppBackupsDelete)] [ApiPermissionOrAnonymous(Permissions.AppBackupsDelete)]
[ApiCosts(0)] [ApiCosts(0)]
public async Task<IActionResult> DeleteBackup(string app, DomainId id) public async Task<IActionResult> DeleteBackup(string app, DomainId id)

2
backend/src/Squidex/Areas/Api/Controllers/History/HistoryController.cs

@ -39,7 +39,7 @@ namespace Squidex.Areas.Api.Controllers.History
/// </returns> /// </returns>
[HttpGet] [HttpGet]
[Route("apps/{app}/history/")] [Route("apps/{app}/history/")]
[ProducesResponseType(typeof(HistoryEventDto), StatusCodes.Status200OK)] [ProducesResponseType(typeof(HistoryEventDto[]), StatusCodes.Status200OK)]
[ApiPermissionOrAnonymous(Permissions.AppHistory)] [ApiPermissionOrAnonymous(Permissions.AppHistory)]
[ApiCosts(0.1)] [ApiCosts(0.1)]
public async Task<IActionResult> GetHistory(string app, string channel) public async Task<IActionResult> GetHistory(string app, string channel)

2
backend/src/Squidex/Areas/Api/Controllers/Rules/RulesController.cs

@ -466,7 +466,7 @@ namespace Squidex.Areas.Api.Controllers.Rules
/// </returns> /// </returns>
[HttpGet] [HttpGet]
[Route("rules/eventtypes")] [Route("rules/eventtypes")]
[ProducesResponseType(typeof(List<string>), StatusCodes.Status200OK)] [ProducesResponseType(typeof(string[]), StatusCodes.Status200OK)]
[AllowAnonymous] [AllowAnonymous]
public IActionResult GetEventTypes() public IActionResult GetEventTypes()
{ {

65
backend/tools/TestSuite/TestSuite.ApiTests/AnonymousTests.Should_create_app_with_anonymous_read_access.verified.txt

@ -0,0 +1,65 @@
{
name: Guid_1,
version: 2,
id: Guid_2,
canAccessContent: true,
_links: {
assets: {
method: GET
},
assets/create: {
method: POST
},
assets/scripts: {
method: DELETE
},
backups: {
method: GET
},
clients: {
method: GET
},
contributors: {
method: GET
},
delete: {
method: DELETE
},
image/delete: {
method: DELETE
},
image/upload: {
method: POST
},
languages: {
method: GET
},
ping: {
method: GET
},
plans: {
method: GET
},
roles: {
method: GET
},
rules: {
method: GET
},
schemas: {
method: GET
},
schemas/create: {
method: POST
},
settings: {
method: GET
},
update: {
method: PUT
},
workflows: {
method: GET
}
}
}

65
backend/tools/TestSuite/TestSuite.ApiTests/AnonymousTests.Should_create_app_with_anonymous_write_access.verified.txt

@ -0,0 +1,65 @@
{
name: Guid_1,
version: 2,
id: Guid_2,
canAccessContent: true,
_links: {
assets: {
method: GET
},
assets/create: {
method: POST
},
assets/scripts: {
method: DELETE
},
backups: {
method: GET
},
clients: {
method: GET
},
contributors: {
method: GET
},
delete: {
method: DELETE
},
image/delete: {
method: DELETE
},
image/upload: {
method: POST
},
languages: {
method: GET
},
ping: {
method: GET
},
plans: {
method: GET
},
roles: {
method: GET
},
rules: {
method: GET
},
schemas: {
method: GET
},
schemas/create: {
method: POST
},
settings: {
method: GET
},
update: {
method: PUT
},
workflows: {
method: GET
}
}
}

6
backend/tools/TestSuite/TestSuite.ApiTests/AnonymousTests.cs

@ -8,13 +8,13 @@
using System.Net; using System.Net;
using Squidex.ClientLibrary.Management; using Squidex.ClientLibrary.Management;
using TestSuite.Fixtures; using TestSuite.Fixtures;
using Xunit;
#pragma warning disable SA1300 // Element should begin with upper-case letter #pragma warning disable SA1300 // Element should begin with upper-case letter
#pragma warning disable SA1507 // Code should not contain multiple blank lines in a row #pragma warning disable SA1507 // Code should not contain multiple blank lines in a row
namespace TestSuite.ApiTests namespace TestSuite.ApiTests
{ {
[UsesVerify]
public class AnonymousTests : IClassFixture<ClientFixture> public class AnonymousTests : IClassFixture<ClientFixture>
{ {
public ClientFixture _ { get; } public ClientFixture _ { get; }
@ -59,6 +59,8 @@ namespace TestSuite.ApiTests
Assert.Equal(HttpStatusCode.OK, response.StatusCode); Assert.Equal(HttpStatusCode.OK, response.StatusCode);
} }
await Verify(app);
} }
[Fact] [Fact]
@ -107,6 +109,8 @@ namespace TestSuite.ApiTests
Assert.Equal(HttpStatusCode.Created, response.StatusCode); Assert.Equal(HttpStatusCode.Created, response.StatusCode);
} }
await Verify(app);
} }
} }
} }

14
backend/tools/TestSuite/TestSuite.ApiTests/AppClientsTests.Should_create_client.verified.txt

@ -0,0 +1,14 @@
{
id: Guid_1,
name: Guid_1,
role: Editor,
allowAnonymous: false,
_links: {
delete: {
method: DELETE
},
update: {
method: PUT
}
}
}

26
backend/tools/TestSuite/TestSuite.ApiTests/AppClientsTests.Should_delete_client.verified.txt

@ -0,0 +1,26 @@
{
items: [
{
id: default,
name: default,
role: Owner,
allowAnonymous: false,
_links: {
delete: {
method: DELETE
},
update: {
method: PUT
}
}
}
],
_links: {
create: {
method: POST
},
self: {
method: GET
}
}
}

42
backend/tools/TestSuite/TestSuite.ApiTests/AppClientsTests.Should_update_client.verified.txt

@ -0,0 +1,42 @@
{
items: [
{
id: default,
name: default,
role: Owner,
allowAnonymous: false,
_links: {
delete: {
method: DELETE
},
update: {
method: PUT
}
}
},
{
id: Guid_1,
name: My Client,
role: Owner,
apiCallsLimit: 100,
apiTrafficLimit: 200,
allowAnonymous: true,
_links: {
delete: {
method: DELETE
},
update: {
method: PUT
}
}
}
],
_links: {
create: {
method: POST
},
self: {
method: GET
}
}
}

11
backend/tools/TestSuite/TestSuite.ApiTests/AppClientsTests.cs

@ -7,13 +7,13 @@
using Squidex.ClientLibrary.Management; using Squidex.ClientLibrary.Management;
using TestSuite.Fixtures; using TestSuite.Fixtures;
using Xunit;
#pragma warning disable SA1300 // Element should begin with upper-case letter #pragma warning disable SA1300 // Element should begin with upper-case letter
#pragma warning disable SA1507 // Code should not contain multiple blank lines in a row #pragma warning disable SA1507 // Code should not contain multiple blank lines in a row
namespace TestSuite.ApiTests namespace TestSuite.ApiTests
{ {
[UsesVerify]
public sealed class AppClientsTests : IClassFixture<ClientFixture> public sealed class AppClientsTests : IClassFixture<ClientFixture>
{ {
private readonly string appName = Guid.NewGuid().ToString(); private readonly string appName = Guid.NewGuid().ToString();
@ -41,6 +41,9 @@ namespace TestSuite.ApiTests
// Should return client with correct name and id. // Should return client with correct name and id.
Assert.Equal(clientRole, client.Role); Assert.Equal(clientRole, client.Role);
Assert.Equal(id, client.Name); Assert.Equal(id, client.Name);
await Verify(client)
.IgnoreMember<ClientDto>(x => x.Secret);
} }
[Fact] [Fact]
@ -73,6 +76,9 @@ namespace TestSuite.ApiTests
Assert.Equal(updateNameRequest.ApiCallsLimit, client_2.ApiCallsLimit); Assert.Equal(updateNameRequest.ApiCallsLimit, client_2.ApiCallsLimit);
Assert.Equal(updateNameRequest.ApiTrafficLimit, client_2.ApiTrafficLimit); Assert.Equal(updateNameRequest.ApiTrafficLimit, client_2.ApiTrafficLimit);
Assert.Equal(updateNameRequest.Role, client_2.Role); Assert.Equal(updateNameRequest.Role, client_2.Role);
await Verify(clients_2)
.IgnoreMember<ClientDto>(x => x.Secret);
} }
[Fact] [Fact]
@ -91,6 +97,9 @@ namespace TestSuite.ApiTests
// Should not return deleted client. // Should not return deleted client.
Assert.DoesNotContain(clients_2.Items, x => x.Id == client.Id); Assert.DoesNotContain(clients_2.Items, x => x.Id == client.Id);
await Verify(clients_2)
.IgnoreMember<ClientDto>(x => x.Secret);
} }
private async Task<ClientDto> CreateAsync() private async Task<ClientDto> CreateAsync()

11
backend/tools/TestSuite/TestSuite.ApiTests/AppContributorsTests.Should_invite_contributor.verified.txt

@ -0,0 +1,11 @@
{
role: Developer,
_links: {
delete: {
method: DELETE
},
update: {
method: POST
}
}
}

11
backend/tools/TestSuite/TestSuite.ApiTests/AppContributorsTests.Should_remove_contributor.verified.txt

@ -0,0 +1,11 @@
{
maxContributors: -1,
_links: {
create: {
method: POST
},
self: {
method: GET
}
}
}

27
backend/tools/TestSuite/TestSuite.ApiTests/AppContributorsTests.Should_update_contributor.received.txt

@ -0,0 +1,27 @@
{
items: [
{
contributorId: 62e7ef6018142ae0daa22fb2,
contributorName: 5a1671f5-5651-415c-95a3-9e29bc83658e@squidex.io,
contributorEmail: 5a1671f5-5651-415c-95a3-9e29bc83658e@squidex.io,
role: Owner,
_links: {
delete: {
method: DELETE
},
update: {
method: POST
}
}
}
],
maxContributors: -1,
_links: {
create: {
method: POST
},
self: {
method: GET
}
}
}

1
backend/tools/TestSuite/TestSuite.ApiTests/AppContributorsTests.Should_update_contributor.verified.txt

@ -0,0 +1 @@


9
backend/tools/TestSuite/TestSuite.ApiTests/AppContributorsTests.cs

@ -7,13 +7,13 @@
using Squidex.ClientLibrary.Management; using Squidex.ClientLibrary.Management;
using TestSuite.Fixtures; using TestSuite.Fixtures;
using Xunit;
#pragma warning disable SA1300 // Element should begin with upper-case letter #pragma warning disable SA1300 // Element should begin with upper-case letter
#pragma warning disable SA1507 // Code should not contain multiple blank lines in a row #pragma warning disable SA1507 // Code should not contain multiple blank lines in a row
namespace TestSuite.ApiTests namespace TestSuite.ApiTests
{ {
[UsesVerify]
public sealed class AppContributorsTests : IClassFixture<ClientFixture> public sealed class AppContributorsTests : IClassFixture<ClientFixture>
{ {
private readonly string appName = Guid.NewGuid().ToString(); private readonly string appName = Guid.NewGuid().ToString();
@ -58,6 +58,11 @@ namespace TestSuite.ApiTests
ContributorDto contributor_1 = await InviteAsync(); ContributorDto contributor_1 = await InviteAsync();
Assert.Equal("Developer", contributor_1?.Role); Assert.Equal("Developer", contributor_1?.Role);
await Verify(contributor_1)
.IgnoreMember<ContributorDto>(x => x.ContributorId)
.IgnoreMember<ContributorDto>(x => x.ContributorEmail)
.IgnoreMember<ContributorDto>(x => x.ContributorName);
} }
[Fact] [Fact]
@ -100,6 +105,8 @@ namespace TestSuite.ApiTests
var contributors_2 = await _.Apps.DeleteContributorAsync(appName, contributor.ContributorId); var contributors_2 = await _.Apps.DeleteContributorAsync(appName, contributor.ContributorId);
Assert.DoesNotContain(contributors_2.Items, x => x.ContributorId == contributor.ContributorId); Assert.DoesNotContain(contributors_2.Items, x => x.ContributorId == contributor.ContributorId);
await Verify(contributors_2);
} }
private async Task<ContributorDto> InviteAsync() private async Task<ContributorDto> InviteAsync()

65
backend/tools/TestSuite/TestSuite.ApiTests/AppCreationTests.Should_create_app.verified.txt

@ -0,0 +1,65 @@
{
name: Guid_1,
version: 2,
id: Guid_2,
canAccessContent: true,
_links: {
assets: {
method: GET
},
assets/create: {
method: POST
},
assets/scripts: {
method: DELETE
},
backups: {
method: GET
},
clients: {
method: GET
},
contributors: {
method: GET
},
delete: {
method: DELETE
},
image/delete: {
method: DELETE
},
image/upload: {
method: POST
},
languages: {
method: GET
},
ping: {
method: GET
},
plans: {
method: GET
},
roles: {
method: GET
},
rules: {
method: GET
},
schemas: {
method: GET
},
schemas/create: {
method: POST
},
settings: {
method: GET
},
update: {
method: PUT
},
workflows: {
method: GET
}
}
}

396
backend/tools/TestSuite/TestSuite.ApiTests/AppCreationTests.Should_create_app_from_templates.verified.txt

@ -0,0 +1,396 @@
{
items: [
{
id: Guid_1,
name: pages,
properties: {
label: Pages,
validateOnPublish: false
},
isPublished: true,
version: 7,
scripts: {
create:
var data = ctx.data;
if (data.title && data.title.iv) {
data.slug = { iv: slugify(data.title.iv) };
replace(data);
},
update:
var data = ctx.data;
if (data.title && data.title.iv) {
data.slug = { iv: slugify(data.title.iv) };
replace(data);
}
},
fields: [
{
fieldId: 1,
name: title,
isHidden: false,
isLocked: false,
isDisabled: false,
partitioning: invariant,
properties: {
fieldType: String,
maxLength: 100,
isUnique: false,
isEmbeddable: false,
inlineEditable: false,
createEnum: false,
label: Title,
hints: The title of the page.,
isRequired: true,
isRequiredOnPublish: false,
isHalfWidth: false
},
_links: {
delete: {
method: DELETE
},
disable: {
method: PUT
},
hide: {
method: PUT
},
lock: {
method: PUT
},
update: {
method: PUT
}
}
},
{
fieldId: 2,
name: text,
isHidden: false,
isLocked: false,
isDisabled: false,
partitioning: invariant,
properties: {
fieldType: String,
isUnique: false,
isEmbeddable: false,
inlineEditable: false,
createEnum: false,
editor: RichText,
label: Text,
hints: The text of the page.,
isRequired: true,
isRequiredOnPublish: false,
isHalfWidth: false
},
_links: {
delete: {
method: DELETE
},
disable: {
method: PUT
},
hide: {
method: PUT
},
lock: {
method: PUT
},
update: {
method: PUT
}
}
},
{
fieldId: 3,
name: slug,
isHidden: false,
isLocked: false,
isDisabled: true,
partitioning: invariant,
properties: {
fieldType: String,
isUnique: false,
isEmbeddable: false,
inlineEditable: false,
createEnum: false,
label: Slug (Autogenerated),
hints: Autogenerated slug that can be used to identity the page.,
isRequired: false,
isRequiredOnPublish: false,
isHalfWidth: false
},
_links: {
delete: {
method: DELETE
},
enable: {
method: PUT
},
hide: {
method: PUT
},
lock: {
method: PUT
},
update: {
method: PUT
}
}
}
],
_links: {
contents: {
method: GET
},
contents/create: {
method: POST
},
contents/create/publish: {
method: POST
},
delete: {
method: DELETE
},
fields/add: {
method: POST
},
fields/order: {
method: PUT
},
fields/ui: {
method: PUT
},
self: {
method: GET
},
unpublish: {
method: PUT
},
update: {
method: PUT
},
update/category: {
method: PUT
},
update/rules: {
method: PUT
},
update/scripts: {
method: PUT
},
update/sync: {
method: PUT
},
update/urls: {
method: PUT
}
}
},
{
id: Guid_2,
name: posts,
properties: {
label: Posts,
validateOnPublish: false
},
isPublished: true,
version: 7,
scripts: {
create:
var data = ctx.data;
if (data.title && data.title.iv) {
data.slug = { iv: slugify(data.title.iv) };
replace(data);
},
update:
var data = ctx.data;
if (data.title && data.title.iv) {
data.slug = { iv: slugify(data.title.iv) };
replace(data);
}
},
fields: [
{
fieldId: 1,
name: title,
isHidden: false,
isLocked: false,
isDisabled: false,
partitioning: invariant,
properties: {
fieldType: String,
maxLength: 100,
isUnique: false,
isEmbeddable: false,
inlineEditable: false,
createEnum: false,
label: Title,
hints: The title of the post.,
isRequired: true,
isRequiredOnPublish: false,
isHalfWidth: false
},
_links: {
delete: {
method: DELETE
},
disable: {
method: PUT
},
hide: {
method: PUT
},
lock: {
method: PUT
},
update: {
method: PUT
}
}
},
{
fieldId: 2,
name: text,
isHidden: false,
isLocked: false,
isDisabled: false,
partitioning: invariant,
properties: {
fieldType: String,
isUnique: false,
isEmbeddable: false,
inlineEditable: false,
createEnum: false,
editor: RichText,
label: Text,
hints: The text of the post.,
isRequired: true,
isRequiredOnPublish: false,
isHalfWidth: false
},
_links: {
delete: {
method: DELETE
},
disable: {
method: PUT
},
hide: {
method: PUT
},
lock: {
method: PUT
},
update: {
method: PUT
}
}
},
{
fieldId: 3,
name: slug,
isHidden: false,
isLocked: false,
isDisabled: true,
partitioning: invariant,
properties: {
fieldType: String,
isUnique: false,
isEmbeddable: false,
inlineEditable: false,
createEnum: false,
label: Slug (Autogenerated),
hints: Autogenerated slug that can be used to identity the post.,
isRequired: false,
isRequiredOnPublish: false,
isHalfWidth: false
},
_links: {
delete: {
method: DELETE
},
enable: {
method: PUT
},
hide: {
method: PUT
},
lock: {
method: PUT
},
update: {
method: PUT
}
}
}
],
_links: {
contents: {
method: GET
},
contents/create: {
method: POST
},
contents/create/publish: {
method: POST
},
delete: {
method: DELETE
},
fields/add: {
method: POST
},
fields/order: {
method: PUT
},
fields/ui: {
method: PUT
},
self: {
method: GET
},
unpublish: {
method: PUT
},
update: {
method: PUT
},
update/category: {
method: PUT
},
update/rules: {
method: PUT
},
update/scripts: {
method: PUT
},
update/sync: {
method: PUT
},
update/urls: {
method: PUT
}
}
}
],
_links: {
create: {
method: POST
},
self: {
method: GET
}
}
}

6
backend/tools/TestSuite/TestSuite.ApiTests/AppCreationTests.cs

@ -7,13 +7,13 @@
using Squidex.ClientLibrary.Management; using Squidex.ClientLibrary.Management;
using TestSuite.Fixtures; using TestSuite.Fixtures;
using Xunit;
#pragma warning disable SA1300 // Element should begin with upper-case letter #pragma warning disable SA1300 // Element should begin with upper-case letter
#pragma warning disable SA1507 // Code should not contain multiple blank lines in a row #pragma warning disable SA1507 // Code should not contain multiple blank lines in a row
namespace TestSuite.ApiTests namespace TestSuite.ApiTests
{ {
[UsesVerify]
public class AppCreationTests : IClassFixture<ClientFixture> public class AppCreationTests : IClassFixture<ClientFixture>
{ {
private readonly string appName = Guid.NewGuid().ToString(); private readonly string appName = Guid.NewGuid().ToString();
@ -59,6 +59,8 @@ namespace TestSuite.ApiTests
// Should create default client. // Should create default client.
Assert.Contains(clients.Items, x => x.Id == "default"); Assert.Contains(clients.Items, x => x.Id == "default");
await Verify(app);
} }
[Fact] [Fact]
@ -142,6 +144,8 @@ namespace TestSuite.ApiTests
var schemas = await _.Schemas.GetSchemasAsync(appName); var schemas = await _.Schemas.GetSchemasAsync(appName);
Assert.NotEmpty(schemas.Items); Assert.NotEmpty(schemas.Items);
await Verify(schemas);
} }
private async Task CreateAppAsync() private async Task CreateAppAsync()

46
backend/tools/TestSuite/TestSuite.ApiTests/AppLanguagesTests.Should_add_custom_language.verified.txt

@ -0,0 +1,46 @@
{
items: [
{
iso2Code: en,
englishName: English,
isMaster: true,
isOptional: false
},
{
iso2Code: abc,
englishName: ,
isMaster: false,
isOptional: false,
_links: {
delete: {
method: DELETE
},
update: {
method: PUT
}
}
},
{
iso2Code: xyz,
englishName: ,
isMaster: false,
isOptional: false,
_links: {
delete: {
method: DELETE
},
update: {
method: PUT
}
}
}
],
_links: {
create: {
method: POST
},
self: {
method: GET
}
}
}

46
backend/tools/TestSuite/TestSuite.ApiTests/AppLanguagesTests.Should_add_language.verified.txt

@ -0,0 +1,46 @@
{
items: [
{
iso2Code: en,
englishName: English,
isMaster: true,
isOptional: false
},
{
iso2Code: de,
englishName: German,
isMaster: false,
isOptional: false,
_links: {
delete: {
method: DELETE
},
update: {
method: PUT
}
}
},
{
iso2Code: it,
englishName: Italian,
isMaster: false,
isOptional: false,
_links: {
delete: {
method: DELETE
},
update: {
method: PUT
}
}
}
],
_links: {
create: {
method: POST
},
self: {
method: GET
}
}
}

32
backend/tools/TestSuite/TestSuite.ApiTests/AppLanguagesTests.Should_delete_language.verified.txt

@ -0,0 +1,32 @@
{
items: [
{
iso2Code: en,
englishName: English,
isMaster: true,
isOptional: false
},
{
iso2Code: it,
englishName: Italian,
isMaster: false,
isOptional: true,
_links: {
delete: {
method: DELETE
},
update: {
method: PUT
}
}
}
],
_links: {
create: {
method: POST
},
self: {
method: GET
}
}
}

49
backend/tools/TestSuite/TestSuite.ApiTests/AppLanguagesTests.Should_update_language.verified.txt

@ -0,0 +1,49 @@
{
items: [
{
iso2Code: en,
englishName: English,
isMaster: true,
isOptional: false
},
{
iso2Code: de,
englishName: German,
fallback: [
it
],
isMaster: false,
isOptional: true,
_links: {
delete: {
method: DELETE
},
update: {
method: PUT
}
}
},
{
iso2Code: it,
englishName: Italian,
isMaster: false,
isOptional: false,
_links: {
delete: {
method: DELETE
},
update: {
method: PUT
}
}
}
],
_links: {
create: {
method: POST
},
self: {
method: GET
}
}
}

46
backend/tools/TestSuite/TestSuite.ApiTests/AppLanguagesTests.Should_update_master_language.verified.txt

@ -0,0 +1,46 @@
{
items: [
{
iso2Code: it,
englishName: Italian,
isMaster: true,
isOptional: false
},
{
iso2Code: de,
englishName: German,
isMaster: false,
isOptional: false,
_links: {
delete: {
method: DELETE
},
update: {
method: PUT
}
}
},
{
iso2Code: en,
englishName: English,
isMaster: false,
isOptional: false,
_links: {
delete: {
method: DELETE
},
update: {
method: PUT
}
}
}
],
_links: {
create: {
method: POST
},
self: {
method: GET
}
}
}

12
backend/tools/TestSuite/TestSuite.ApiTests/AppLanguagesTests.cs

@ -7,13 +7,13 @@
using Squidex.ClientLibrary.Management; using Squidex.ClientLibrary.Management;
using TestSuite.Fixtures; using TestSuite.Fixtures;
using Xunit;
#pragma warning disable SA1300 // Element should begin with upper-case letter #pragma warning disable SA1300 // Element should begin with upper-case letter
#pragma warning disable SA1507 // Code should not contain multiple blank lines in a row #pragma warning disable SA1507 // Code should not contain multiple blank lines in a row
namespace TestSuite.ApiTests namespace TestSuite.ApiTests
{ {
[UsesVerify]
public sealed class AppLanguagesTests : IClassFixture<ClientFixture> public sealed class AppLanguagesTests : IClassFixture<ClientFixture>
{ {
private readonly string appName = Guid.NewGuid().ToString(); private readonly string appName = Guid.NewGuid().ToString();
@ -39,6 +39,8 @@ namespace TestSuite.ApiTests
var languages_1 = await _.Apps.GetLanguagesAsync(appName); var languages_1 = await _.Apps.GetLanguagesAsync(appName);
Assert.Equal(new string[] { "en", "de", "it" }, languages_1.Items.Select(x => x.Iso2Code).ToArray()); Assert.Equal(new string[] { "en", "de", "it" }, languages_1.Items.Select(x => x.Iso2Code).ToArray());
await Verify(languages_1);
} }
[Fact] [Fact]
@ -55,6 +57,8 @@ namespace TestSuite.ApiTests
var languages_1 = await _.Apps.GetLanguagesAsync(appName); var languages_1 = await _.Apps.GetLanguagesAsync(appName);
Assert.Equal(new string[] { "en", "abc", "xyz" }, languages_1.Items.Select(x => x.Iso2Code).ToArray()); Assert.Equal(new string[] { "en", "abc", "xyz" }, languages_1.Items.Select(x => x.Iso2Code).ToArray());
await Verify(languages_1);
} }
[Fact] [Fact]
@ -84,6 +88,8 @@ namespace TestSuite.ApiTests
Assert.Equal(updateRequest.Fallback, language_2_DE.Fallback); Assert.Equal(updateRequest.Fallback, language_2_DE.Fallback);
Assert.Equal(updateRequest.IsOptional, language_2_DE.IsOptional); Assert.Equal(updateRequest.IsOptional, language_2_DE.IsOptional);
await Verify(languages_2);
} }
[Fact] [Fact]
@ -131,6 +137,8 @@ namespace TestSuite.ApiTests
// Fallback for new master language must be removed. // Fallback for new master language must be removed.
Assert.Empty(language_4_IT.Fallback); Assert.Empty(language_4_IT.Fallback);
await Verify(languages_4);
} }
[Fact] [Fact]
@ -166,6 +174,8 @@ namespace TestSuite.ApiTests
Assert.Empty(language_2_IT.Fallback); Assert.Empty(language_2_IT.Fallback);
Assert.Equal(new string[] { "en", "it" }, languages_2.Items.Select(x => x.Iso2Code).ToArray()); Assert.Equal(new string[] { "en", "it" }, languages_2.Items.Select(x => x.Iso2Code).ToArray());
await Verify(languages_2);
} }
private async Task CreateAppAsync() private async Task CreateAppAsync()

11
backend/tools/TestSuite/TestSuite.ApiTests/AppRolesTests.Should_create_role.verified.txt

@ -0,0 +1,11 @@
{
isDefaultRole: false,
_links: {
delete: {
method: DELETE
},
update: {
method: PUT
}
}
}

11
backend/tools/TestSuite/TestSuite.ApiTests/AppRolesTests.Should_create_role_with_buggy_name.verified.txt

@ -0,0 +1,11 @@
{
isDefaultRole: false,
_links: {
delete: {
method: DELETE
},
update: {
method: PUT
}
}
}

15
backend/tools/TestSuite/TestSuite.ApiTests/AppRolesTests.Should_update_role.verified.txt

@ -0,0 +1,15 @@
{
isDefaultRole: false,
permissions: [
a,
b
],
_links: {
delete: {
method: DELETE
},
update: {
method: PUT
}
}
}

11
backend/tools/TestSuite/TestSuite.ApiTests/AppRolesTests.cs

@ -7,13 +7,13 @@
using Squidex.ClientLibrary.Management; using Squidex.ClientLibrary.Management;
using TestSuite.Fixtures; using TestSuite.Fixtures;
using Xunit;
#pragma warning disable SA1300 // Element should begin with upper-case letter #pragma warning disable SA1300 // Element should begin with upper-case letter
#pragma warning disable SA1507 // Code should not contain multiple blank lines in a row #pragma warning disable SA1507 // Code should not contain multiple blank lines in a row
namespace TestSuite.ApiTests namespace TestSuite.ApiTests
{ {
[UsesVerify]
public sealed class AppRolesTests : IClassFixture<CreatedAppFixture> public sealed class AppRolesTests : IClassFixture<CreatedAppFixture>
{ {
private readonly string roleName = Guid.NewGuid().ToString(); private readonly string roleName = Guid.NewGuid().ToString();
@ -35,6 +35,9 @@ namespace TestSuite.ApiTests
// Should return role with correct name. // Should return role with correct name.
Assert.Empty(role.Permissions); Assert.Empty(role.Permissions);
await Verify(role)
.IgnoreMember<RoleDto>(x => x.Name);
} }
[Fact] [Fact]
@ -45,6 +48,9 @@ namespace TestSuite.ApiTests
// Should return role with correct name. // Should return role with correct name.
Assert.Empty(role.Permissions); Assert.Empty(role.Permissions);
await Verify(role)
.IgnoreMember<RoleDto>(x => x.Name);
} }
[Fact] [Fact]
@ -65,6 +71,9 @@ namespace TestSuite.ApiTests
// Should return role with correct name. // Should return role with correct name.
Assert.Equal(updateRequest.Permissions, role_2.Permissions); Assert.Equal(updateRequest.Permissions, role_2.Permissions);
await Verify(role_2)
.IgnoreMember<RoleDto>(x => x.Name);
} }
[Fact] [Fact]

24
backend/tools/TestSuite/TestSuite.ApiTests/AppTests.Should_update_settings.verified.txt

@ -0,0 +1,24 @@
{
patterns: [
{
name: pattern,
regex: .*
}
],
editors: [
{
name: editor,
url: http://squidex.io/path/to/editor
}
],
hideScheduler: false,
hideDateTimeModeButton: false,
_links: {
self: {
method: GET
},
update: {
method: PUT
}
}
}

5
backend/tools/TestSuite/TestSuite.ApiTests/AppTests.cs

@ -7,13 +7,13 @@
using Squidex.ClientLibrary.Management; using Squidex.ClientLibrary.Management;
using TestSuite.Fixtures; using TestSuite.Fixtures;
using Xunit;
#pragma warning disable SA1300 // Element should begin with upper-case letter #pragma warning disable SA1300 // Element should begin with upper-case letter
#pragma warning disable SA1507 // Code should not contain multiple blank lines in a row #pragma warning disable SA1507 // Code should not contain multiple blank lines in a row
namespace TestSuite.ApiTests namespace TestSuite.ApiTests
{ {
[UsesVerify]
public sealed class AppTests : IClassFixture<CreatedAppFixture> public sealed class AppTests : IClassFixture<CreatedAppFixture>
{ {
public CreatedAppFixture _ { get; } public CreatedAppFixture _ { get; }
@ -143,6 +143,9 @@ namespace TestSuite.ApiTests
Assert.NotEmpty(settings_1.Patterns); Assert.NotEmpty(settings_1.Patterns);
Assert.NotEmpty(settings_1.Editors); Assert.NotEmpty(settings_1.Editors);
await Verify(settings_1)
.IgnoreMember<AppSettingsDto>(x => x.Version);
} }
} }
} }

41
backend/tools/TestSuite/TestSuite.ApiTests/AppWorkflowsTests.Should_create_workflow.verified.txt

@ -0,0 +1,41 @@
{
id: Guid_1,
name: Guid_2,
steps: {
Archived: {
transitions: {
Draft: {}
},
color: #eb3142,
validate: false,
noUpdate: true
},
Draft: {
transitions: {
Archived: {},
Published: {}
},
color: #8091a5,
validate: false,
noUpdate: false
},
Published: {
transitions: {
Archived: {},
Draft: {}
},
color: #4bb958,
validate: false,
noUpdate: false
}
},
initial: Draft,
_links: {
delete: {
method: DELETE
},
update: {
method: PUT
}
}
}

10
backend/tools/TestSuite/TestSuite.ApiTests/AppWorkflowsTests.Should_delete_workflow.verified.txt

@ -0,0 +1,10 @@
{
_links: {
create: {
method: POST
},
self: {
method: GET
}
}
}

38
backend/tools/TestSuite/TestSuite.ApiTests/AppWorkflowsTests.Should_update_workflow.verified.txt

@ -0,0 +1,38 @@
{
items: [
{
id: Guid_1,
name: Guid_2,
steps: {
Draft: {
transitions: {
Published: {}
},
validate: false,
noUpdate: false
},
Published: {
validate: false,
noUpdate: false
}
},
initial: Draft,
_links: {
delete: {
method: DELETE
},
update: {
method: PUT
}
}
}
],
_links: {
create: {
method: POST
},
self: {
method: GET
}
}
}

9
backend/tools/TestSuite/TestSuite.ApiTests/AppWorkflowsTest.cs → backend/tools/TestSuite/TestSuite.ApiTests/AppWorkflowsTests.cs

@ -7,14 +7,13 @@
using Squidex.ClientLibrary.Management; using Squidex.ClientLibrary.Management;
using TestSuite.Fixtures; using TestSuite.Fixtures;
using Xunit;
#pragma warning disable MA0048 // File name must match type name
#pragma warning disable SA1300 // Element should begin with upper-case letter #pragma warning disable SA1300 // Element should begin with upper-case letter
#pragma warning disable SA1507 // Code should not contain multiple blank lines in a row #pragma warning disable SA1507 // Code should not contain multiple blank lines in a row
namespace TestSuite.ApiTests namespace TestSuite.ApiTests
{ {
[UsesVerify]
public sealed class AppWorkflowsTests : IClassFixture<ClientFixture> public sealed class AppWorkflowsTests : IClassFixture<ClientFixture>
{ {
private readonly string appName = Guid.NewGuid().ToString(); private readonly string appName = Guid.NewGuid().ToString();
@ -40,6 +39,8 @@ namespace TestSuite.ApiTests
Assert.NotNull(workflow); Assert.NotNull(workflow);
Assert.NotNull(workflow.Name); Assert.NotNull(workflow.Name);
Assert.Equal(3, workflow.Steps.Count); Assert.Equal(3, workflow.Steps.Count);
await Verify(workflow);
} }
[Fact] [Fact]
@ -77,6 +78,8 @@ namespace TestSuite.ApiTests
Assert.NotNull(workflow_2); Assert.NotNull(workflow_2);
Assert.NotNull(workflow_2.Name); Assert.NotNull(workflow_2.Name);
Assert.Equal(2, workflow_2.Steps.Count); Assert.Equal(2, workflow_2.Steps.Count);
await Verify(workflows_2);
} }
[Fact] [Fact]
@ -94,6 +97,8 @@ namespace TestSuite.ApiTests
var workflows_2 = await _.Apps.DeleteWorkflowAsync(appName, workflow.Id); var workflows_2 = await _.Apps.DeleteWorkflowAsync(appName, workflow.Id);
Assert.DoesNotContain(workflows_2.Items, x => x.Name == name); Assert.DoesNotContain(workflows_2.Items, x => x.Name == name);
await Verify(workflows_2);
} }
private async Task<WorkflowDto> CreateAsync() private async Task<WorkflowDto> CreateAsync()

100
backend/tools/TestSuite/TestSuite.ApiTests/AssetFixture.cs

@ -1,100 +0,0 @@
// ==========================================================================
// Squidex Headless CMS
// ==========================================================================
// Copyright (c) Squidex UG (haftungsbeschraenkt)
// All rights reserved. Licensed under the MIT license.
// ==========================================================================
using Squidex.ClientLibrary.Management;
using TestSuite.Fixtures;
namespace TestSuite.ApiTests
{
public class AssetFixture : CreatedAppFixture
{
public async Task<MemoryStream> DownloadAsync(AssetDto asset, int? version = null)
{
var temp = new MemoryStream();
using (var client = new HttpClient())
{
client.BaseAddress = new Uri(ServerUrl);
var url = asset._links["content"].Href[1..];
if (version > 0)
{
url += $"?version={version}";
}
var response = await client.GetAsync(url);
response.EnsureSuccessStatusCode();
await using (var stream = await response.Content.ReadAsStreamAsync())
{
await stream.CopyToAsync(temp);
}
}
return temp;
}
public async Task<AssetDto> UploadFileAsync(string path, AssetDto asset, string fileName = null)
{
var fileInfo = new FileInfo(path);
await using (var stream = fileInfo.OpenRead())
{
var upload = new FileParameter(stream, fileName ?? RandomName(fileInfo.Extension), asset.MimeType);
return await Assets.PutAssetContentAsync(AppName, asset.Id, upload);
}
}
public async Task<AssetDto> UploadFileAsync(string path, string mimeType, string fileName = null, string parentId = null, string id = null)
{
var fileInfo = new FileInfo(path);
await using (var stream = fileInfo.OpenRead())
{
var upload = new FileParameter(stream, fileName ?? RandomName(fileInfo.Extension), mimeType);
return await Assets.PostAssetAsync(AppName, parentId, id, true, upload);
}
}
public async Task<AssetDto> UploadFileAsync(int size, string fileName = null, string parentId = null, string id = null)
{
using (var stream = RandomAsset(size))
{
var upload = new FileParameter(stream, fileName ?? RandomName(".txt"), "text/csv");
return await Assets.PostAssetAsync(AppName, parentId, id, true, upload);
}
}
private static MemoryStream RandomAsset(int length)
{
var stream = new MemoryStream(length);
var random = new Random();
for (var i = 0; i < length; i++)
{
stream.WriteByte((byte)random.Next());
}
stream.Position = 0;
return stream;
}
private static string RandomName(string extension)
{
var fileName = $"{Guid.NewGuid()}{extension}";
return fileName;
}
}
}

47
backend/tools/TestSuite/TestSuite.ApiTests/AssetFormatTests.Should_fix_orientation.verified.txt

@ -0,0 +1,47 @@
{
id: Guid_1,
parentId: Guid_Empty,
fileName: logo-wide-rotated.jpg,
fileHash: TLNAlI4UM3i8O4IF/O7ZuH3PrI3+bsz4AsBt9NrEydI=,
isProtected: false,
slug: logo-wide-rotated.jpg,
mimeType: image/jpg,
fileType: jpg,
metadataText: 600x135px, 15.1 kB,
metadata: {
description: JFIF File,
imageQuality: 79,
pixelHeight: 135,
pixelWidth: 600
},
tags: [
type/jpg,
image,
image/medium
],
fileSize: 15425,
type: Image,
_links: {
content: {
method: GET
},
content/slug: {
method: GET
},
delete: {
method: DELETE
},
move: {
method: PUT
},
self: {
method: GET
},
update: {
method: PUT
},
upload: {
method: PUT
}
}
}

46
backend/tools/TestSuite/TestSuite.ApiTests/AssetFormatTests.Should_upload_audio_mp3.verified.txt

@ -0,0 +1,46 @@
{
id: Guid_1,
parentId: Guid_Empty,
fileName: SampleAudio_0.4mb.mp3,
fileHash: 0pbi5CFhQWqqSVy37vaw8bUOg3k1tDrlK1ySXxDrmNE=,
isProtected: false,
slug: sampleaudio-0.4mb.mp3,
mimeType: audio/mp3,
fileType: mp3,
metadataText: 00:00:28.2708750, 433.5 kB,
metadata: {
audioBitrate: 128,
audioChannels: 2,
audioSampleRate: 44100,
description: MPEG Version 1 Audio, Layer 3,
duration: 00:00:28.2708750
},
tags: [
type/mp3
],
fileSize: 443926,
type: Audio,
_links: {
content: {
method: GET
},
content/slug: {
method: GET
},
delete: {
method: DELETE
},
move: {
method: PUT
},
self: {
method: GET
},
update: {
method: PUT
},
upload: {
method: PUT
}
}
}

45
backend/tools/TestSuite/TestSuite.ApiTests/AssetFormatTests.Should_upload_image_bmp_and_encode_to_webp.verified.txt

@ -0,0 +1,45 @@
{
id: Guid_1,
parentId: Guid_Empty,
fileName: SampleImage_700kb.bmp,
fileHash: LNQGH33R2ShAFTo54UlxKOKzBg8a+yjVaFgzwiHw2LQ=,
isProtected: false,
slug: sampleimage-700kb.bmp,
mimeType: image/bmp,
fileType: bmp,
metadataText: 600x400px, 703.2 kB,
metadata: {
pixelHeight: 400,
pixelWidth: 600
},
tags: [
type/bmp,
image,
image/medium
],
fileSize: 720054,
type: Image,
_links: {
content: {
method: GET
},
content/slug: {
method: GET
},
delete: {
method: DELETE
},
move: {
method: PUT
},
self: {
method: GET
},
update: {
method: PUT
},
upload: {
method: PUT
}
}
}

45
backend/tools/TestSuite/TestSuite.ApiTests/AssetFormatTests.Should_upload_image_bmp_and_resize.verified.txt

@ -0,0 +1,45 @@
{
id: Guid_1,
parentId: Guid_Empty,
fileName: SampleImage_700kb.bmp,
fileHash: LNQGH33R2ShAFTo54UlxKOKzBg8a+yjVaFgzwiHw2LQ=,
isProtected: false,
slug: sampleimage-700kb.bmp,
mimeType: image/bmp,
fileType: bmp,
metadataText: 600x400px, 703.2 kB,
metadata: {
pixelHeight: 400,
pixelWidth: 600
},
tags: [
type/bmp,
image,
image/medium
],
fileSize: 720054,
type: Image,
_links: {
content: {
method: GET
},
content/slug: {
method: GET
},
delete: {
method: DELETE
},
move: {
method: PUT
},
self: {
method: GET
},
update: {
method: PUT
},
upload: {
method: PUT
}
}
}

46
backend/tools/TestSuite/TestSuite.ApiTests/AssetFormatTests.Should_upload_image_gif_and_resize.verified.txt

@ -0,0 +1,46 @@
{
id: Guid_1,
parentId: Guid_Empty,
fileName: SampleImage_150kb.gif,
fileHash: j+n9HuQJ0F4n5z0G29NfFlWJTuaGIW+eqw3NDOYCtU8=,
isProtected: false,
slug: sampleimage-150kb.gif,
mimeType: image/gif,
fileType: gif,
metadataText: 600x400px, 154.2 kB,
metadata: {
description: GIF File,
pixelHeight: 400,
pixelWidth: 600
},
tags: [
type/gif,
image,
image/medium
],
fileSize: 157934,
type: Image,
_links: {
content: {
method: GET
},
content/slug: {
method: GET
},
delete: {
method: DELETE
},
move: {
method: PUT
},
self: {
method: GET
},
update: {
method: PUT
},
upload: {
method: PUT
}
}
}

42
backend/tools/TestSuite/TestSuite.ApiTests/AssetFormatTests.Should_upload_image_gif_without_extension.verified.txt

@ -0,0 +1,42 @@
{
id: Guid_1,
parentId: Guid_Empty,
isProtected: false,
mimeType: image/gif,
fileType: blob,
metadataText: 600x400px, 154.2 kB,
metadata: {
pixelHeight: 400,
pixelWidth: 600
},
tags: [
type/blob,
image,
image/medium
],
fileSize: 157934,
type: Image,
_links: {
content: {
method: GET
},
content/slug: {
method: GET
},
delete: {
method: DELETE
},
move: {
method: PUT
},
self: {
method: GET
},
update: {
method: PUT
},
upload: {
method: PUT
}
}
}

47
backend/tools/TestSuite/TestSuite.ApiTests/AssetFormatTests.Should_upload_image_jpg_and_resize.verified.txt

@ -0,0 +1,47 @@
{
id: Guid_1,
parentId: Guid_Empty,
fileName: SampleImage_62kb.jpg,
fileHash: hmGXmHleJqbU37bbPExix+Jbu36GNq6ZPf09Uw63t8w=,
isProtected: false,
slug: sampleimage-62kb.jpg,
mimeType: image/jpg,
fileType: jpg,
metadataText: 600x400px, 62 kB,
metadata: {
description: JFIF File,
imageQuality: 79,
pixelHeight: 400,
pixelWidth: 600
},
tags: [
type/jpg,
image,
image/medium
],
fileSize: 63507,
type: Image,
_links: {
content: {
method: GET
},
content/slug: {
method: GET
},
delete: {
method: DELETE
},
move: {
method: PUT
},
self: {
method: GET
},
update: {
method: PUT
},
upload: {
method: PUT
}
}
}

46
backend/tools/TestSuite/TestSuite.ApiTests/AssetFormatTests.Should_upload_image_png_and_resize.verified.txt

@ -0,0 +1,46 @@
{
id: Guid_1,
parentId: Guid_Empty,
fileName: SampleImage_400kb.png,
fileHash: RpNNfc8ES2rBybyEgqP//18IgQReGtvjzb845gh0Ews=,
isProtected: false,
slug: sampleimage-400kb.png,
mimeType: image/png,
fileType: png,
metadataText: 600x400px, 428.9 kB,
metadata: {
description: PNG File,
pixelHeight: 400,
pixelWidth: 600
},
tags: [
type/png,
image,
image/medium
],
fileSize: 439244,
type: Image,
_links: {
content: {
method: GET
},
content/slug: {
method: GET
},
delete: {
method: DELETE
},
move: {
method: PUT
},
self: {
method: GET
},
update: {
method: PUT
},
upload: {
method: PUT
}
}
}

45
backend/tools/TestSuite/TestSuite.ApiTests/AssetFormatTests.Should_upload_image_tga_and_resize.verified.txt

@ -0,0 +1,45 @@
{
id: Guid_1,
parentId: Guid_Empty,
fileName: SampleImage_600kb.tga,
fileHash: KIi1RB34TaH+sGhnOIVsaPSn8ZRW1EMnM8noCzFbwsk=,
isProtected: false,
slug: sampleimage-600kb.tga,
mimeType: image/x-tga,
fileType: tga,
metadataText: 600x400px, 617.2 kB,
metadata: {
pixelHeight: 400,
pixelWidth: 600
},
tags: [
type/tga,
image,
image/medium
],
fileSize: 631995,
type: Image,
_links: {
content: {
method: GET
},
content/slug: {
method: GET
},
delete: {
method: DELETE
},
move: {
method: PUT
},
self: {
method: GET
},
update: {
method: PUT
},
upload: {
method: PUT
}
}
}

46
backend/tools/TestSuite/TestSuite.ApiTests/AssetFormatTests.Should_upload_image_tiff_and_resize.verified.txt

@ -0,0 +1,46 @@
{
id: Guid_1,
parentId: Guid_Empty,
fileName: SampleImage_400kb.tiff,
fileHash: f+ZdTDOoK23jmThbfPhWhXL8Q9+KIQajHeFfT/MtWFU=,
isProtected: false,
slug: sampleimage-400kb.tiff,
mimeType: image/jpg,
fileType: tiff,
metadataText: 600x400px, 473.6 kB,
metadata: {
description: TIFF File,
pixelHeight: 400,
pixelWidth: 600
},
tags: [
type/tiff,
image,
image/medium
],
fileSize: 485012,
type: Image,
_links: {
content: {
method: GET
},
content/slug: {
method: GET
},
delete: {
method: DELETE
},
move: {
method: PUT
},
self: {
method: GET
},
update: {
method: PUT
},
upload: {
method: PUT
}
}
}

45
backend/tools/TestSuite/TestSuite.ApiTests/AssetFormatTests.Should_upload_image_webp_and_resize.verified.txt

@ -0,0 +1,45 @@
{
id: Guid_1,
parentId: Guid_Empty,
fileName: SampleImage_100kb.webp,
fileHash: WwD409RVswvccG2YopnFqJzpWrCveLrd0Zj6Buw8Vao=,
isProtected: false,
slug: sampleimage-100kb.webp,
mimeType: image/jpg,
fileType: webp,
metadataText: 600x400px, 109.5 kB,
metadata: {
pixelHeight: 400,
pixelWidth: 600
},
tags: [
type/webp,
image,
image/medium
],
fileSize: 112138,
type: Image,
_links: {
content: {
method: GET
},
content/slug: {
method: GET
},
delete: {
method: DELETE
},
move: {
method: PUT
},
self: {
method: GET
},
update: {
method: PUT
},
upload: {
method: PUT
}
}
}

38
backend/tools/TestSuite/TestSuite.ApiTests/AssetFormatTests.Should_upload_video_3gp.verified.txt

@ -0,0 +1,38 @@
{
id: Guid_1,
parentId: Guid_Empty,
fileName: SampleVideo_176x144_1mb.3gp,
fileHash: 5zD+lLsuo4GmL9csQoc25ihbmRzkRUAym+PNe1Z73Y0=,
isProtected: false,
slug: samplevideo-176x144-1mb.3gp,
mimeType: audio/3gpp,
fileType: 3gp,
metadataText: 1014.4 kB,
tags: [
type/3gp
],
fileSize: 1038741,
_links: {
content: {
method: GET
},
content/slug: {
method: GET
},
delete: {
method: DELETE
},
move: {
method: PUT
},
self: {
method: GET
},
update: {
method: PUT
},
upload: {
method: PUT
}
}
}

38
backend/tools/TestSuite/TestSuite.ApiTests/AssetFormatTests.Should_upload_video_flv.verified.txt

@ -0,0 +1,38 @@
{
id: Guid_1,
parentId: Guid_Empty,
fileName: SampleVideo_1280x720_1mb.flv,
fileHash: 3oKq+MS0nT4apMnvvhPkIpFIBkk+GY8z2qevv16cbgI=,
isProtected: false,
slug: samplevideo-1280x720-1mb.flv,
mimeType: audio/x-flv,
fileType: flv,
metadataText: 1 MB,
tags: [
type/flv
],
fileSize: 1051185,
_links: {
content: {
method: GET
},
content/slug: {
method: GET
},
delete: {
method: DELETE
},
move: {
method: PUT
},
self: {
method: GET
},
update: {
method: PUT
},
upload: {
method: PUT
}
}
}

38
backend/tools/TestSuite/TestSuite.ApiTests/AssetFormatTests.Should_upload_video_mkv.verified.txt

@ -0,0 +1,38 @@
{
id: Guid_1,
parentId: Guid_Empty,
fileName: SampleVideo_1280x720_1mb.flv,
fileHash: 3oKq+MS0nT4apMnvvhPkIpFIBkk+GY8z2qevv16cbgI=,
isProtected: false,
slug: samplevideo-1280x720-1mb.flv,
mimeType: audio/webm,
fileType: flv,
metadataText: 1 MB,
tags: [
type/flv
],
fileSize: 1051185,
_links: {
content: {
method: GET
},
content/slug: {
method: GET
},
delete: {
method: DELETE
},
move: {
method: PUT
},
self: {
method: GET
},
update: {
method: PUT
},
upload: {
method: PUT
}
}
}

48
backend/tools/TestSuite/TestSuite.ApiTests/AssetFormatTests.Should_upload_video_mp4.verified.txt

@ -0,0 +1,48 @@
{
id: Guid_1,
parentId: Guid_Empty,
fileName: SampleVideo_1280x720_1mb.mp4,
fileHash: SoNpw/wBHvjtUJPXWHOoJrGZco0qSJWp27vl5qXcQOo=,
isProtected: false,
slug: samplevideo-1280x720-1mb.mp4,
mimeType: audio/mp4,
fileType: mp4,
metadataText: 1280x720pt, 00:00:05.3120000, 1 MB,
metadata: {
audioBitrate: 384,
audioChannels: 2,
audioSampleRate: 48000,
description: MPEG-4 Audio (mp4a); MPEG-4 Video (avc1),
duration: 00:00:05.3120000,
videoHeight: 720,
videoWidth: 1280
},
tags: [
type/mp4
],
fileSize: 1055736,
type: Video,
_links: {
content: {
method: GET
},
content/slug: {
method: GET
},
delete: {
method: DELETE
},
move: {
method: PUT
},
self: {
method: GET
},
update: {
method: PUT
},
upload: {
method: PUT
}
}
}

60
backend/tools/TestSuite/TestSuite.ApiTests/AssetFormatTests.cs

@ -6,18 +6,19 @@
// ========================================================================== // ==========================================================================
using Squidex.ClientLibrary.Management; using Squidex.ClientLibrary.Management;
using Xunit; using TestSuite.Fixtures;
#pragma warning disable SA1300 // Element should begin with upper-case letter #pragma warning disable SA1300 // Element should begin with upper-case letter
#pragma warning disable CS0618 // Type or member is obsolete #pragma warning disable CS0618 // Type or member is obsolete
namespace TestSuite.ApiTests namespace TestSuite.ApiTests
{ {
public class AssetFormatTests : IClassFixture<AssetFixture> [UsesVerify]
public class AssetFormatTests : IClassFixture<CreatedAppFixture>
{ {
public AssetFixture _ { get; } public CreatedAppFixture _ { get; }
public AssetFormatTests(AssetFixture fixture) public AssetFormatTests(CreatedAppFixture fixture)
{ {
_ = fixture; _ = fixture;
} }
@ -25,7 +26,7 @@ namespace TestSuite.ApiTests
[Fact] [Fact]
public async Task Should_upload_image_gif_without_extension() public async Task Should_upload_image_gif_without_extension()
{ {
var asset = await _.UploadFileAsync("Assets/SampleImage_150kb.gif", "image/gif", Guid.NewGuid().ToString()); var asset = await _.Assets.UploadFileAsync(_.AppName, "Assets/SampleImage_150kb.gif", "image/gif", Guid.NewGuid().ToString());
// Should parse image metadata. // Should parse image metadata.
Assert.True(asset.IsImage); Assert.True(asset.IsImage);
@ -34,12 +35,17 @@ namespace TestSuite.ApiTests
Assert.Equal(400L, (long)asset.PixelHeight); Assert.Equal(400L, (long)asset.PixelHeight);
Assert.Equal(400L, asset.Metadata["pixelHeight"]); Assert.Equal(400L, asset.Metadata["pixelHeight"]);
Assert.Equal(AssetType.Image, asset.Type); Assert.Equal(AssetType.Image, asset.Type);
await Verify(asset)
.IgnoreMember<AssetDto>(x => x.FileName)
.IgnoreMember<AssetDto>(x => x.FileHash)
.IgnoreMember<AssetDto>(x => x.Slug);
} }
[Fact] [Fact]
public async Task Should_upload_image_gif_and_resize() public async Task Should_upload_image_gif_and_resize()
{ {
var asset = await _.UploadFileAsync("Assets/SampleImage_150kb.gif", "image/gif"); var asset = await _.Assets.UploadFileAsync(_.AppName, "Assets/SampleImage_150kb.gif", "image/gif");
await AssertImageAsync(asset); await AssertImageAsync(asset);
} }
@ -47,7 +53,7 @@ namespace TestSuite.ApiTests
[Fact] [Fact]
public async Task Should_upload_image_png_and_resize() public async Task Should_upload_image_png_and_resize()
{ {
var asset = await _.UploadFileAsync("Assets/SampleImage_400kb.png", "image/png"); var asset = await _.Assets.UploadFileAsync(_.AppName, "Assets/SampleImage_400kb.png", "image/png");
await AssertImageAsync(asset); await AssertImageAsync(asset);
} }
@ -55,7 +61,7 @@ namespace TestSuite.ApiTests
[Fact] [Fact]
public async Task Should_upload_image_jpg_and_resize() public async Task Should_upload_image_jpg_and_resize()
{ {
var asset = await _.UploadFileAsync("Assets/SampleImage_62kb.jpg", "image/jpg"); var asset = await _.Assets.UploadFileAsync(_.AppName, "Assets/SampleImage_62kb.jpg", "image/jpg");
await AssertImageAsync(asset); await AssertImageAsync(asset);
@ -65,7 +71,7 @@ namespace TestSuite.ApiTests
[Fact] [Fact]
public async Task Should_upload_image_webp_and_resize() public async Task Should_upload_image_webp_and_resize()
{ {
var asset = await _.UploadFileAsync("Assets/SampleImage_100kb.webp", "image/jpg"); var asset = await _.Assets.UploadFileAsync(_.AppName, "Assets/SampleImage_100kb.webp", "image/jpg");
await AssertImageAsync(asset); await AssertImageAsync(asset);
} }
@ -73,7 +79,7 @@ namespace TestSuite.ApiTests
[Fact] [Fact]
public async Task Should_upload_image_tiff_and_resize() public async Task Should_upload_image_tiff_and_resize()
{ {
var asset = await _.UploadFileAsync("Assets/SampleImage_400kb.tiff", "image/jpg"); var asset = await _.Assets.UploadFileAsync(_.AppName, "Assets/SampleImage_400kb.tiff", "image/jpg");
await AssertImageAsync(asset); await AssertImageAsync(asset);
} }
@ -81,7 +87,7 @@ namespace TestSuite.ApiTests
[Fact] [Fact]
public async Task Should_upload_image_tga_and_resize() public async Task Should_upload_image_tga_and_resize()
{ {
var asset = await _.UploadFileAsync("Assets/SampleImage_600kb.tga", "image/x-tga"); var asset = await _.Assets.UploadFileAsync(_.AppName, "Assets/SampleImage_600kb.tga", "image/x-tga");
await AssertImageAsync(asset); await AssertImageAsync(asset);
} }
@ -89,7 +95,7 @@ namespace TestSuite.ApiTests
[Fact] [Fact]
public async Task Should_upload_image_bmp_and_resize() public async Task Should_upload_image_bmp_and_resize()
{ {
var asset = await _.UploadFileAsync("Assets/SampleImage_700kb.bmp", "image/bmp"); var asset = await _.Assets.UploadFileAsync(_.AppName, "Assets/SampleImage_700kb.bmp", "image/bmp");
await AssertImageAsync(asset); await AssertImageAsync(asset);
} }
@ -97,16 +103,20 @@ namespace TestSuite.ApiTests
[Fact] [Fact]
public async Task Should_upload_image_bmp_and_encode_to_webp() public async Task Should_upload_image_bmp_and_encode_to_webp()
{ {
var asset = await _.UploadFileAsync("Assets/SampleImage_700kb.bmp", "image/bmp"); var asset = await _.Assets.UploadFileAsync(_.AppName, "Assets/SampleImage_700kb.bmp", "image/bmp");
var (size, type) = await GetReformattedLength(asset.Id, "WEBP"); var (size, type) = await GetReformattedLength(asset.Id, "WEBP");
Assert.True(size < asset.FileSize); Assert.True(size < asset.FileSize);
Assert.Equal("image/webp", type); Assert.Equal("image/webp", type);
await Verify(asset);
} }
private async Task AssertImageAsync(AssetDto asset) private async Task AssertImageAsync(AssetDto asset)
{ {
await Verify(asset);
// Should parse image metadata. // Should parse image metadata.
Assert.True(asset.IsImage); Assert.True(asset.IsImage);
Assert.Equal(600L, (long)asset.PixelWidth); Assert.Equal(600L, (long)asset.PixelWidth);
@ -123,7 +133,7 @@ namespace TestSuite.ApiTests
[Fact] [Fact]
public async Task Should_fix_orientation() public async Task Should_fix_orientation()
{ {
var asset = await _.UploadFileAsync("Assets/logo-wide-rotated.jpg", "image/jpg"); var asset = await _.Assets.UploadFileAsync(_.AppName, "Assets/logo-wide-rotated.jpg", "image/jpg");
// Should parse image metadata and fix orientation. // Should parse image metadata and fix orientation.
Assert.True(asset.IsImage); Assert.True(asset.IsImage);
@ -133,12 +143,14 @@ namespace TestSuite.ApiTests
Assert.Equal(135L, asset.Metadata["pixelHeight"]); Assert.Equal(135L, asset.Metadata["pixelHeight"]);
Assert.Equal(79L, asset.Metadata["imageQuality"]); Assert.Equal(79L, asset.Metadata["imageQuality"]);
Assert.Equal(AssetType.Image, asset.Type); Assert.Equal(AssetType.Image, asset.Type);
await Verify(asset);
} }
[Fact] [Fact]
public async Task Should_upload_audio_mp3() public async Task Should_upload_audio_mp3()
{ {
var asset = await _.UploadFileAsync("Assets/SampleAudio_0.4mb.mp3", "audio/mp3"); var asset = await _.Assets.UploadFileAsync(_.AppName, "Assets/SampleAudio_0.4mb.mp3", "audio/mp3");
// Should parse audio metadata. // Should parse audio metadata.
Assert.False(asset.IsImage); Assert.False(asset.IsImage);
@ -147,12 +159,14 @@ namespace TestSuite.ApiTests
Assert.Equal(2L, asset.Metadata["audioChannels"]); Assert.Equal(2L, asset.Metadata["audioChannels"]);
Assert.Equal(44100L, asset.Metadata["audioSampleRate"]); Assert.Equal(44100L, asset.Metadata["audioSampleRate"]);
Assert.Equal(AssetType.Audio, asset.Type); Assert.Equal(AssetType.Audio, asset.Type);
await Verify(asset);
} }
[Fact] [Fact]
public async Task Should_upload_video_mp4() public async Task Should_upload_video_mp4()
{ {
var asset = await _.UploadFileAsync("Assets/SampleVideo_1280x720_1mb.mp4", "audio/mp4"); var asset = await _.Assets.UploadFileAsync(_.AppName, "Assets/SampleVideo_1280x720_1mb.mp4", "audio/mp4");
// Should parse video metadata. // Should parse video metadata.
Assert.False(asset.IsImage); Assert.False(asset.IsImage);
@ -163,33 +177,41 @@ namespace TestSuite.ApiTests
Assert.Equal(1280L, asset.Metadata["videoWidth"]); Assert.Equal(1280L, asset.Metadata["videoWidth"]);
Assert.Equal(720L, asset.Metadata["videoHeight"]); Assert.Equal(720L, asset.Metadata["videoHeight"]);
Assert.Equal(AssetType.Video, asset.Type); Assert.Equal(AssetType.Video, asset.Type);
await Verify(asset);
} }
[Fact] [Fact]
public async Task Should_upload_video_mkv() public async Task Should_upload_video_mkv()
{ {
var asset = await _.UploadFileAsync("Assets/SampleVideo_1280x720_1mb.flv", "audio/webm"); var asset = await _.Assets.UploadFileAsync(_.AppName, "Assets/SampleVideo_1280x720_1mb.flv", "audio/webm");
// Should not parse yet. // Should not parse yet.
Assert.Equal(AssetType.Unknown, asset.Type); Assert.Equal(AssetType.Unknown, asset.Type);
await Verify(asset);
} }
[Fact] [Fact]
public async Task Should_upload_video_flv() public async Task Should_upload_video_flv()
{ {
var asset = await _.UploadFileAsync("Assets/SampleVideo_1280x720_1mb.flv", "audio/x-flv"); var asset = await _.Assets.UploadFileAsync(_.AppName, "Assets/SampleVideo_1280x720_1mb.flv", "audio/x-flv");
// Should not parse yet. // Should not parse yet.
Assert.Equal(AssetType.Unknown, asset.Type); Assert.Equal(AssetType.Unknown, asset.Type);
await Verify(asset);
} }
[Fact] [Fact]
public async Task Should_upload_video_3gp() public async Task Should_upload_video_3gp()
{ {
var asset = await _.UploadFileAsync("Assets/SampleVideo_176x144_1mb.3gp", "audio/3gpp"); var asset = await _.Assets.UploadFileAsync(_.AppName, "Assets/SampleVideo_176x144_1mb.3gp", "audio/3gpp");
// Should not parse yet. // Should not parse yet.
Assert.Equal(AssetType.Unknown, asset.Type); Assert.Equal(AssetType.Unknown, asset.Type);
await Verify(asset);
} }
private async Task<long> GetResizedLengthAsync(string imageId, int width, int height) private async Task<long> GetResizedLengthAsync(string imageId, int width, int height)

42
backend/tools/TestSuite/TestSuite.ApiTests/AssetTests.Should_annotate_asset_in_parallel.verified.txt

@ -0,0 +1,42 @@
{
id: Guid_1,
parentId: Guid_Empty,
fileName: logo-squared.png,
fileHash: pAp0RDvipkoNCCTgey1HTJekRKKEWT6Ft5JdRLuAfAc=,
isProtected: false,
slug: logo-squared.png,
mimeType: image/png,
fileType: png,
metadataText: 600x600px, 19 kB,
metadata: {
description: PNG File,
pixelHeight: 600,
pixelWidth: 600
},
fileSize: 19430,
type: Image,
version: 1,
_links: {
content: {
method: GET
},
content/slug: {
method: GET
},
delete: {
method: DELETE
},
move: {
method: PUT
},
self: {
method: GET
},
update: {
method: PUT
},
upload: {
method: PUT
}
}
}

47
backend/tools/TestSuite/TestSuite.ApiTests/AssetTests.Should_annote_asset_file_name.verified.txt

@ -0,0 +1,47 @@
{
id: Guid_1,
parentId: Guid_Empty,
fileName: My Image,
fileHash: pAp0RDvipkoNCCTgey1HTJekRKKEWT6Ft5JdRLuAfAc=,
isProtected: false,
slug: logo-squared.png,
mimeType: image/png,
fileType: blob,
metadataText: 600x600px, 19 kB,
metadata: {
description: PNG File,
pixelHeight: 600,
pixelWidth: 600
},
tags: [
type/png,
image,
image/medium
],
fileSize: 19430,
type: Image,
version: 1,
_links: {
content: {
method: GET
},
content/slug: {
method: GET
},
delete: {
method: DELETE
},
move: {
method: PUT
},
self: {
method: GET
},
update: {
method: PUT
},
upload: {
method: PUT
}
}
}

46
backend/tools/TestSuite/TestSuite.ApiTests/AssetTests.Should_annote_asset_metadata.verified.txt

@ -0,0 +1,46 @@
{
id: Guid_1,
parentId: Guid_Empty,
fileName: logo-squared.png,
fileHash: pAp0RDvipkoNCCTgey1HTJekRKKEWT6Ft5JdRLuAfAc=,
isProtected: false,
slug: logo-squared.png,
mimeType: image/png,
fileType: png,
metadataText: 19 kB,
metadata: {
ph: 20,
pw: 100
},
tags: [
type/png,
image,
image/medium
],
fileSize: 19430,
type: Image,
version: 1,
_links: {
content: {
method: GET
},
content/slug: {
method: GET
},
delete: {
method: DELETE
},
move: {
method: PUT
},
self: {
method: GET
},
update: {
method: PUT
},
upload: {
method: PUT
}
}
}

47
backend/tools/TestSuite/TestSuite.ApiTests/AssetTests.Should_annote_asset_slug.verified.txt

@ -0,0 +1,47 @@
{
id: Guid_1,
parentId: Guid_Empty,
fileName: logo-squared.png,
fileHash: pAp0RDvipkoNCCTgey1HTJekRKKEWT6Ft5JdRLuAfAc=,
isProtected: false,
slug: my-image,
mimeType: image/png,
fileType: png,
metadataText: 600x600px, 19 kB,
metadata: {
description: PNG File,
pixelHeight: 600,
pixelWidth: 600
},
tags: [
type/png,
image,
image/medium
],
fileSize: 19430,
type: Image,
version: 1,
_links: {
content: {
method: GET
},
content/slug: {
method: GET
},
delete: {
method: DELETE
},
move: {
method: PUT
},
self: {
method: GET
},
update: {
method: PUT
},
upload: {
method: PUT
}
}
}

46
backend/tools/TestSuite/TestSuite.ApiTests/AssetTests.Should_annote_asset_tags.verified.txt

@ -0,0 +1,46 @@
{
id: Guid_1,
parentId: Guid_Empty,
fileName: logo-squared.png,
fileHash: pAp0RDvipkoNCCTgey1HTJekRKKEWT6Ft5JdRLuAfAc=,
isProtected: false,
slug: logo-squared.png,
mimeType: image/png,
fileType: png,
metadataText: 600x600px, 19 kB,
metadata: {
description: PNG File,
pixelHeight: 600,
pixelWidth: 600
},
tags: [
tag1,
tag2
],
fileSize: 19430,
type: Image,
version: 1,
_links: {
content: {
method: GET
},
content/slug: {
method: GET
},
delete: {
method: DELETE
},
move: {
method: PUT
},
self: {
method: GET
},
update: {
method: PUT
},
upload: {
method: PUT
}
}
}

47
backend/tools/TestSuite/TestSuite.ApiTests/AssetTests.Should_protect_asset.verified.txt

@ -0,0 +1,47 @@
{
id: Guid_1,
parentId: Guid_Empty,
fileName: logo-squared.png,
fileHash: pAp0RDvipkoNCCTgey1HTJekRKKEWT6Ft5JdRLuAfAc=,
isProtected: true,
slug: logo-squared.png,
mimeType: image/png,
fileType: png,
metadataText: 600x600px, 19 kB,
metadata: {
description: PNG File,
pixelHeight: 600,
pixelWidth: 600
},
tags: [
type/png,
image,
image/medium
],
fileSize: 19430,
type: Image,
version: 1,
_links: {
content: {
method: GET
},
content/slug: {
method: GET
},
delete: {
method: DELETE
},
move: {
method: PUT
},
self: {
method: GET
},
update: {
method: PUT
},
upload: {
method: PUT
}
}
}

48
backend/tools/TestSuite/TestSuite.ApiTests/AssetTests.Should_replace_asset.verified.txt

@ -0,0 +1,48 @@
{
id: Guid_1,
parentId: Guid_Empty,
fileName: logo-squared.png,
fileHash: zWbRIMB2AYcz3lddAtaNFB4//qDyuwTwNKuUgKHp0Vc=,
isProtected: false,
slug: logo-squared.png,
mimeType: image/png,
fileType: png,
metadataText: 600x135px, 17.1 kB,
metadata: {
description: PNG File,
pixelHeight: 135,
pixelWidth: 600
},
tags: [
type/png,
image,
image/medium
],
fileSize: 17539,
fileVersion: 1,
type: Image,
version: 1,
_links: {
content: {
method: GET
},
content/slug: {
method: GET
},
delete: {
method: DELETE
},
move: {
method: PUT
},
self: {
method: GET
},
update: {
method: PUT
},
upload: {
method: PUT
}
}
}

46
backend/tools/TestSuite/TestSuite.ApiTests/AssetTests.Should_upload_asset.verified.txt

@ -0,0 +1,46 @@
{
id: Guid_1,
parentId: Guid_Empty,
fileName: logo-squared.png,
fileHash: pAp0RDvipkoNCCTgey1HTJekRKKEWT6Ft5JdRLuAfAc=,
isProtected: false,
slug: logo-squared.png,
mimeType: image/png,
fileType: png,
metadataText: 600x600px, 19 kB,
metadata: {
description: PNG File,
pixelHeight: 600,
pixelWidth: 600
},
tags: [
type/png,
image,
image/medium
],
fileSize: 19430,
type: Image,
_links: {
content: {
method: GET
},
content/slug: {
method: GET
},
delete: {
method: DELETE
},
move: {
method: PUT
},
self: {
method: GET
},
update: {
method: PUT
},
upload: {
method: PUT
}
}
}

46
backend/tools/TestSuite/TestSuite.ApiTests/AssetTests.Should_upload_asset_with_custom_id.verified.txt

@ -0,0 +1,46 @@
{
id: Guid_1,
parentId: Guid_Empty,
fileName: logo-squared.png,
fileHash: pAp0RDvipkoNCCTgey1HTJekRKKEWT6Ft5JdRLuAfAc=,
isProtected: false,
slug: logo-squared.png,
mimeType: image/png,
fileType: png,
metadataText: 600x600px, 19 kB,
metadata: {
description: PNG File,
pixelHeight: 600,
pixelWidth: 600
},
tags: [
type/png,
image,
image/medium
],
fileSize: 19430,
type: Image,
_links: {
content: {
method: GET
},
content/slug: {
method: GET
},
delete: {
method: DELETE
},
move: {
method: PUT
},
self: {
method: GET
},
update: {
method: PUT
},
upload: {
method: PUT
}
}
}

129
backend/tools/TestSuite/TestSuite.ApiTests/AssetTests.cs

@ -8,20 +8,21 @@
using System.Net; using System.Net;
using Squidex.Assets; using Squidex.Assets;
using Squidex.ClientLibrary.Management; using Squidex.ClientLibrary.Management;
using Xunit; using TestSuite.Fixtures;
#pragma warning disable SA1300 // Element should begin with upper-case letter #pragma warning disable SA1300 // Element should begin with upper-case letter
#pragma warning disable SA1507 // Code should not contain multiple blank lines in a row #pragma warning disable SA1507 // Code should not contain multiple blank lines in a row
namespace TestSuite.ApiTests namespace TestSuite.ApiTests
{ {
public class AssetTests : IClassFixture<AssetFixture> [UsesVerify]
public class AssetTests : IClassFixture<CreatedAppFixture>
{ {
private ProgressHandler progress = new ProgressHandler(); private ProgressHandler progress = new ProgressHandler();
public AssetFixture _ { get; } public CreatedAppFixture _ { get; }
public AssetTests(AssetFixture fixture) public AssetTests(CreatedAppFixture fixture)
{ {
_ = fixture; _ = fixture;
} }
@ -30,7 +31,7 @@ namespace TestSuite.ApiTests
public async Task Should_upload_asset() public async Task Should_upload_asset()
{ {
// STEP 1: Create asset // STEP 1: Create asset
var asset_1 = await _.UploadFileAsync("Assets/logo-squared.png", "image/png"); var asset_1 = await _.Assets.UploadFileAsync(_.AppName, "Assets/logo-squared.png", "image/png");
await using (var stream = new FileStream("Assets/logo-squared.png", FileMode.Open)) await using (var stream = new FileStream("Assets/logo-squared.png", FileMode.Open))
{ {
@ -39,6 +40,8 @@ namespace TestSuite.ApiTests
// Should dowload with correct size. // Should dowload with correct size.
Assert.Equal(stream.Length, downloaded.Length); Assert.Equal(stream.Length, downloaded.Length);
} }
await Verify(asset_1);
} }
[Fact] [Fact]
@ -119,9 +122,11 @@ namespace TestSuite.ApiTests
var id = Guid.NewGuid().ToString(); var id = Guid.NewGuid().ToString();
// STEP 1: Create asset // STEP 1: Create asset
var asset_1 = await _.UploadFileAsync("Assets/logo-squared.png", "image/png", id: id); var asset_1 = await _.Assets.UploadFileAsync(_.AppName, "Assets/logo-squared.png", "image/png", id: id);
Assert.Equal(id, asset_1.Id); Assert.Equal(id, asset_1.Id);
await Verify(asset_1);
} }
[Fact] [Fact]
@ -144,13 +149,13 @@ namespace TestSuite.ApiTests
var id = Guid.NewGuid().ToString(); var id = Guid.NewGuid().ToString();
// STEP 1: Create asset // STEP 1: Create asset
await _.UploadFileAsync("Assets/logo-squared.png", "image/png", id: id); await _.Assets.UploadFileAsync(_.AppName, "Assets/logo-squared.png", "image/png", id: id);
// STEP 2: Create a new item with a custom id. // STEP 2: Create a new item with a custom id.
var ex = await Assert.ThrowsAnyAsync<SquidexManagementException>(() => var ex = await Assert.ThrowsAnyAsync<SquidexManagementException>(() =>
{ {
return _.UploadFileAsync("Assets/logo-squared.png", "image/png", id: id); return _.Assets.UploadFileAsync(_.AppName, "Assets/logo-squared.png", "image/png", id: id);
}); });
Assert.Equal(409, ex.StatusCode); Assert.Equal(409, ex.StatusCode);
@ -160,13 +165,13 @@ namespace TestSuite.ApiTests
public async Task Should_not_create_very_big_asset() public async Task Should_not_create_very_big_asset()
{ {
// STEP 1: Create small asset // STEP 1: Create small asset
await _.UploadFileAsync(1_000_000); await _.Assets.UploadFileAsync(_.AppName, 1_000_000);
// STEP 2: Create big asset // STEP 2: Create big asset
var ex = await Assert.ThrowsAnyAsync<Exception>(() => var ex = await Assert.ThrowsAnyAsync<Exception>(() =>
{ {
return _.UploadFileAsync(10_000_000); return _.Assets.UploadFileAsync(_.AppName, 10_000_000);
}); });
// Client library cannot catch this exception properly. // Client library cannot catch this exception properly.
@ -177,11 +182,11 @@ namespace TestSuite.ApiTests
public async Task Should_replace_asset() public async Task Should_replace_asset()
{ {
// STEP 1: Create asset // STEP 1: Create asset
var asset_1 = await _.UploadFileAsync("Assets/logo-squared.png", "image/png"); var asset_1 = await _.Assets.UploadFileAsync(_.AppName, "Assets/logo-squared.png", "image/png");
// STEP 2: Reupload asset // STEP 2: Reupload asset
var asset_2 = await _.UploadFileAsync("Assets/logo-wide.png", asset_1); var asset_2 = await _.Assets.UploadFileAsync(_.AppName, "Assets/logo-wide.png", asset_1);
await using (var stream = new FileStream("Assets/logo-wide.png", FileMode.Open)) await using (var stream = new FileStream("Assets/logo-wide.png", FileMode.Open))
{ {
@ -190,13 +195,15 @@ namespace TestSuite.ApiTests
// Should dowload with correct size. // Should dowload with correct size.
Assert.Equal(stream.Length, downloaded.Length); Assert.Equal(stream.Length, downloaded.Length);
} }
await Verify(asset_2);
} }
[Fact] [Fact]
public async Task Should_replace_asset_using_tus() public async Task Should_replace_asset_using_tus()
{ {
// STEP 1: Create asset // STEP 1: Create asset
var asset_1 = await _.UploadFileAsync("Assets/logo-squared.png", "image/png"); var asset_1 = await _.Assets.UploadFileAsync(_.AppName, "Assets/logo-squared.png", "image/png");
// STEP 2: Reupload asset // STEP 2: Reupload asset
@ -227,7 +234,7 @@ namespace TestSuite.ApiTests
for (var i = 0; i < 5; i++) for (var i = 0; i < 5; i++)
{ {
// STEP 1: Create asset // STEP 1: Create asset
var asset_1 = await _.UploadFileAsync("Assets/logo-squared.png", "image/png"); var asset_1 = await _.Assets.UploadFileAsync(_.AppName, "Assets/logo-squared.png", "image/png");
// STEP 2: Reupload asset // STEP 2: Reupload asset
@ -273,10 +280,31 @@ namespace TestSuite.ApiTests
} }
[Fact] [Fact]
public async Task Should_annote_asset() public async Task Should_annote_asset_file_name()
{
// STEP 1: Create asset
var asset_1 = await _.Assets.UploadFileAsync(_.AppName, "Assets/logo-squared.png", "image/png");
// STEP 2: Annotate file name.
var fileNameRequest = new AnnotateAssetDto
{
FileName = "My Image"
};
var asset_2 = await _.Assets.PutAssetAsync(_.AppName, asset_1.Id, fileNameRequest);
// Should provide updated file name.
Assert.Equal(fileNameRequest.FileName, asset_2.FileName);
await Verify(asset_2);
}
[Fact]
public async Task Should_annote_asset_metadata()
{ {
// STEP 1: Create asset // STEP 1: Create asset
var asset_1 = await _.UploadFileAsync("Assets/logo-squared.png", "image/png"); var asset_1 = await _.Assets.UploadFileAsync(_.AppName, "Assets/logo-squared.png", "image/png");
// STEP 2: Annotate metadata. // STEP 2: Annotate metadata.
@ -294,29 +322,53 @@ namespace TestSuite.ApiTests
// Should provide metadata. // Should provide metadata.
Assert.Equal(metadataRequest.Metadata, asset_2.Metadata); Assert.Equal(metadataRequest.Metadata, asset_2.Metadata);
await Verify(asset_2);
}
[Fact]
public async Task Should_annote_asset_slug()
{
// STEP 1: Create asset
var asset_1 = await _.Assets.UploadFileAsync(_.AppName, "Assets/logo-squared.png", "image/png");
// STEP 3: Annotate slug.
// STEP 2: Annotate slug.
var slugRequest = new AnnotateAssetDto var slugRequest = new AnnotateAssetDto
{ {
Slug = "my-image" Slug = "my-image"
}; };
var asset_3 = await _.Assets.PutAssetAsync(_.AppName, asset_2.Id, slugRequest); var asset_2 = await _.Assets.PutAssetAsync(_.AppName, asset_1.Id, slugRequest);
// Should provide updated slug. // Should provide updated slug.
Assert.Equal(slugRequest.Slug, asset_3.Slug); Assert.Equal(slugRequest.Slug, asset_2.Slug);
await Verify(asset_2);
}
[Fact]
public async Task Should_annote_asset_tags()
{
// STEP 1: Create asset
var asset_1 = await _.Assets.UploadFileAsync(_.AppName, "Assets/logo-squared.png", "image/png");
// STEP 3: Annotate file name.
var fileNameRequest = new AnnotateAssetDto // STEP 2: Annotate tags.
var tagsRequest = new AnnotateAssetDto
{ {
FileName = "My Image" Tags = new List<string>
{
"tag1",
"tag2"
}
}; };
var asset_4 = await _.Assets.PutAssetAsync(_.AppName, asset_3.Id, fileNameRequest); var asset_2 = await _.Assets.PutAssetAsync(_.AppName, asset_1.Id, tagsRequest);
// Should provide updated file name. // Should provide updated tags.
Assert.Equal(fileNameRequest.FileName, asset_4.FileName); Assert.Equal(tagsRequest.Tags, asset_2.Tags);
await Verify(asset_2);
} }
[Fact] [Fact]
@ -336,7 +388,7 @@ namespace TestSuite.ApiTests
// STEP 1: Create asset // STEP 1: Create asset
var asset_1 = await _.UploadFileAsync("Assets/logo-squared.png", "image/png"); var asset_1 = await _.Assets.UploadFileAsync(_.AppName, "Assets/logo-squared.png", "image/png");
var numErrors = 0; var numErrors = 0;
@ -364,7 +416,7 @@ namespace TestSuite.ApiTests
// STEP 3: Make an normal update to ensure nothing is corrupt. // STEP 3: Make an normal update to ensure nothing is corrupt.
await _.Assets.PutAssetAsync(_.AppName, asset_1.Id, metadataRequest); var asset_2 = await _.Assets.PutAssetAsync(_.AppName, asset_1.Id, metadataRequest);
// STEP 4: Check tags // STEP 4: Check tags
@ -374,6 +426,9 @@ namespace TestSuite.ApiTests
Assert.Contains(tag2, tags); Assert.Contains(tag2, tags);
Assert.Equal(1, tags[tag1]); Assert.Equal(1, tags[tag1]);
Assert.Equal(1, tags[tag2]); Assert.Equal(1, tags[tag2]);
await Verify(asset_2)
.IgnoreMember<AssetDto>(x => x.Tags);
} }
[Fact] [Fact]
@ -382,7 +437,7 @@ namespace TestSuite.ApiTests
var fileName = $"{Guid.NewGuid()}.png"; var fileName = $"{Guid.NewGuid()}.png";
// STEP 1: Create asset // STEP 1: Create asset
var asset_1 = await _.UploadFileAsync("Assets/logo-squared.png", "image/png"); var asset_1 = await _.Assets.UploadFileAsync(_.AppName, "Assets/logo-squared.png", "image/png");
// STEP 2: Download asset // STEP 2: Download asset
@ -443,13 +498,15 @@ namespace TestSuite.ApiTests
// Should return 403 when not authenticated. // Should return 403 when not authenticated.
Assert.Equal(HttpStatusCode.Forbidden, ex.StatusCode); Assert.Equal(HttpStatusCode.Forbidden, ex.StatusCode);
} }
await Verify(asset_2);
} }
[Fact] [Fact]
public async Task Should_query_asset_by_metadata() public async Task Should_query_asset_by_metadata()
{ {
// STEP 1: Create asset // STEP 1: Create asset
var asset_1 = await _.UploadFileAsync("Assets/logo-squared.png", "image/png"); var asset_1 = await _.Assets.UploadFileAsync(_.AppName, "Assets/logo-squared.png", "image/png");
// STEP 2: Query asset by pixel width. // STEP 2: Query asset by pixel width.
@ -483,7 +540,7 @@ namespace TestSuite.ApiTests
public async Task Should_query_asset_by_root_folder() public async Task Should_query_asset_by_root_folder()
{ {
// STEP 1: Create asset // STEP 1: Create asset
var asset_1 = await _.UploadFileAsync("Assets/logo-squared.png", "image/png"); var asset_1 = await _.Assets.UploadFileAsync(_.AppName, "Assets/logo-squared.png", "image/png");
// STEP 2: Query asset by root folder. // STEP 2: Query asset by root folder.
@ -508,7 +565,7 @@ namespace TestSuite.ApiTests
// STEP 1: Create asset in folder // STEP 1: Create asset in folder
var asset_1 = await _.UploadFileAsync("Assets/logo-squared.png", "image/png", parentId: folder.Id); var asset_1 = await _.Assets.UploadFileAsync(_.AppName, "Assets/logo-squared.png", "image/png", parentId: folder.Id);
// STEP 2: Query asset by root folder. // STEP 2: Query asset by root folder.
@ -544,11 +601,11 @@ namespace TestSuite.ApiTests
// STEP 3: Create asset in folder // STEP 3: Create asset in folder
var asset_1 = await _.UploadFileAsync("Assets/logo-squared.png", "image/png", null, folder_2.Id); var asset_1 = await _.Assets.UploadFileAsync(_.AppName, "Assets/logo-squared.png", "image/png", null, folder_2.Id);
// STEP 4: Create asset outside folder // STEP 4: Create asset outside folder
var asset_2 = await _.UploadFileAsync("Assets/logo-squared.png", "image/png"); var asset_2 = await _.Assets.UploadFileAsync(_.AppName, "Assets/logo-squared.png", "image/png");
// STEP 5: Delete folder. // STEP 5: Delete folder.
@ -567,7 +624,7 @@ namespace TestSuite.ApiTests
public async Task Should_delete_asset(bool permanent) public async Task Should_delete_asset(bool permanent)
{ {
// STEP 1: Create asset // STEP 1: Create asset
var asset = await _.UploadFileAsync("Assets/logo-squared.png", "image/png"); var asset = await _.Assets.UploadFileAsync(_.AppName, "Assets/logo-squared.png", "image/png");
// STEP 2: Delete asset // STEP 2: Delete asset
@ -603,7 +660,7 @@ namespace TestSuite.ApiTests
public async Task Should_recreate_deleted_asset(bool permanent) public async Task Should_recreate_deleted_asset(bool permanent)
{ {
// STEP 1: Create asset // STEP 1: Create asset
var asset_1 = await _.UploadFileAsync("Assets/logo-squared.png", "image/png"); var asset_1 = await _.Assets.UploadFileAsync(_.AppName, "Assets/logo-squared.png", "image/png");
// STEP 2: Delete asset // STEP 2: Delete asset
@ -611,7 +668,7 @@ namespace TestSuite.ApiTests
// STEP 3: Recreate asset // STEP 3: Recreate asset
var asset_2 = await _.UploadFileAsync("Assets/logo-wide.png", "image/png"); var asset_2 = await _.Assets.UploadFileAsync(_.AppName, "Assets/logo-wide.png", "image/png");
Assert.NotEqual(asset_1.FileSize, asset_2.FileSize); Assert.NotEqual(asset_1.FileSize, asset_2.FileSize);
} }

11
backend/tools/TestSuite/TestSuite.ApiTests/BackupTests.cs

@ -9,7 +9,6 @@ using Squidex.ClientLibrary.Management;
using TestSuite.Fixtures; using TestSuite.Fixtures;
using TestSuite.Model; using TestSuite.Model;
using TestSuite.Utils; using TestSuite.Utils;
using Xunit;
#pragma warning disable SA1300 // Element should begin with upper-case letter #pragma warning disable SA1300 // Element should begin with upper-case letter
#pragma warning disable SA1507 // Code should not contain multiple blank lines in a row #pragma warning disable SA1507 // Code should not contain multiple blank lines in a row
@ -52,7 +51,8 @@ namespace TestSuite.ApiTests
// STEP 3: Create backup // STEP 3: Create backup
await _.Backups.PostBackupAsync(appName); await _.Backups.PostBackupAsync(appName);
var backup = await _.Backups.WaitForBackupAsync(appName, TimeSpan.FromMinutes(2)); var backups = await _.Backups.WaitForBackupsAsync(appName, x => x.Status is JobStatus.Completed or JobStatus.Failed, TimeSpan.FromMinutes(2));
var backup = backups.FirstOrDefault(x => x.Status is JobStatus.Completed or JobStatus.Failed);
Assert.Equal(JobStatus.Completed, backup?.Status); Assert.Equal(JobStatus.Completed, backup?.Status);
@ -71,7 +71,7 @@ namespace TestSuite.ApiTests
// STEP 5: Wait for the backup. // STEP 5: Wait for the backup.
var restore = await _.Backups.WaitForRestoreAsync(uri, TimeSpan.FromMinutes(2)); var restore = await _.Backups.WaitForRestoreAsync(x => x.Url == uri && x.Status is JobStatus.Completed or JobStatus.Failed, TimeSpan.FromMinutes(2));
Assert.Equal(JobStatus.Completed, restore?.Status); Assert.Equal(JobStatus.Completed, restore?.Status);
} }
@ -98,7 +98,8 @@ namespace TestSuite.ApiTests
// STEP 3: Create backup // STEP 3: Create backup
await _.Backups.PostBackupAsync(appName); await _.Backups.PostBackupAsync(appName);
var backup = await _.Backups.WaitForBackupAsync(appName, TimeSpan.FromMinutes(2)); var backups = await _.Backups.WaitForBackupsAsync(appName, x => x.Status is JobStatus.Completed or JobStatus.Failed, TimeSpan.FromMinutes(2));
var backup = backups.FirstOrDefault(x => x.Status is JobStatus.Completed or JobStatus.Failed);
Assert.Equal(JobStatus.Completed, backup?.Status); Assert.Equal(JobStatus.Completed, backup?.Status);
@ -121,7 +122,7 @@ namespace TestSuite.ApiTests
// STEP 6: Wait for the backup. // STEP 6: Wait for the backup.
var restore = await _.Backups.WaitForRestoreAsync(uri, TimeSpan.FromMinutes(2)); var restore = await _.Backups.WaitForRestoreAsync(x => x.Url == uri && x.Status is JobStatus.Completed or JobStatus.Failed, TimeSpan.FromMinutes(2));
Assert.Equal(JobStatus.Completed, restore?.Status); Assert.Equal(JobStatus.Completed, restore?.Status);
} }

1
backend/tools/TestSuite/TestSuite.ApiTests/CDNTests.cs

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

8
backend/tools/TestSuite/TestSuite.ApiTests/CommentsTests.Should_create_comment.verified.txt

@ -0,0 +1,8 @@
{
createdComments: [
{
id: Guid_1,
user: client:root
}
]
}

6
backend/tools/TestSuite/TestSuite.ApiTests/CommentsTests.Should_delete_comment.verified.txt

@ -0,0 +1,6 @@
{
deletedComments: [
Guid_1
],
version: 1
}

9
backend/tools/TestSuite/TestSuite.ApiTests/CommentsTests.Should_update_comment.verified.txt

@ -0,0 +1,9 @@
{
updatedComments: [
{
id: Guid_1,
user: client:root
}
],
version: 1
}

11
backend/tools/TestSuite/TestSuite.ApiTests/CommentsTests.cs

@ -7,13 +7,13 @@
using Squidex.ClientLibrary.Management; using Squidex.ClientLibrary.Management;
using TestSuite.Fixtures; using TestSuite.Fixtures;
using Xunit;
#pragma warning disable SA1300 // Element should begin with upper-case letter #pragma warning disable SA1300 // Element should begin with upper-case letter
#pragma warning disable SA1507 // Code should not contain multiple blank lines in a row #pragma warning disable SA1507 // Code should not contain multiple blank lines in a row
namespace TestSuite.ApiTests namespace TestSuite.ApiTests
{ {
[UsesVerify]
public class CommentsTests : IClassFixture<CreatedAppFixture> public class CommentsTests : IClassFixture<CreatedAppFixture>
{ {
private readonly string resource = Guid.NewGuid().ToString(); private readonly string resource = Guid.NewGuid().ToString();
@ -49,6 +49,9 @@ namespace TestSuite.ApiTests
var comments = await _.Comments.GetCommentsAsync(_.AppName, resource); var comments = await _.Comments.GetCommentsAsync(_.AppName, resource);
Assert.Contains(comments.CreatedComments, x => x.Text == createRequest.Text); Assert.Contains(comments.CreatedComments, x => x.Text == createRequest.Text);
await Verify(comments)
.IgnoreMember<CommentDto>(x => x.Text);
} }
[Fact] [Fact]
@ -76,6 +79,9 @@ namespace TestSuite.ApiTests
var comments = await _.Comments.GetCommentsAsync(_.AppName, resource, 0); var comments = await _.Comments.GetCommentsAsync(_.AppName, resource, 0);
Assert.Contains(comments.UpdatedComments, x => x.Text == updateRequest.Text); Assert.Contains(comments.UpdatedComments, x => x.Text == updateRequest.Text);
await Verify(comments)
.IgnoreMember<CommentDto>(x => x.Text);
} }
[Fact] [Fact]
@ -98,6 +104,9 @@ namespace TestSuite.ApiTests
var comments = await _.Comments.GetCommentsAsync(_.AppName, resource, 0); var comments = await _.Comments.GetCommentsAsync(_.AppName, resource, 0);
Assert.Contains(comment.Id, comments.DeletedComments); Assert.Contains(comment.Id, comments.DeletedComments);
await Verify(comments)
.IgnoreMember<CommentDto>(x => x.Text);
} }
} }
} }

1
backend/tools/TestSuite/TestSuite.ApiTests/ContentCleanupTests.cs

@ -8,7 +8,6 @@
using Squidex.ClientLibrary; using Squidex.ClientLibrary;
using TestSuite.Fixtures; using TestSuite.Fixtures;
using TestSuite.Model; using TestSuite.Model;
using Xunit;
#pragma warning disable SA1300 // Element should begin with upper-case letter #pragma warning disable SA1300 // Element should begin with upper-case letter
#pragma warning disable SA1507 // Code should not contain multiple blank lines in a row #pragma warning disable SA1507 // Code should not contain multiple blank lines in a row

1
backend/tools/TestSuite/TestSuite.ApiTests/ContentLanguageTests.cs

@ -7,7 +7,6 @@
using Squidex.ClientLibrary; using Squidex.ClientLibrary;
using TestSuite.Model; using TestSuite.Model;
using Xunit;
#pragma warning disable SA1300 // Element should begin with upper-case letter #pragma warning disable SA1300 // Element should begin with upper-case letter
#pragma warning disable SA1507 // Code should not contain multiple blank lines in a row #pragma warning disable SA1507 // Code should not contain multiple blank lines in a row

99
backend/tools/TestSuite/TestSuite.ApiTests/ContentQueryTests.cs

@ -9,7 +9,6 @@ using Newtonsoft.Json;
using Newtonsoft.Json.Linq; using Newtonsoft.Json.Linq;
using Squidex.ClientLibrary; using Squidex.ClientLibrary;
using TestSuite.Model; using TestSuite.Model;
using Xunit;
#pragma warning disable SA1300 // Element should begin with upper-case letter #pragma warning disable SA1300 // Element should begin with upper-case letter
@ -251,23 +250,11 @@ namespace TestSuite.ApiTests
[Fact] [Fact]
public async Task Should_return_items_by_full_text_with_odata() public async Task Should_return_items_by_full_text_with_odata()
{ {
var q = new ContentQuery { Search = "1" }; var q = new ContentQuery { Search = "2" };
// Query multiple times to wait for async text indexer. var items = await _.Contents.WaitForContentAsync(q, x => true, TimeSpan.FromSeconds(30));
for (var i = 0; i < 10; i++)
{
await Task.Delay(500);
var items = await _.Contents.GetAsync(q);
if (items.Items.Any())
{
AssertItems(items, 1, new[] { 1 });
return;
}
}
Assert.False(true); AssertItems(items, 1, new[] { 2 });
} }
[Fact] [Fact]
@ -281,21 +268,9 @@ namespace TestSuite.ApiTests
} }
}; };
// Query multiple times to wait for async text indexer. var items = await _.Contents.WaitForContentAsync(q, x => true, TimeSpan.FromSeconds(30));
for (var i = 0; i < 10; i++)
{
await Task.Delay(500);
var items = await _.Contents.GetAsync(q);
if (items.Items.Any()) AssertItems(items, 1, new[] { 2 });
{
AssertItems(items, 1, new[] { 2 });
return;
}
}
Assert.False(true);
} }
[Fact] [Fact]
@ -303,21 +278,9 @@ namespace TestSuite.ApiTests
{ {
var q = new ContentQuery { Filter = "geo.distance(data/geo/iv, geography'POINT(3 3)') lt 1000" }; var q = new ContentQuery { Filter = "geo.distance(data/geo/iv, geography'POINT(3 3)') lt 1000" };
// Query multiple times to wait for async text indexer. var items = await _.Contents.WaitForContentAsync(q, x => true, TimeSpan.FromSeconds(30));
for (var i = 0; i < 20; i++)
{
await Task.Delay(500);
var items = await _.Contents.GetAsync(q);
if (items.Items.Any())
{
AssertItems(items, 1, new[] { 3 });
return;
}
}
Assert.False(true); AssertItems(items, 1, new[] { 3 });
} }
[Fact] [Fact]
@ -341,21 +304,9 @@ namespace TestSuite.ApiTests
} }
}; };
// Query multiple times to wait for async text indexer. var items = await _.Contents.WaitForContentAsync(q, x => true, TimeSpan.FromSeconds(30));
for (var i = 0; i < 20; i++)
{
await Task.Delay(500);
var items = await _.Contents.GetAsync(q);
if (items.Items.Any())
{
AssertItems(items, 1, new[] { 3 });
return;
}
}
Assert.False(true); AssertItems(items, 1, new[] { 3 });
} }
[Fact] [Fact]
@ -363,21 +314,9 @@ namespace TestSuite.ApiTests
{ {
var q = new ContentQuery { Filter = "geo.distance(data/geo/iv, geography'POINT(4 4)') lt 1000" }; var q = new ContentQuery { Filter = "geo.distance(data/geo/iv, geography'POINT(4 4)') lt 1000" };
// Query multiple times to wait for async text indexer. var items = await _.Contents.WaitForContentAsync(q, x => true, TimeSpan.FromSeconds(30));
for (var i = 0; i < 10; i++)
{
await Task.Delay(500);
var items = await _.Contents.GetAsync(q); AssertItems(items, 1, new[] { 4 });
if (items.Items.Any())
{
AssertItems(items, 1, new[] { 4 });
return;
}
}
Assert.False(true);
} }
[Fact] [Fact]
@ -401,21 +340,9 @@ namespace TestSuite.ApiTests
} }
}; };
// Query multiple times to wait for async text indexer. var items = await _.Contents.WaitForContentAsync(q, x => true, TimeSpan.FromSeconds(30));
for (var i = 0; i < 10; i++)
{
await Task.Delay(500);
var items = await _.Contents.GetAsync(q);
if (items.Items.Any())
{
AssertItems(items, 1, new[] { 4 });
return;
}
}
Assert.False(true); AssertItems(items, 1, new[] { 4 });
} }
[Fact] [Fact]

1
backend/tools/TestSuite/TestSuite.ApiTests/ContentReferencesTests.cs

@ -7,7 +7,6 @@
using Squidex.ClientLibrary; using Squidex.ClientLibrary;
using TestSuite.Model; using TestSuite.Model;
using Xunit;
#pragma warning disable SA1300 // Element should begin with upper-case letter #pragma warning disable SA1300 // Element should begin with upper-case letter
#pragma warning disable SA1507 // Code should not contain multiple blank lines in a row #pragma warning disable SA1507 // Code should not contain multiple blank lines in a row

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

@ -9,7 +9,6 @@ using Squidex.ClientLibrary;
using Squidex.ClientLibrary.Management; using Squidex.ClientLibrary.Management;
using TestSuite.Fixtures; using TestSuite.Fixtures;
using TestSuite.Model; using TestSuite.Model;
using Xunit;
#pragma warning disable SA1300 // Element should begin with upper-case letter #pragma warning disable SA1300 // Element should begin with upper-case letter
#pragma warning disable SA1507 // Code should not contain multiple blank lines in a row #pragma warning disable SA1507 // Code should not contain multiple blank lines in a row

17
backend/tools/TestSuite/TestSuite.ApiTests/ContentUpdateTests.Should_create_non_published_content.verified.txt

@ -0,0 +1,17 @@
{
Data: {
Number: {
iv: 1
}
},
Status: Draft,
Id: Guid_1,
_links: {
delete: {
Method: DELETE
},
self: {
Method: GET
}
}
}

26
backend/tools/TestSuite/TestSuite.ApiTests/ContentUpdateTests.Should_create_null_text.verified.txt

@ -0,0 +1,26 @@
{
Data: {
Localized: {
custom: default,
de: default,
en: null
}
},
Status: Published,
Id: Guid_1,
Version: 1,
_links: {
delete: {
Method: DELETE
},
draft/create: {
Method: POST
},
previous: {
Method: GET
},
self: {
Method: GET
}
}
}

24
backend/tools/TestSuite/TestSuite.ApiTests/ContentUpdateTests.Should_create_strange_text.verified.txt

@ -0,0 +1,24 @@
{
Data: {
String: {
iv: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.88 Safari/537.36
}
},
Status: Published,
Id: Guid_1,
Version: 1,
_links: {
delete: {
Method: DELETE
},
draft/create: {
Method: POST
},
previous: {
Method: GET
},
self: {
Method: GET
}
}
}

5
backend/tools/TestSuite/TestSuite.ApiTests/ContentUpdateTests.Should_get_content_by_version.verified.txt

@ -0,0 +1,5 @@
{
Number: {
iv: 1
}
}

27
backend/tools/TestSuite/TestSuite.ApiTests/ContentUpdateTests.Should_patch_content.verified.txt

@ -0,0 +1,27 @@
{
Data: {
Number: {
iv: 2
},
String: {
iv: test
}
},
Status: Published,
Id: Guid_1,
Version: 3,
_links: {
delete: {
Method: DELETE
},
draft/create: {
Method: POST
},
previous: {
Method: GET
},
self: {
Method: GET
}
}
}

20
backend/tools/TestSuite/TestSuite.ApiTests/ContentUpdateTests.Should_patch_content_to_null.verified.txt

@ -0,0 +1,20 @@
{
Data: {},
Status: Published,
Id: Guid_1,
Version: 2,
_links: {
delete: {
Method: DELETE
},
draft/create: {
Method: POST
},
previous: {
Method: GET
},
self: {
Method: GET
}
}
}

27
backend/tools/TestSuite/TestSuite.ApiTests/ContentUpdateTests.Should_patch_content_with_bulk.verified.txt

@ -0,0 +1,27 @@
{
Data: {
Number: {
iv: 2
},
String: {
iv: test
}
},
Status: Published,
Id: Guid_1,
Version: 3,
_links: {
delete: {
Method: DELETE
},
draft/create: {
Method: POST
},
previous: {
Method: GET
},
self: {
Method: GET
}
}
}

27
backend/tools/TestSuite/TestSuite.ApiTests/ContentUpdateTests.Should_patch_content_with_upsert.verified.txt

@ -0,0 +1,27 @@
{
Data: {
Number: {
iv: 2
},
String: {
iv: test
}
},
Status: Published,
Id: Guid_1,
Version: 3,
_links: {
delete: {
Method: DELETE
},
draft/create: {
Method: POST
},
previous: {
Method: GET
},
self: {
Method: GET
}
}
}

24
backend/tools/TestSuite/TestSuite.ApiTests/ContentUpdateTests.Should_patch_id_data_value.verified.txt

@ -0,0 +1,24 @@
{
Data: {
Id: {
iv: id2
}
},
Status: Published,
Id: Guid_1,
Version: 2,
_links: {
delete: {
Method: DELETE
},
draft/create: {
Method: POST
},
previous: {
Method: GET
},
self: {
Method: GET
}
}
}

40
backend/tools/TestSuite/TestSuite.ApiTests/ContentUpdateTests.Should_recreate_deleted_content.verified.txt

@ -0,0 +1,40 @@
{
Items: [
{
Data: {
Number: {
iv: 2
}
},
Status: Published,
Id: Guid_1,
Version: 4,
_links: {
delete: {
Method: DELETE
},
draft/create: {
Method: POST
},
previous: {
Method: GET
},
self: {
Method: GET
}
}
}
],
Total: 1,
_links: {
create: {
Method: POST
},
create/publish: {
Method: POST
},
self: {
Method: GET
}
}
}

40
backend/tools/TestSuite/TestSuite.ApiTests/ContentUpdateTests.Should_recreate_deleted_content_with_upsert.verified.txt

@ -0,0 +1,40 @@
{
Items: [
{
Data: {
Number: {
iv: 2
}
},
Status: Published,
Id: Guid_1,
Version: 1,
_links: {
delete: {
Method: DELETE
},
draft/create: {
Method: POST
},
previous: {
Method: GET
},
self: {
Method: GET
}
}
}
],
Total: 1,
_links: {
create: {
Method: POST
},
create/publish: {
Method: POST
},
self: {
Method: GET
}
}
}

21
backend/tools/TestSuite/TestSuite.ApiTests/ContentUpdateTests.Should_update_singleton_content_with_special_id.verified.txt

@ -0,0 +1,21 @@
{
Data: {
my-field: {
iv: singleton
}
},
Status: Published,
Id: Guid_1,
Version: 2,
_links: {
draft/create: {
Method: POST
},
previous: {
Method: GET
},
self: {
Method: GET
}
}
}

22
backend/tools/TestSuite/TestSuite.ApiTests/ContentUpdateTests.cs

@ -9,7 +9,6 @@ using Newtonsoft.Json.Linq;
using Squidex.ClientLibrary; using Squidex.ClientLibrary;
using Squidex.ClientLibrary.Management; using Squidex.ClientLibrary.Management;
using TestSuite.Model; using TestSuite.Model;
using Xunit;
#pragma warning disable CS0618 // Type or member is obsolete #pragma warning disable CS0618 // Type or member is obsolete
#pragma warning disable SA1300 // Element should begin with upper-case letter #pragma warning disable SA1300 // Element should begin with upper-case letter
@ -17,6 +16,7 @@ using Xunit;
namespace TestSuite.ApiTests namespace TestSuite.ApiTests
{ {
[UsesVerify]
public class ContentUpdateTests : IClassFixture<ContentFixture> public class ContentUpdateTests : IClassFixture<ContentFixture>
{ {
public ContentFixture _ { get; } public ContentFixture _ { get; }
@ -139,6 +139,8 @@ namespace TestSuite.ApiTests
var updated = await _.Contents.GetAsync(content.Id); var updated = await _.Contents.GetAsync(content.Id);
Assert.Equal(text, updated.Data.String); Assert.Equal(text, updated.Data.String);
await Verify(updated);
} }
finally finally
{ {
@ -169,6 +171,8 @@ namespace TestSuite.ApiTests
var updated = await _.Contents.GetAsync(content.Id, QueryContext.Default.IgnoreFallback()); var updated = await _.Contents.GetAsync(content.Id, QueryContext.Default.IgnoreFallback());
Assert.Null(updated.Data.Localized["en"]); Assert.Null(updated.Data.Localized["en"]);
await Verify(updated);
} }
finally finally
{ {
@ -221,6 +225,8 @@ namespace TestSuite.ApiTests
{ {
return _.Contents.GetAsync(content.Id); return _.Contents.GetAsync(content.Id);
}); });
await Verify(content);
} }
finally finally
{ {
@ -519,6 +525,8 @@ namespace TestSuite.ApiTests
// Should not change other value with patch. // Should not change other value with patch.
Assert.Equal("test", updated.Data.String); Assert.Equal("test", updated.Data.String);
await Verify(updated);
} }
finally finally
{ {
@ -545,6 +553,8 @@ namespace TestSuite.ApiTests
var updated = await _.Contents.GetAsync(content.Id); var updated = await _.Contents.GetAsync(content.Id);
Assert.Equal("id2", updated.Data.Id); Assert.Equal("id2", updated.Data.Id);
await Verify(updated);
} }
finally finally
{ {
@ -571,6 +581,8 @@ namespace TestSuite.ApiTests
var updated = await _.Contents.GetAsync(content.Id); var updated = await _.Contents.GetAsync(content.Id);
Assert.Null(updated.Data.String); Assert.Null(updated.Data.String);
await Verify(updated);
} }
finally finally
{ {
@ -604,6 +616,8 @@ namespace TestSuite.ApiTests
// Should not change other value with patch. // Should not change other value with patch.
Assert.Equal("test", updated.Data.String); Assert.Equal("test", updated.Data.String);
await Verify(updated);
} }
finally finally
{ {
@ -671,6 +685,8 @@ namespace TestSuite.ApiTests
// Should not change other value with patch. // Should not change other value with patch.
Assert.Equal("test", updated.Data.String); Assert.Equal("test", updated.Data.String);
await Verify(updated);
} }
finally finally
{ {
@ -857,6 +873,8 @@ namespace TestSuite.ApiTests
}); });
Assert.Equal("singleton", content_2.Data["my-field"]["iv"]); Assert.Equal("singleton", content_2.Data["my-field"]["iv"]);
await Verify(content_2);
} }
[Fact] [Fact]
@ -889,6 +907,8 @@ namespace TestSuite.ApiTests
var data_1 = await _.Contents.GetDataAsync(content.Id, content.Version - 1); var data_1 = await _.Contents.GetDataAsync(content.Id, content.Version - 1);
Assert.Equal(1, data_1.Number); Assert.Equal(1, data_1.Number);
await Verify(data_1);
} }
finally finally
{ {

29
backend/tools/TestSuite/TestSuite.ApiTests/DiagnosticsTests.cs

@ -0,0 +1,29 @@
// ==========================================================================
// Squidex Headless CMS
// ==========================================================================
// Copyright (c) Squidex UG (haftungsbeschraenkt)
// All rights reserved. Licensed under the MIT license.
// ==========================================================================
using TestSuite.Fixtures;
#pragma warning disable SA1300 // Element should begin with upper-case letter
namespace TestSuite.ApiTests
{
public class DiagnosticsTests : IClassFixture<CreatedAppFixture>
{
public CreatedAppFixture _ { get; }
public DiagnosticsTests(CreatedAppFixture fixture)
{
_ = fixture;
}
[Fact]
public async Task Should_create_gc_dump()
{
await _.Diagnostics.GetGCDumpAsync();
}
}
}

1
backend/tools/TestSuite/TestSuite.ApiTests/FrontendTests.cs

@ -8,7 +8,6 @@
using Codeuctivity.ImageSharpCompare; using Codeuctivity.ImageSharpCompare;
using PuppeteerSharp; using PuppeteerSharp;
using TestSuite.Fixtures; using TestSuite.Fixtures;
using Xunit;
#pragma warning disable SA1300 // Element should begin with upper-case letter #pragma warning disable SA1300 // Element should begin with upper-case letter

1
backend/tools/TestSuite/TestSuite.ApiTests/GraphQLTests.cs

@ -9,7 +9,6 @@ using Newtonsoft.Json.Linq;
using Squidex.ClientLibrary; using Squidex.ClientLibrary;
using Squidex.ClientLibrary.Management; using Squidex.ClientLibrary.Management;
using TestSuite.Model; using TestSuite.Model;
using Xunit;
#pragma warning disable SA1300 // Element should begin with upper-case letter #pragma warning disable SA1300 // Element should begin with upper-case letter
#pragma warning disable SA1507 // Code should not contain multiple blank lines in a row #pragma warning disable SA1507 // Code should not contain multiple blank lines in a row

31
backend/tools/TestSuite/TestSuite.ApiTests/HistoryTests.cs

@ -0,0 +1,31 @@
// ==========================================================================
// Squidex Headless CMS
// ==========================================================================
// Copyright (c) Squidex UG (haftungsbeschraenkt)
// All rights reserved. Licensed under the MIT license.
// ==========================================================================
using TestSuite.Fixtures;
#pragma warning disable SA1300 // Element should begin with upper-case letter
namespace TestSuite.ApiTests
{
public class HistoryTests : IClassFixture<CreatedAppFixture>
{
public CreatedAppFixture _ { get; }
public HistoryTests(CreatedAppFixture fixture)
{
_ = fixture;
}
[Fact]
public async Task Should_get_history()
{
var history = await _.History.WaitForHistoryAsync(_.AppName, null, x => true, TimeSpan.FromSeconds(30));
Assert.NotEmpty(history);
}
}
}

1
backend/tools/TestSuite/TestSuite.ApiTests/LanguagesTests.cs

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

1
backend/tools/TestSuite/TestSuite.ApiTests/OpenApiTests.cs

@ -6,7 +6,6 @@
// ========================================================================== // ==========================================================================
using NSwag; using NSwag;
using Xunit;
#pragma warning disable SA1300 // Element should begin with upper-case letter #pragma warning disable SA1300 // Element should begin with upper-case letter

1
backend/tools/TestSuite/TestSuite.ApiTests/PingTests.cs

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

31
backend/tools/TestSuite/TestSuite.ApiTests/PlansTests.cs

@ -0,0 +1,31 @@
// ==========================================================================
// Squidex Headless CMS
// ==========================================================================
// Copyright (c) Squidex UG (haftungsbeschraenkt)
// All rights reserved. Licensed under the MIT license.
// ==========================================================================
using TestSuite.Fixtures;
#pragma warning disable SA1300 // Element should begin with upper-case letter
namespace TestSuite.ApiTests
{
public class PlansTests : IClassFixture<CreatedAppFixture>
{
public CreatedAppFixture _ { get; }
public PlansTests(CreatedAppFixture fixture)
{
_ = fixture;
}
[Fact]
public async Task Should_get_plans()
{
var plans = await _.Plans.GetPlansAsync(_.AppName);
Assert.NotNull(plans);
}
}
}

1
backend/tools/TestSuite/TestSuite.ApiTests/RuleRunnerTests.cs

@ -8,7 +8,6 @@
using Squidex.ClientLibrary.Management; using Squidex.ClientLibrary.Management;
using TestSuite.Fixtures; using TestSuite.Fixtures;
using TestSuite.Model; using TestSuite.Model;
using Xunit;
#pragma warning disable SA1300 // Element should begin with upper-case letter #pragma warning disable SA1300 // Element should begin with upper-case letter
#pragma warning disable SA1507 // Code should not contain multiple blank lines in a row #pragma warning disable SA1507 // Code should not contain multiple blank lines in a row

29
backend/tools/TestSuite/TestSuite.ApiTests/RuleTests.Should_create_rule.verified.txt

@ -0,0 +1,29 @@
{
id: Guid_1,
isEnabled: true,
trigger: {
triggerType: ContentChanged,
handleAll: true
},
action: {
actionType: Webhook,
url: http://squidex.io
},
_links: {
delete: {
method: DELETE
},
disable: {
method: PUT
},
logs: {
method: GET
},
trigger: {
method: PUT
},
update: {
method: PUT
}
}
}

31
backend/tools/TestSuite/TestSuite.ApiTests/RuleTests.Should_update_rule.verified.txt

@ -0,0 +1,31 @@
{
id: Guid_1,
version: 1,
isEnabled: true,
name: Guid_2,
trigger: {
triggerType: ContentChanged,
handleAll: true
},
action: {
actionType: Webhook,
url: http://squidex.io
},
_links: {
delete: {
method: DELETE
},
disable: {
method: PUT
},
logs: {
method: GET
},
trigger: {
method: PUT
},
update: {
method: PUT
}
}
}

6
backend/tools/TestSuite/TestSuite.ApiTests/RuleTests.cs

@ -7,13 +7,13 @@
using Squidex.ClientLibrary.Management; using Squidex.ClientLibrary.Management;
using TestSuite.Fixtures; using TestSuite.Fixtures;
using Xunit;
#pragma warning disable SA1300 // Element should begin with upper-case letter #pragma warning disable SA1300 // Element should begin with upper-case letter
#pragma warning disable SA1507 // Code should not contain multiple blank lines in a row #pragma warning disable SA1507 // Code should not contain multiple blank lines in a row
namespace TestSuite.ApiTests namespace TestSuite.ApiTests
{ {
[UsesVerify]
public class RuleTests : IClassFixture<ClientFixture> public class RuleTests : IClassFixture<ClientFixture>
{ {
private readonly string appName = Guid.NewGuid().ToString(); private readonly string appName = Guid.NewGuid().ToString();
@ -52,6 +52,8 @@ namespace TestSuite.ApiTests
var rule = await _.Rules.PostRuleAsync(appName, createRule); var rule = await _.Rules.PostRuleAsync(appName, createRule);
Assert.IsType<WebhookRuleActionDto>(rule.Action); Assert.IsType<WebhookRuleActionDto>(rule.Action);
await Verify(rule);
} }
[Fact] [Fact]
@ -89,6 +91,8 @@ namespace TestSuite.ApiTests
var rule_1 = await _.Rules.PutRuleAsync(appName, rule_0.Id, updateRequest); var rule_1 = await _.Rules.PutRuleAsync(appName, rule_0.Id, updateRequest);
Assert.Equal(ruleName, rule_1.Name); Assert.Equal(ruleName, rule_1.Name);
await Verify(rule_1);
} }
[Fact] [Fact]

50
backend/tools/TestSuite/TestSuite.ApiTests/SchemaTests.Should_create_singleton_schema.verified.txt

@ -0,0 +1,50 @@
{
id: Guid_1,
type: Singleton,
properties: {
validateOnPublish: false
},
isPublished: true,
scripts: {},
_links: {
contents: {
method: GET
},
delete: {
method: DELETE
},
fields/add: {
method: POST
},
fields/order: {
method: PUT
},
fields/ui: {
method: PUT
},
self: {
method: GET
},
unpublish: {
method: PUT
},
update: {
method: PUT
},
update/category: {
method: PUT
},
update/rules: {
method: PUT
},
update/scripts: {
method: PUT
},
update/sync: {
method: PUT
},
update/urls: {
method: PUT
}
}
}

50
backend/tools/TestSuite/TestSuite.ApiTests/SchemaTests.Should_create_singleton_schema_with_obsolete_property.verified.txt

@ -0,0 +1,50 @@
{
id: Guid_1,
type: Singleton,
properties: {
validateOnPublish: false
},
isPublished: true,
scripts: {},
_links: {
contents: {
method: GET
},
delete: {
method: DELETE
},
fields/add: {
method: POST
},
fields/order: {
method: PUT
},
fields/ui: {
method: PUT
},
self: {
method: GET
},
unpublish: {
method: PUT
},
update: {
method: PUT
},
update/category: {
method: PUT
},
update/rules: {
method: PUT
},
update/scripts: {
method: PUT
},
update/sync: {
method: PUT
},
update/urls: {
method: PUT
}
}
}

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

Loading…
Cancel
Save