diff --git a/.dockerignore b/.dockerignore index 6ec863bb3..3bdda5d2b 100644 --- a/.dockerignore +++ b/.dockerignore @@ -3,6 +3,7 @@ *.user *.vs *.log +*.received.txt .vs .git diff --git a/backend/src/Squidex/Areas/Api/Controllers/Backups/BackupsController.cs b/backend/src/Squidex/Areas/Api/Controllers/Backups/BackupsController.cs index 33810a14f..5c945ccc1 100644 --- a/backend/src/Squidex/Areas/Api/Controllers/Backups/BackupsController.cs +++ b/backend/src/Squidex/Areas/Api/Controllers/Backups/BackupsController.cs @@ -63,7 +63,7 @@ namespace Squidex.Areas.Api.Controllers.Backups /// [HttpPost] [Route("apps/{app}/backups/")] - [ProducesResponseType(typeof(List), StatusCodes.Status200OK)] + [ProducesResponseType(typeof(BackupJobDto[]), StatusCodes.Status200OK)] [ApiPermissionOrAnonymous(Permissions.AppBackupsCreate)] [ApiCosts(0)] public async Task PostBackup(string app) @@ -84,7 +84,7 @@ namespace Squidex.Areas.Api.Controllers.Backups /// [HttpDelete] [Route("apps/{app}/backups/{id}")] - [ProducesResponseType(typeof(List), StatusCodes.Status200OK)] + [ProducesResponseType(typeof(BackupJobDto[]), StatusCodes.Status200OK)] [ApiPermissionOrAnonymous(Permissions.AppBackupsDelete)] [ApiCosts(0)] public async Task DeleteBackup(string app, DomainId id) diff --git a/backend/src/Squidex/Areas/Api/Controllers/History/HistoryController.cs b/backend/src/Squidex/Areas/Api/Controllers/History/HistoryController.cs index ebd88b053..8153313ca 100644 --- a/backend/src/Squidex/Areas/Api/Controllers/History/HistoryController.cs +++ b/backend/src/Squidex/Areas/Api/Controllers/History/HistoryController.cs @@ -39,7 +39,7 @@ namespace Squidex.Areas.Api.Controllers.History /// [HttpGet] [Route("apps/{app}/history/")] - [ProducesResponseType(typeof(HistoryEventDto), StatusCodes.Status200OK)] + [ProducesResponseType(typeof(HistoryEventDto[]), StatusCodes.Status200OK)] [ApiPermissionOrAnonymous(Permissions.AppHistory)] [ApiCosts(0.1)] public async Task GetHistory(string app, string channel) diff --git a/backend/src/Squidex/Areas/Api/Controllers/Rules/RulesController.cs b/backend/src/Squidex/Areas/Api/Controllers/Rules/RulesController.cs index 6f3f26986..aad3c8204 100644 --- a/backend/src/Squidex/Areas/Api/Controllers/Rules/RulesController.cs +++ b/backend/src/Squidex/Areas/Api/Controllers/Rules/RulesController.cs @@ -466,7 +466,7 @@ namespace Squidex.Areas.Api.Controllers.Rules /// [HttpGet] [Route("rules/eventtypes")] - [ProducesResponseType(typeof(List), StatusCodes.Status200OK)] + [ProducesResponseType(typeof(string[]), StatusCodes.Status200OK)] [AllowAnonymous] public IActionResult GetEventTypes() { diff --git a/backend/tools/TestSuite/TestSuite.ApiTests/AnonymousTests.Should_create_app_with_anonymous_read_access.verified.txt b/backend/tools/TestSuite/TestSuite.ApiTests/AnonymousTests.Should_create_app_with_anonymous_read_access.verified.txt new file mode 100644 index 000000000..3369044ef --- /dev/null +++ b/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 + } + } +} \ No newline at end of file diff --git a/backend/tools/TestSuite/TestSuite.ApiTests/AnonymousTests.Should_create_app_with_anonymous_write_access.verified.txt b/backend/tools/TestSuite/TestSuite.ApiTests/AnonymousTests.Should_create_app_with_anonymous_write_access.verified.txt new file mode 100644 index 000000000..3369044ef --- /dev/null +++ b/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 + } + } +} \ No newline at end of file diff --git a/backend/tools/TestSuite/TestSuite.ApiTests/AnonymousTests.cs b/backend/tools/TestSuite/TestSuite.ApiTests/AnonymousTests.cs index 2429d3173..6ebf1c6b2 100644 --- a/backend/tools/TestSuite/TestSuite.ApiTests/AnonymousTests.cs +++ b/backend/tools/TestSuite/TestSuite.ApiTests/AnonymousTests.cs @@ -8,13 +8,13 @@ using System.Net; using Squidex.ClientLibrary.Management; using TestSuite.Fixtures; -using Xunit; #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 namespace TestSuite.ApiTests { + [UsesVerify] public class AnonymousTests : IClassFixture { public ClientFixture _ { get; } @@ -59,6 +59,8 @@ namespace TestSuite.ApiTests Assert.Equal(HttpStatusCode.OK, response.StatusCode); } + + await Verify(app); } [Fact] @@ -107,6 +109,8 @@ namespace TestSuite.ApiTests Assert.Equal(HttpStatusCode.Created, response.StatusCode); } + + await Verify(app); } } } diff --git a/backend/tools/TestSuite/TestSuite.ApiTests/AppClientsTests.Should_create_client.verified.txt b/backend/tools/TestSuite/TestSuite.ApiTests/AppClientsTests.Should_create_client.verified.txt new file mode 100644 index 000000000..5e46b9b10 --- /dev/null +++ b/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 + } + } +} \ No newline at end of file diff --git a/backend/tools/TestSuite/TestSuite.ApiTests/AppClientsTests.Should_delete_client.verified.txt b/backend/tools/TestSuite/TestSuite.ApiTests/AppClientsTests.Should_delete_client.verified.txt new file mode 100644 index 000000000..92220ce20 --- /dev/null +++ b/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 + } + } +} \ No newline at end of file diff --git a/backend/tools/TestSuite/TestSuite.ApiTests/AppClientsTests.Should_update_client.verified.txt b/backend/tools/TestSuite/TestSuite.ApiTests/AppClientsTests.Should_update_client.verified.txt new file mode 100644 index 000000000..805ce7ee2 --- /dev/null +++ b/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 + } + } +} \ No newline at end of file diff --git a/backend/tools/TestSuite/TestSuite.ApiTests/AppClientsTests.cs b/backend/tools/TestSuite/TestSuite.ApiTests/AppClientsTests.cs index bd5784636..44e8c8005 100644 --- a/backend/tools/TestSuite/TestSuite.ApiTests/AppClientsTests.cs +++ b/backend/tools/TestSuite/TestSuite.ApiTests/AppClientsTests.cs @@ -7,13 +7,13 @@ using Squidex.ClientLibrary.Management; using TestSuite.Fixtures; -using Xunit; #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 namespace TestSuite.ApiTests { + [UsesVerify] public sealed class AppClientsTests : IClassFixture { private readonly string appName = Guid.NewGuid().ToString(); @@ -41,6 +41,9 @@ namespace TestSuite.ApiTests // Should return client with correct name and id. Assert.Equal(clientRole, client.Role); Assert.Equal(id, client.Name); + + await Verify(client) + .IgnoreMember(x => x.Secret); } [Fact] @@ -73,6 +76,9 @@ namespace TestSuite.ApiTests Assert.Equal(updateNameRequest.ApiCallsLimit, client_2.ApiCallsLimit); Assert.Equal(updateNameRequest.ApiTrafficLimit, client_2.ApiTrafficLimit); Assert.Equal(updateNameRequest.Role, client_2.Role); + + await Verify(clients_2) + .IgnoreMember(x => x.Secret); } [Fact] @@ -91,6 +97,9 @@ namespace TestSuite.ApiTests // Should not return deleted client. Assert.DoesNotContain(clients_2.Items, x => x.Id == client.Id); + + await Verify(clients_2) + .IgnoreMember(x => x.Secret); } private async Task CreateAsync() diff --git a/backend/tools/TestSuite/TestSuite.ApiTests/AppContributorsTests.Should_invite_contributor.verified.txt b/backend/tools/TestSuite/TestSuite.ApiTests/AppContributorsTests.Should_invite_contributor.verified.txt new file mode 100644 index 000000000..a045b4a82 --- /dev/null +++ b/backend/tools/TestSuite/TestSuite.ApiTests/AppContributorsTests.Should_invite_contributor.verified.txt @@ -0,0 +1,11 @@ +{ + role: Developer, + _links: { + delete: { + method: DELETE + }, + update: { + method: POST + } + } +} \ No newline at end of file diff --git a/backend/tools/TestSuite/TestSuite.ApiTests/AppContributorsTests.Should_remove_contributor.verified.txt b/backend/tools/TestSuite/TestSuite.ApiTests/AppContributorsTests.Should_remove_contributor.verified.txt new file mode 100644 index 000000000..48cee8513 --- /dev/null +++ b/backend/tools/TestSuite/TestSuite.ApiTests/AppContributorsTests.Should_remove_contributor.verified.txt @@ -0,0 +1,11 @@ +{ + maxContributors: -1, + _links: { + create: { + method: POST + }, + self: { + method: GET + } + } +} \ No newline at end of file diff --git a/backend/tools/TestSuite/TestSuite.ApiTests/AppContributorsTests.Should_update_contributor.received.txt b/backend/tools/TestSuite/TestSuite.ApiTests/AppContributorsTests.Should_update_contributor.received.txt new file mode 100644 index 000000000..a77300733 --- /dev/null +++ b/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 + } + } +} \ No newline at end of file diff --git a/backend/tools/TestSuite/TestSuite.ApiTests/AppContributorsTests.Should_update_contributor.verified.txt b/backend/tools/TestSuite/TestSuite.ApiTests/AppContributorsTests.Should_update_contributor.verified.txt new file mode 100644 index 000000000..5f282702b --- /dev/null +++ b/backend/tools/TestSuite/TestSuite.ApiTests/AppContributorsTests.Should_update_contributor.verified.txt @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/backend/tools/TestSuite/TestSuite.ApiTests/AppContributorsTests.cs b/backend/tools/TestSuite/TestSuite.ApiTests/AppContributorsTests.cs index 547cc0c51..55b71af11 100644 --- a/backend/tools/TestSuite/TestSuite.ApiTests/AppContributorsTests.cs +++ b/backend/tools/TestSuite/TestSuite.ApiTests/AppContributorsTests.cs @@ -7,13 +7,13 @@ using Squidex.ClientLibrary.Management; using TestSuite.Fixtures; -using Xunit; #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 namespace TestSuite.ApiTests { + [UsesVerify] public sealed class AppContributorsTests : IClassFixture { private readonly string appName = Guid.NewGuid().ToString(); @@ -58,6 +58,11 @@ namespace TestSuite.ApiTests ContributorDto contributor_1 = await InviteAsync(); Assert.Equal("Developer", contributor_1?.Role); + + await Verify(contributor_1) + .IgnoreMember(x => x.ContributorId) + .IgnoreMember(x => x.ContributorEmail) + .IgnoreMember(x => x.ContributorName); } [Fact] @@ -100,6 +105,8 @@ namespace TestSuite.ApiTests var contributors_2 = await _.Apps.DeleteContributorAsync(appName, contributor.ContributorId); Assert.DoesNotContain(contributors_2.Items, x => x.ContributorId == contributor.ContributorId); + + await Verify(contributors_2); } private async Task InviteAsync() diff --git a/backend/tools/TestSuite/TestSuite.ApiTests/AppCreationTests.Should_create_app.verified.txt b/backend/tools/TestSuite/TestSuite.ApiTests/AppCreationTests.Should_create_app.verified.txt new file mode 100644 index 000000000..3369044ef --- /dev/null +++ b/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 + } + } +} \ No newline at end of file diff --git a/backend/tools/TestSuite/TestSuite.ApiTests/AppCreationTests.Should_create_app_from_templates.verified.txt b/backend/tools/TestSuite/TestSuite.ApiTests/AppCreationTests.Should_create_app_from_templates.verified.txt new file mode 100644 index 000000000..7c14fde87 --- /dev/null +++ b/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 + } + } +} \ No newline at end of file diff --git a/backend/tools/TestSuite/TestSuite.ApiTests/AppCreationTests.cs b/backend/tools/TestSuite/TestSuite.ApiTests/AppCreationTests.cs index 974c28d09..c7b42bf58 100644 --- a/backend/tools/TestSuite/TestSuite.ApiTests/AppCreationTests.cs +++ b/backend/tools/TestSuite/TestSuite.ApiTests/AppCreationTests.cs @@ -7,13 +7,13 @@ using Squidex.ClientLibrary.Management; using TestSuite.Fixtures; -using Xunit; #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 namespace TestSuite.ApiTests { + [UsesVerify] public class AppCreationTests : IClassFixture { private readonly string appName = Guid.NewGuid().ToString(); @@ -59,6 +59,8 @@ namespace TestSuite.ApiTests // Should create default client. Assert.Contains(clients.Items, x => x.Id == "default"); + + await Verify(app); } [Fact] @@ -142,6 +144,8 @@ namespace TestSuite.ApiTests var schemas = await _.Schemas.GetSchemasAsync(appName); Assert.NotEmpty(schemas.Items); + + await Verify(schemas); } private async Task CreateAppAsync() diff --git a/backend/tools/TestSuite/TestSuite.ApiTests/AppLanguagesTests.Should_add_custom_language.verified.txt b/backend/tools/TestSuite/TestSuite.ApiTests/AppLanguagesTests.Should_add_custom_language.verified.txt new file mode 100644 index 000000000..98799d66d --- /dev/null +++ b/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 + } + } +} \ No newline at end of file diff --git a/backend/tools/TestSuite/TestSuite.ApiTests/AppLanguagesTests.Should_add_language.verified.txt b/backend/tools/TestSuite/TestSuite.ApiTests/AppLanguagesTests.Should_add_language.verified.txt new file mode 100644 index 000000000..a6a85363c --- /dev/null +++ b/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 + } + } +} \ No newline at end of file diff --git a/backend/tools/TestSuite/TestSuite.ApiTests/AppLanguagesTests.Should_delete_language.verified.txt b/backend/tools/TestSuite/TestSuite.ApiTests/AppLanguagesTests.Should_delete_language.verified.txt new file mode 100644 index 000000000..14f0bac15 --- /dev/null +++ b/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 + } + } +} \ No newline at end of file diff --git a/backend/tools/TestSuite/TestSuite.ApiTests/AppLanguagesTests.Should_update_language.verified.txt b/backend/tools/TestSuite/TestSuite.ApiTests/AppLanguagesTests.Should_update_language.verified.txt new file mode 100644 index 000000000..733c0804a --- /dev/null +++ b/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 + } + } +} \ No newline at end of file diff --git a/backend/tools/TestSuite/TestSuite.ApiTests/AppLanguagesTests.Should_update_master_language.verified.txt b/backend/tools/TestSuite/TestSuite.ApiTests/AppLanguagesTests.Should_update_master_language.verified.txt new file mode 100644 index 000000000..dd54326de --- /dev/null +++ b/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 + } + } +} \ No newline at end of file diff --git a/backend/tools/TestSuite/TestSuite.ApiTests/AppLanguagesTests.cs b/backend/tools/TestSuite/TestSuite.ApiTests/AppLanguagesTests.cs index 2318c6e09..424ebfbbd 100644 --- a/backend/tools/TestSuite/TestSuite.ApiTests/AppLanguagesTests.cs +++ b/backend/tools/TestSuite/TestSuite.ApiTests/AppLanguagesTests.cs @@ -7,13 +7,13 @@ using Squidex.ClientLibrary.Management; using TestSuite.Fixtures; -using Xunit; #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 namespace TestSuite.ApiTests { + [UsesVerify] public sealed class AppLanguagesTests : IClassFixture { private readonly string appName = Guid.NewGuid().ToString(); @@ -39,6 +39,8 @@ namespace TestSuite.ApiTests var languages_1 = await _.Apps.GetLanguagesAsync(appName); Assert.Equal(new string[] { "en", "de", "it" }, languages_1.Items.Select(x => x.Iso2Code).ToArray()); + + await Verify(languages_1); } [Fact] @@ -55,6 +57,8 @@ namespace TestSuite.ApiTests var languages_1 = await _.Apps.GetLanguagesAsync(appName); Assert.Equal(new string[] { "en", "abc", "xyz" }, languages_1.Items.Select(x => x.Iso2Code).ToArray()); + + await Verify(languages_1); } [Fact] @@ -84,6 +88,8 @@ namespace TestSuite.ApiTests Assert.Equal(updateRequest.Fallback, language_2_DE.Fallback); Assert.Equal(updateRequest.IsOptional, language_2_DE.IsOptional); + + await Verify(languages_2); } [Fact] @@ -131,6 +137,8 @@ namespace TestSuite.ApiTests // Fallback for new master language must be removed. Assert.Empty(language_4_IT.Fallback); + + await Verify(languages_4); } [Fact] @@ -166,6 +174,8 @@ namespace TestSuite.ApiTests Assert.Empty(language_2_IT.Fallback); Assert.Equal(new string[] { "en", "it" }, languages_2.Items.Select(x => x.Iso2Code).ToArray()); + + await Verify(languages_2); } private async Task CreateAppAsync() diff --git a/backend/tools/TestSuite/TestSuite.ApiTests/AppRolesTests.Should_create_role.verified.txt b/backend/tools/TestSuite/TestSuite.ApiTests/AppRolesTests.Should_create_role.verified.txt new file mode 100644 index 000000000..c52428c53 --- /dev/null +++ b/backend/tools/TestSuite/TestSuite.ApiTests/AppRolesTests.Should_create_role.verified.txt @@ -0,0 +1,11 @@ +{ + isDefaultRole: false, + _links: { + delete: { + method: DELETE + }, + update: { + method: PUT + } + } +} \ No newline at end of file diff --git a/backend/tools/TestSuite/TestSuite.ApiTests/AppRolesTests.Should_create_role_with_buggy_name.verified.txt b/backend/tools/TestSuite/TestSuite.ApiTests/AppRolesTests.Should_create_role_with_buggy_name.verified.txt new file mode 100644 index 000000000..c52428c53 --- /dev/null +++ b/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 + } + } +} \ No newline at end of file diff --git a/backend/tools/TestSuite/TestSuite.ApiTests/AppRolesTests.Should_update_role.verified.txt b/backend/tools/TestSuite/TestSuite.ApiTests/AppRolesTests.Should_update_role.verified.txt new file mode 100644 index 000000000..bae470f7e --- /dev/null +++ b/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 + } + } +} \ No newline at end of file diff --git a/backend/tools/TestSuite/TestSuite.ApiTests/AppRolesTests.cs b/backend/tools/TestSuite/TestSuite.ApiTests/AppRolesTests.cs index 8cdfb6598..c77ff8863 100644 --- a/backend/tools/TestSuite/TestSuite.ApiTests/AppRolesTests.cs +++ b/backend/tools/TestSuite/TestSuite.ApiTests/AppRolesTests.cs @@ -7,13 +7,13 @@ using Squidex.ClientLibrary.Management; using TestSuite.Fixtures; -using Xunit; #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 namespace TestSuite.ApiTests { + [UsesVerify] public sealed class AppRolesTests : IClassFixture { private readonly string roleName = Guid.NewGuid().ToString(); @@ -35,6 +35,9 @@ namespace TestSuite.ApiTests // Should return role with correct name. Assert.Empty(role.Permissions); + + await Verify(role) + .IgnoreMember(x => x.Name); } [Fact] @@ -45,6 +48,9 @@ namespace TestSuite.ApiTests // Should return role with correct name. Assert.Empty(role.Permissions); + + await Verify(role) + .IgnoreMember(x => x.Name); } [Fact] @@ -65,6 +71,9 @@ namespace TestSuite.ApiTests // Should return role with correct name. Assert.Equal(updateRequest.Permissions, role_2.Permissions); + + await Verify(role_2) + .IgnoreMember(x => x.Name); } [Fact] diff --git a/backend/tools/TestSuite/TestSuite.ApiTests/AppTests.Should_update_settings.verified.txt b/backend/tools/TestSuite/TestSuite.ApiTests/AppTests.Should_update_settings.verified.txt new file mode 100644 index 000000000..3e35c08d1 --- /dev/null +++ b/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 + } + } +} \ No newline at end of file diff --git a/backend/tools/TestSuite/TestSuite.ApiTests/AppTests.cs b/backend/tools/TestSuite/TestSuite.ApiTests/AppTests.cs index 89917a6c6..c5241d280 100644 --- a/backend/tools/TestSuite/TestSuite.ApiTests/AppTests.cs +++ b/backend/tools/TestSuite/TestSuite.ApiTests/AppTests.cs @@ -7,13 +7,13 @@ using Squidex.ClientLibrary.Management; using TestSuite.Fixtures; -using Xunit; #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 namespace TestSuite.ApiTests { + [UsesVerify] public sealed class AppTests : IClassFixture { public CreatedAppFixture _ { get; } @@ -143,6 +143,9 @@ namespace TestSuite.ApiTests Assert.NotEmpty(settings_1.Patterns); Assert.NotEmpty(settings_1.Editors); + + await Verify(settings_1) + .IgnoreMember(x => x.Version); } } } diff --git a/backend/tools/TestSuite/TestSuite.ApiTests/AppWorkflowsTests.Should_create_workflow.verified.txt b/backend/tools/TestSuite/TestSuite.ApiTests/AppWorkflowsTests.Should_create_workflow.verified.txt new file mode 100644 index 000000000..3fa99e1a7 --- /dev/null +++ b/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 + } + } +} \ No newline at end of file diff --git a/backend/tools/TestSuite/TestSuite.ApiTests/AppWorkflowsTests.Should_delete_workflow.verified.txt b/backend/tools/TestSuite/TestSuite.ApiTests/AppWorkflowsTests.Should_delete_workflow.verified.txt new file mode 100644 index 000000000..663f89d3c --- /dev/null +++ b/backend/tools/TestSuite/TestSuite.ApiTests/AppWorkflowsTests.Should_delete_workflow.verified.txt @@ -0,0 +1,10 @@ +{ + _links: { + create: { + method: POST + }, + self: { + method: GET + } + } +} \ No newline at end of file diff --git a/backend/tools/TestSuite/TestSuite.ApiTests/AppWorkflowsTests.Should_update_workflow.verified.txt b/backend/tools/TestSuite/TestSuite.ApiTests/AppWorkflowsTests.Should_update_workflow.verified.txt new file mode 100644 index 000000000..601973991 --- /dev/null +++ b/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 + } + } +} \ No newline at end of file diff --git a/backend/tools/TestSuite/TestSuite.ApiTests/AppWorkflowsTest.cs b/backend/tools/TestSuite/TestSuite.ApiTests/AppWorkflowsTests.cs similarity index 96% rename from backend/tools/TestSuite/TestSuite.ApiTests/AppWorkflowsTest.cs rename to backend/tools/TestSuite/TestSuite.ApiTests/AppWorkflowsTests.cs index fb98886f1..531b6d8c4 100644 --- a/backend/tools/TestSuite/TestSuite.ApiTests/AppWorkflowsTest.cs +++ b/backend/tools/TestSuite/TestSuite.ApiTests/AppWorkflowsTests.cs @@ -7,14 +7,13 @@ using Squidex.ClientLibrary.Management; 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 SA1507 // Code should not contain multiple blank lines in a row namespace TestSuite.ApiTests { + [UsesVerify] public sealed class AppWorkflowsTests : IClassFixture { private readonly string appName = Guid.NewGuid().ToString(); @@ -40,6 +39,8 @@ namespace TestSuite.ApiTests Assert.NotNull(workflow); Assert.NotNull(workflow.Name); Assert.Equal(3, workflow.Steps.Count); + + await Verify(workflow); } [Fact] @@ -77,6 +78,8 @@ namespace TestSuite.ApiTests Assert.NotNull(workflow_2); Assert.NotNull(workflow_2.Name); Assert.Equal(2, workflow_2.Steps.Count); + + await Verify(workflows_2); } [Fact] @@ -94,6 +97,8 @@ namespace TestSuite.ApiTests var workflows_2 = await _.Apps.DeleteWorkflowAsync(appName, workflow.Id); Assert.DoesNotContain(workflows_2.Items, x => x.Name == name); + + await Verify(workflows_2); } private async Task CreateAsync() diff --git a/backend/tools/TestSuite/TestSuite.ApiTests/AssetFixture.cs b/backend/tools/TestSuite/TestSuite.ApiTests/AssetFixture.cs deleted file mode 100644 index ffc6fecfe..000000000 --- a/backend/tools/TestSuite/TestSuite.ApiTests/AssetFixture.cs +++ /dev/null @@ -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 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 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 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 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; - } - } -} diff --git a/backend/tools/TestSuite/TestSuite.ApiTests/AssetFormatTests.Should_fix_orientation.verified.txt b/backend/tools/TestSuite/TestSuite.ApiTests/AssetFormatTests.Should_fix_orientation.verified.txt new file mode 100644 index 000000000..5007421fa --- /dev/null +++ b/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 + } + } +} \ No newline at end of file diff --git a/backend/tools/TestSuite/TestSuite.ApiTests/AssetFormatTests.Should_upload_audio_mp3.verified.txt b/backend/tools/TestSuite/TestSuite.ApiTests/AssetFormatTests.Should_upload_audio_mp3.verified.txt new file mode 100644 index 000000000..e1f2f9753 --- /dev/null +++ b/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 + } + } +} \ No newline at end of file diff --git a/backend/tools/TestSuite/TestSuite.ApiTests/AssetFormatTests.Should_upload_image_bmp_and_encode_to_webp.verified.txt b/backend/tools/TestSuite/TestSuite.ApiTests/AssetFormatTests.Should_upload_image_bmp_and_encode_to_webp.verified.txt new file mode 100644 index 000000000..2ee387ea0 --- /dev/null +++ b/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 + } + } +} \ No newline at end of file diff --git a/backend/tools/TestSuite/TestSuite.ApiTests/AssetFormatTests.Should_upload_image_bmp_and_resize.verified.txt b/backend/tools/TestSuite/TestSuite.ApiTests/AssetFormatTests.Should_upload_image_bmp_and_resize.verified.txt new file mode 100644 index 000000000..2ee387ea0 --- /dev/null +++ b/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 + } + } +} \ No newline at end of file diff --git a/backend/tools/TestSuite/TestSuite.ApiTests/AssetFormatTests.Should_upload_image_gif_and_resize.verified.txt b/backend/tools/TestSuite/TestSuite.ApiTests/AssetFormatTests.Should_upload_image_gif_and_resize.verified.txt new file mode 100644 index 000000000..9b8fa2b02 --- /dev/null +++ b/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 + } + } +} \ No newline at end of file diff --git a/backend/tools/TestSuite/TestSuite.ApiTests/AssetFormatTests.Should_upload_image_gif_without_extension.verified.txt b/backend/tools/TestSuite/TestSuite.ApiTests/AssetFormatTests.Should_upload_image_gif_without_extension.verified.txt new file mode 100644 index 000000000..ffd930b01 --- /dev/null +++ b/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 + } + } +} \ No newline at end of file diff --git a/backend/tools/TestSuite/TestSuite.ApiTests/AssetFormatTests.Should_upload_image_jpg_and_resize.verified.txt b/backend/tools/TestSuite/TestSuite.ApiTests/AssetFormatTests.Should_upload_image_jpg_and_resize.verified.txt new file mode 100644 index 000000000..44efcadfa --- /dev/null +++ b/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 + } + } +} \ No newline at end of file diff --git a/backend/tools/TestSuite/TestSuite.ApiTests/AssetFormatTests.Should_upload_image_png_and_resize.verified.txt b/backend/tools/TestSuite/TestSuite.ApiTests/AssetFormatTests.Should_upload_image_png_and_resize.verified.txt new file mode 100644 index 000000000..d047fb1b3 --- /dev/null +++ b/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 + } + } +} \ No newline at end of file diff --git a/backend/tools/TestSuite/TestSuite.ApiTests/AssetFormatTests.Should_upload_image_tga_and_resize.verified.txt b/backend/tools/TestSuite/TestSuite.ApiTests/AssetFormatTests.Should_upload_image_tga_and_resize.verified.txt new file mode 100644 index 000000000..ac4364936 --- /dev/null +++ b/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 + } + } +} \ No newline at end of file diff --git a/backend/tools/TestSuite/TestSuite.ApiTests/AssetFormatTests.Should_upload_image_tiff_and_resize.verified.txt b/backend/tools/TestSuite/TestSuite.ApiTests/AssetFormatTests.Should_upload_image_tiff_and_resize.verified.txt new file mode 100644 index 000000000..006d77e50 --- /dev/null +++ b/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 + } + } +} \ No newline at end of file diff --git a/backend/tools/TestSuite/TestSuite.ApiTests/AssetFormatTests.Should_upload_image_webp_and_resize.verified.txt b/backend/tools/TestSuite/TestSuite.ApiTests/AssetFormatTests.Should_upload_image_webp_and_resize.verified.txt new file mode 100644 index 000000000..362d1d8d8 --- /dev/null +++ b/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 + } + } +} \ No newline at end of file diff --git a/backend/tools/TestSuite/TestSuite.ApiTests/AssetFormatTests.Should_upload_video_3gp.verified.txt b/backend/tools/TestSuite/TestSuite.ApiTests/AssetFormatTests.Should_upload_video_3gp.verified.txt new file mode 100644 index 000000000..c046ef88f --- /dev/null +++ b/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 + } + } +} \ No newline at end of file diff --git a/backend/tools/TestSuite/TestSuite.ApiTests/AssetFormatTests.Should_upload_video_flv.verified.txt b/backend/tools/TestSuite/TestSuite.ApiTests/AssetFormatTests.Should_upload_video_flv.verified.txt new file mode 100644 index 000000000..235efc493 --- /dev/null +++ b/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 + } + } +} \ No newline at end of file diff --git a/backend/tools/TestSuite/TestSuite.ApiTests/AssetFormatTests.Should_upload_video_mkv.verified.txt b/backend/tools/TestSuite/TestSuite.ApiTests/AssetFormatTests.Should_upload_video_mkv.verified.txt new file mode 100644 index 000000000..bc5fdf291 --- /dev/null +++ b/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 + } + } +} \ No newline at end of file diff --git a/backend/tools/TestSuite/TestSuite.ApiTests/AssetFormatTests.Should_upload_video_mp4.verified.txt b/backend/tools/TestSuite/TestSuite.ApiTests/AssetFormatTests.Should_upload_video_mp4.verified.txt new file mode 100644 index 000000000..17acfbd11 --- /dev/null +++ b/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 + } + } +} \ No newline at end of file diff --git a/backend/tools/TestSuite/TestSuite.ApiTests/AssetFormatTests.cs b/backend/tools/TestSuite/TestSuite.ApiTests/AssetFormatTests.cs index 5f5fe45ca..b4a185579 100644 --- a/backend/tools/TestSuite/TestSuite.ApiTests/AssetFormatTests.cs +++ b/backend/tools/TestSuite/TestSuite.ApiTests/AssetFormatTests.cs @@ -6,18 +6,19 @@ // ========================================================================== using Squidex.ClientLibrary.Management; -using Xunit; +using TestSuite.Fixtures; #pragma warning disable SA1300 // Element should begin with upper-case letter #pragma warning disable CS0618 // Type or member is obsolete namespace TestSuite.ApiTests { - public class AssetFormatTests : IClassFixture + [UsesVerify] + public class AssetFormatTests : IClassFixture { - public AssetFixture _ { get; } + public CreatedAppFixture _ { get; } - public AssetFormatTests(AssetFixture fixture) + public AssetFormatTests(CreatedAppFixture fixture) { _ = fixture; } @@ -25,7 +26,7 @@ namespace TestSuite.ApiTests [Fact] 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. Assert.True(asset.IsImage); @@ -34,12 +35,17 @@ namespace TestSuite.ApiTests Assert.Equal(400L, (long)asset.PixelHeight); Assert.Equal(400L, asset.Metadata["pixelHeight"]); Assert.Equal(AssetType.Image, asset.Type); + + await Verify(asset) + .IgnoreMember(x => x.FileName) + .IgnoreMember(x => x.FileHash) + .IgnoreMember(x => x.Slug); } [Fact] 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); } @@ -47,7 +53,7 @@ namespace TestSuite.ApiTests [Fact] 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); } @@ -55,7 +61,7 @@ namespace TestSuite.ApiTests [Fact] 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); @@ -65,7 +71,7 @@ namespace TestSuite.ApiTests [Fact] 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); } @@ -73,7 +79,7 @@ namespace TestSuite.ApiTests [Fact] 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); } @@ -81,7 +87,7 @@ namespace TestSuite.ApiTests [Fact] 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); } @@ -89,7 +95,7 @@ namespace TestSuite.ApiTests [Fact] 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); } @@ -97,16 +103,20 @@ namespace TestSuite.ApiTests [Fact] 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"); Assert.True(size < asset.FileSize); Assert.Equal("image/webp", type); + + await Verify(asset); } private async Task AssertImageAsync(AssetDto asset) { + await Verify(asset); + // Should parse image metadata. Assert.True(asset.IsImage); Assert.Equal(600L, (long)asset.PixelWidth); @@ -123,7 +133,7 @@ namespace TestSuite.ApiTests [Fact] 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. Assert.True(asset.IsImage); @@ -133,12 +143,14 @@ namespace TestSuite.ApiTests Assert.Equal(135L, asset.Metadata["pixelHeight"]); Assert.Equal(79L, asset.Metadata["imageQuality"]); Assert.Equal(AssetType.Image, asset.Type); + + await Verify(asset); } [Fact] 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. Assert.False(asset.IsImage); @@ -147,12 +159,14 @@ namespace TestSuite.ApiTests Assert.Equal(2L, asset.Metadata["audioChannels"]); Assert.Equal(44100L, asset.Metadata["audioSampleRate"]); Assert.Equal(AssetType.Audio, asset.Type); + + await Verify(asset); } [Fact] 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. Assert.False(asset.IsImage); @@ -163,33 +177,41 @@ namespace TestSuite.ApiTests Assert.Equal(1280L, asset.Metadata["videoWidth"]); Assert.Equal(720L, asset.Metadata["videoHeight"]); Assert.Equal(AssetType.Video, asset.Type); + + await Verify(asset); } [Fact] 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. Assert.Equal(AssetType.Unknown, asset.Type); + + await Verify(asset); } [Fact] 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. Assert.Equal(AssetType.Unknown, asset.Type); + + await Verify(asset); } [Fact] 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. Assert.Equal(AssetType.Unknown, asset.Type); + + await Verify(asset); } private async Task GetResizedLengthAsync(string imageId, int width, int height) diff --git a/backend/tools/TestSuite/TestSuite.ApiTests/AssetTests.Should_annotate_asset_in_parallel.verified.txt b/backend/tools/TestSuite/TestSuite.ApiTests/AssetTests.Should_annotate_asset_in_parallel.verified.txt new file mode 100644 index 000000000..29cf14b71 --- /dev/null +++ b/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 + } + } +} \ No newline at end of file diff --git a/backend/tools/TestSuite/TestSuite.ApiTests/AssetTests.Should_annote_asset_file_name.verified.txt b/backend/tools/TestSuite/TestSuite.ApiTests/AssetTests.Should_annote_asset_file_name.verified.txt new file mode 100644 index 000000000..c04acc0d4 --- /dev/null +++ b/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 + } + } +} \ No newline at end of file diff --git a/backend/tools/TestSuite/TestSuite.ApiTests/AssetTests.Should_annote_asset_metadata.verified.txt b/backend/tools/TestSuite/TestSuite.ApiTests/AssetTests.Should_annote_asset_metadata.verified.txt new file mode 100644 index 000000000..fb25a85b1 --- /dev/null +++ b/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 + } + } +} \ No newline at end of file diff --git a/backend/tools/TestSuite/TestSuite.ApiTests/AssetTests.Should_annote_asset_slug.verified.txt b/backend/tools/TestSuite/TestSuite.ApiTests/AssetTests.Should_annote_asset_slug.verified.txt new file mode 100644 index 000000000..2afd9b6ed --- /dev/null +++ b/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 + } + } +} \ No newline at end of file diff --git a/backend/tools/TestSuite/TestSuite.ApiTests/AssetTests.Should_annote_asset_tags.verified.txt b/backend/tools/TestSuite/TestSuite.ApiTests/AssetTests.Should_annote_asset_tags.verified.txt new file mode 100644 index 000000000..79ad4f966 --- /dev/null +++ b/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 + } + } +} \ No newline at end of file diff --git a/backend/tools/TestSuite/TestSuite.ApiTests/AssetTests.Should_protect_asset.verified.txt b/backend/tools/TestSuite/TestSuite.ApiTests/AssetTests.Should_protect_asset.verified.txt new file mode 100644 index 000000000..ac36b5fa9 --- /dev/null +++ b/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 + } + } +} \ No newline at end of file diff --git a/backend/tools/TestSuite/TestSuite.ApiTests/AssetTests.Should_replace_asset.verified.txt b/backend/tools/TestSuite/TestSuite.ApiTests/AssetTests.Should_replace_asset.verified.txt new file mode 100644 index 000000000..58004a91d --- /dev/null +++ b/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 + } + } +} \ No newline at end of file diff --git a/backend/tools/TestSuite/TestSuite.ApiTests/AssetTests.Should_upload_asset.verified.txt b/backend/tools/TestSuite/TestSuite.ApiTests/AssetTests.Should_upload_asset.verified.txt new file mode 100644 index 000000000..2e863873f --- /dev/null +++ b/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 + } + } +} \ No newline at end of file diff --git a/backend/tools/TestSuite/TestSuite.ApiTests/AssetTests.Should_upload_asset_with_custom_id.verified.txt b/backend/tools/TestSuite/TestSuite.ApiTests/AssetTests.Should_upload_asset_with_custom_id.verified.txt new file mode 100644 index 000000000..2e863873f --- /dev/null +++ b/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 + } + } +} \ No newline at end of file diff --git a/backend/tools/TestSuite/TestSuite.ApiTests/AssetTests.cs b/backend/tools/TestSuite/TestSuite.ApiTests/AssetTests.cs index 0cea61621..1d94c7546 100644 --- a/backend/tools/TestSuite/TestSuite.ApiTests/AssetTests.cs +++ b/backend/tools/TestSuite/TestSuite.ApiTests/AssetTests.cs @@ -8,20 +8,21 @@ using System.Net; using Squidex.Assets; using Squidex.ClientLibrary.Management; -using Xunit; +using TestSuite.Fixtures; #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 namespace TestSuite.ApiTests { - public class AssetTests : IClassFixture + [UsesVerify] + public class AssetTests : IClassFixture { private ProgressHandler progress = new ProgressHandler(); - public AssetFixture _ { get; } + public CreatedAppFixture _ { get; } - public AssetTests(AssetFixture fixture) + public AssetTests(CreatedAppFixture fixture) { _ = fixture; } @@ -30,7 +31,7 @@ namespace TestSuite.ApiTests public async Task Should_upload_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)) { @@ -39,6 +40,8 @@ namespace TestSuite.ApiTests // Should dowload with correct size. Assert.Equal(stream.Length, downloaded.Length); } + + await Verify(asset_1); } [Fact] @@ -119,9 +122,11 @@ namespace TestSuite.ApiTests var id = Guid.NewGuid().ToString(); // 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); + + await Verify(asset_1); } [Fact] @@ -144,13 +149,13 @@ namespace TestSuite.ApiTests var id = Guid.NewGuid().ToString(); // 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. var ex = await Assert.ThrowsAnyAsync(() => { - 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); @@ -160,13 +165,13 @@ namespace TestSuite.ApiTests public async Task Should_not_create_very_big_asset() { // STEP 1: Create small asset - await _.UploadFileAsync(1_000_000); + await _.Assets.UploadFileAsync(_.AppName, 1_000_000); // STEP 2: Create big asset var ex = await Assert.ThrowsAnyAsync(() => { - return _.UploadFileAsync(10_000_000); + return _.Assets.UploadFileAsync(_.AppName, 10_000_000); }); // Client library cannot catch this exception properly. @@ -177,11 +182,11 @@ namespace TestSuite.ApiTests public async Task Should_replace_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 - 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)) { @@ -190,13 +195,15 @@ namespace TestSuite.ApiTests // Should dowload with correct size. Assert.Equal(stream.Length, downloaded.Length); } + + await Verify(asset_2); } [Fact] public async Task Should_replace_asset_using_tus() { // 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 @@ -227,7 +234,7 @@ namespace TestSuite.ApiTests for (var i = 0; i < 5; i++) { // 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 @@ -273,10 +280,31 @@ namespace TestSuite.ApiTests } [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 - 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. @@ -294,29 +322,53 @@ namespace TestSuite.ApiTests // Should provide 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 { 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. - 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 + { + "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. - Assert.Equal(fileNameRequest.FileName, asset_4.FileName); + // Should provide updated tags. + Assert.Equal(tagsRequest.Tags, asset_2.Tags); + + await Verify(asset_2); } [Fact] @@ -336,7 +388,7 @@ namespace TestSuite.ApiTests // 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; @@ -364,7 +416,7 @@ namespace TestSuite.ApiTests // 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 @@ -374,6 +426,9 @@ namespace TestSuite.ApiTests Assert.Contains(tag2, tags); Assert.Equal(1, tags[tag1]); Assert.Equal(1, tags[tag2]); + + await Verify(asset_2) + .IgnoreMember(x => x.Tags); } [Fact] @@ -382,7 +437,7 @@ namespace TestSuite.ApiTests var fileName = $"{Guid.NewGuid()}.png"; // 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 @@ -443,13 +498,15 @@ namespace TestSuite.ApiTests // Should return 403 when not authenticated. Assert.Equal(HttpStatusCode.Forbidden, ex.StatusCode); } + + await Verify(asset_2); } [Fact] public async Task Should_query_asset_by_metadata() { // 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. @@ -483,7 +540,7 @@ namespace TestSuite.ApiTests public async Task Should_query_asset_by_root_folder() { // 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. @@ -508,7 +565,7 @@ namespace TestSuite.ApiTests // 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. @@ -544,11 +601,11 @@ namespace TestSuite.ApiTests // 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 - 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. @@ -567,7 +624,7 @@ namespace TestSuite.ApiTests public async Task Should_delete_asset(bool permanent) { // 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 @@ -603,7 +660,7 @@ namespace TestSuite.ApiTests public async Task Should_recreate_deleted_asset(bool permanent) { // 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 @@ -611,7 +668,7 @@ namespace TestSuite.ApiTests // 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); } diff --git a/backend/tools/TestSuite/TestSuite.ApiTests/BackupTests.cs b/backend/tools/TestSuite/TestSuite.ApiTests/BackupTests.cs index 4aa578fb2..fea0b12ec 100644 --- a/backend/tools/TestSuite/TestSuite.ApiTests/BackupTests.cs +++ b/backend/tools/TestSuite/TestSuite.ApiTests/BackupTests.cs @@ -9,7 +9,6 @@ using Squidex.ClientLibrary.Management; using TestSuite.Fixtures; using TestSuite.Model; using TestSuite.Utils; -using Xunit; #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 @@ -52,7 +51,8 @@ namespace TestSuite.ApiTests // STEP 3: Create backup 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); @@ -71,7 +71,7 @@ namespace TestSuite.ApiTests // 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); } @@ -98,7 +98,8 @@ namespace TestSuite.ApiTests // STEP 3: Create backup 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); @@ -121,7 +122,7 @@ namespace TestSuite.ApiTests // 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); } diff --git a/backend/tools/TestSuite/TestSuite.ApiTests/CDNTests.cs b/backend/tools/TestSuite/TestSuite.ApiTests/CDNTests.cs index fcfca6d41..e6f65d8e6 100644 --- a/backend/tools/TestSuite/TestSuite.ApiTests/CDNTests.cs +++ b/backend/tools/TestSuite/TestSuite.ApiTests/CDNTests.cs @@ -7,7 +7,6 @@ using TestSuite.Fixtures; using TestSuite.Model; -using Xunit; #pragma warning disable SA1300 // Element should begin with upper-case letter diff --git a/backend/tools/TestSuite/TestSuite.ApiTests/CommentsTests.Should_create_comment.verified.txt b/backend/tools/TestSuite/TestSuite.ApiTests/CommentsTests.Should_create_comment.verified.txt new file mode 100644 index 000000000..78a71d020 --- /dev/null +++ b/backend/tools/TestSuite/TestSuite.ApiTests/CommentsTests.Should_create_comment.verified.txt @@ -0,0 +1,8 @@ +{ + createdComments: [ + { + id: Guid_1, + user: client:root + } + ] +} \ No newline at end of file diff --git a/backend/tools/TestSuite/TestSuite.ApiTests/CommentsTests.Should_delete_comment.verified.txt b/backend/tools/TestSuite/TestSuite.ApiTests/CommentsTests.Should_delete_comment.verified.txt new file mode 100644 index 000000000..f2c61c88c --- /dev/null +++ b/backend/tools/TestSuite/TestSuite.ApiTests/CommentsTests.Should_delete_comment.verified.txt @@ -0,0 +1,6 @@ +{ + deletedComments: [ + Guid_1 + ], + version: 1 +} \ No newline at end of file diff --git a/backend/tools/TestSuite/TestSuite.ApiTests/CommentsTests.Should_update_comment.verified.txt b/backend/tools/TestSuite/TestSuite.ApiTests/CommentsTests.Should_update_comment.verified.txt new file mode 100644 index 000000000..c31d970c2 --- /dev/null +++ b/backend/tools/TestSuite/TestSuite.ApiTests/CommentsTests.Should_update_comment.verified.txt @@ -0,0 +1,9 @@ +{ + updatedComments: [ + { + id: Guid_1, + user: client:root + } + ], + version: 1 +} \ No newline at end of file diff --git a/backend/tools/TestSuite/TestSuite.ApiTests/CommentsTests.cs b/backend/tools/TestSuite/TestSuite.ApiTests/CommentsTests.cs index 12bb4621b..eaafa2316 100644 --- a/backend/tools/TestSuite/TestSuite.ApiTests/CommentsTests.cs +++ b/backend/tools/TestSuite/TestSuite.ApiTests/CommentsTests.cs @@ -7,13 +7,13 @@ using Squidex.ClientLibrary.Management; using TestSuite.Fixtures; -using Xunit; #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 namespace TestSuite.ApiTests { + [UsesVerify] public class CommentsTests : IClassFixture { private readonly string resource = Guid.NewGuid().ToString(); @@ -49,6 +49,9 @@ namespace TestSuite.ApiTests var comments = await _.Comments.GetCommentsAsync(_.AppName, resource); Assert.Contains(comments.CreatedComments, x => x.Text == createRequest.Text); + + await Verify(comments) + .IgnoreMember(x => x.Text); } [Fact] @@ -76,6 +79,9 @@ namespace TestSuite.ApiTests var comments = await _.Comments.GetCommentsAsync(_.AppName, resource, 0); Assert.Contains(comments.UpdatedComments, x => x.Text == updateRequest.Text); + + await Verify(comments) + .IgnoreMember(x => x.Text); } [Fact] @@ -98,6 +104,9 @@ namespace TestSuite.ApiTests var comments = await _.Comments.GetCommentsAsync(_.AppName, resource, 0); Assert.Contains(comment.Id, comments.DeletedComments); + + await Verify(comments) + .IgnoreMember(x => x.Text); } } } diff --git a/backend/tools/TestSuite/TestSuite.ApiTests/ContentCleanupTests.cs b/backend/tools/TestSuite/TestSuite.ApiTests/ContentCleanupTests.cs index 3937c5f19..87b6608e2 100644 --- a/backend/tools/TestSuite/TestSuite.ApiTests/ContentCleanupTests.cs +++ b/backend/tools/TestSuite/TestSuite.ApiTests/ContentCleanupTests.cs @@ -8,7 +8,6 @@ using Squidex.ClientLibrary; using TestSuite.Fixtures; using TestSuite.Model; -using Xunit; #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 diff --git a/backend/tools/TestSuite/TestSuite.ApiTests/ContentLanguageTests.cs b/backend/tools/TestSuite/TestSuite.ApiTests/ContentLanguageTests.cs index 6c7853564..fa9a121da 100644 --- a/backend/tools/TestSuite/TestSuite.ApiTests/ContentLanguageTests.cs +++ b/backend/tools/TestSuite/TestSuite.ApiTests/ContentLanguageTests.cs @@ -7,7 +7,6 @@ using Squidex.ClientLibrary; using TestSuite.Model; -using Xunit; #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 diff --git a/backend/tools/TestSuite/TestSuite.ApiTests/ContentQueryTests.cs b/backend/tools/TestSuite/TestSuite.ApiTests/ContentQueryTests.cs index e67013c08..05a1138b0 100644 --- a/backend/tools/TestSuite/TestSuite.ApiTests/ContentQueryTests.cs +++ b/backend/tools/TestSuite/TestSuite.ApiTests/ContentQueryTests.cs @@ -9,7 +9,6 @@ using Newtonsoft.Json; using Newtonsoft.Json.Linq; using Squidex.ClientLibrary; using TestSuite.Model; -using Xunit; #pragma warning disable SA1300 // Element should begin with upper-case letter @@ -251,23 +250,11 @@ namespace TestSuite.ApiTests [Fact] 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. - 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; - } - } + var items = await _.Contents.WaitForContentAsync(q, x => true, TimeSpan.FromSeconds(30)); - Assert.False(true); + AssertItems(items, 1, new[] { 2 }); } [Fact] @@ -281,21 +268,9 @@ namespace TestSuite.ApiTests } }; - // Query multiple times to wait for async text indexer. - for (var i = 0; i < 10; i++) - { - await Task.Delay(500); - - var items = await _.Contents.GetAsync(q); + var items = await _.Contents.WaitForContentAsync(q, x => true, TimeSpan.FromSeconds(30)); - if (items.Items.Any()) - { - AssertItems(items, 1, new[] { 2 }); - return; - } - } - - Assert.False(true); + AssertItems(items, 1, new[] { 2 }); } [Fact] @@ -303,21 +278,9 @@ namespace TestSuite.ApiTests { 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. - 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; - } - } + var items = await _.Contents.WaitForContentAsync(q, x => true, TimeSpan.FromSeconds(30)); - Assert.False(true); + AssertItems(items, 1, new[] { 3 }); } [Fact] @@ -341,21 +304,9 @@ namespace TestSuite.ApiTests } }; - // Query multiple times to wait for async text indexer. - 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; - } - } + var items = await _.Contents.WaitForContentAsync(q, x => true, TimeSpan.FromSeconds(30)); - Assert.False(true); + AssertItems(items, 1, new[] { 3 }); } [Fact] @@ -363,21 +314,9 @@ namespace TestSuite.ApiTests { 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. - for (var i = 0; i < 10; i++) - { - await Task.Delay(500); + var items = await _.Contents.WaitForContentAsync(q, x => true, TimeSpan.FromSeconds(30)); - 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] @@ -401,21 +340,9 @@ namespace TestSuite.ApiTests } }; - // Query multiple times to wait for async text indexer. - 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; - } - } + var items = await _.Contents.WaitForContentAsync(q, x => true, TimeSpan.FromSeconds(30)); - Assert.False(true); + AssertItems(items, 1, new[] { 4 }); } [Fact] diff --git a/backend/tools/TestSuite/TestSuite.ApiTests/ContentReferencesTests.cs b/backend/tools/TestSuite/TestSuite.ApiTests/ContentReferencesTests.cs index 307916fb3..a7ff85015 100644 --- a/backend/tools/TestSuite/TestSuite.ApiTests/ContentReferencesTests.cs +++ b/backend/tools/TestSuite/TestSuite.ApiTests/ContentReferencesTests.cs @@ -7,7 +7,6 @@ using Squidex.ClientLibrary; using TestSuite.Model; -using Xunit; #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 diff --git a/backend/tools/TestSuite/TestSuite.ApiTests/ContentScriptingTests.cs b/backend/tools/TestSuite/TestSuite.ApiTests/ContentScriptingTests.cs index b35ac96bd..f1b3bfa4b 100644 --- a/backend/tools/TestSuite/TestSuite.ApiTests/ContentScriptingTests.cs +++ b/backend/tools/TestSuite/TestSuite.ApiTests/ContentScriptingTests.cs @@ -9,7 +9,6 @@ using Squidex.ClientLibrary; using Squidex.ClientLibrary.Management; using TestSuite.Fixtures; using TestSuite.Model; -using Xunit; #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 diff --git a/backend/tools/TestSuite/TestSuite.ApiTests/ContentUpdateTests.Should_create_non_published_content.verified.txt b/backend/tools/TestSuite/TestSuite.ApiTests/ContentUpdateTests.Should_create_non_published_content.verified.txt new file mode 100644 index 000000000..99805a447 --- /dev/null +++ b/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 + } + } +} \ No newline at end of file diff --git a/backend/tools/TestSuite/TestSuite.ApiTests/ContentUpdateTests.Should_create_null_text.verified.txt b/backend/tools/TestSuite/TestSuite.ApiTests/ContentUpdateTests.Should_create_null_text.verified.txt new file mode 100644 index 000000000..40bdd6296 --- /dev/null +++ b/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 + } + } +} \ No newline at end of file diff --git a/backend/tools/TestSuite/TestSuite.ApiTests/ContentUpdateTests.Should_create_strange_text.verified.txt b/backend/tools/TestSuite/TestSuite.ApiTests/ContentUpdateTests.Should_create_strange_text.verified.txt new file mode 100644 index 000000000..477834e4c --- /dev/null +++ b/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 + } + } +} \ No newline at end of file diff --git a/backend/tools/TestSuite/TestSuite.ApiTests/ContentUpdateTests.Should_get_content_by_version.verified.txt b/backend/tools/TestSuite/TestSuite.ApiTests/ContentUpdateTests.Should_get_content_by_version.verified.txt new file mode 100644 index 000000000..a0e9c12f9 --- /dev/null +++ b/backend/tools/TestSuite/TestSuite.ApiTests/ContentUpdateTests.Should_get_content_by_version.verified.txt @@ -0,0 +1,5 @@ +{ + Number: { + iv: 1 + } +} \ No newline at end of file diff --git a/backend/tools/TestSuite/TestSuite.ApiTests/ContentUpdateTests.Should_patch_content.verified.txt b/backend/tools/TestSuite/TestSuite.ApiTests/ContentUpdateTests.Should_patch_content.verified.txt new file mode 100644 index 000000000..731ee0573 --- /dev/null +++ b/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 + } + } +} \ No newline at end of file diff --git a/backend/tools/TestSuite/TestSuite.ApiTests/ContentUpdateTests.Should_patch_content_to_null.verified.txt b/backend/tools/TestSuite/TestSuite.ApiTests/ContentUpdateTests.Should_patch_content_to_null.verified.txt new file mode 100644 index 000000000..8ff50a7e3 --- /dev/null +++ b/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 + } + } +} \ No newline at end of file diff --git a/backend/tools/TestSuite/TestSuite.ApiTests/ContentUpdateTests.Should_patch_content_with_bulk.verified.txt b/backend/tools/TestSuite/TestSuite.ApiTests/ContentUpdateTests.Should_patch_content_with_bulk.verified.txt new file mode 100644 index 000000000..731ee0573 --- /dev/null +++ b/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 + } + } +} \ No newline at end of file diff --git a/backend/tools/TestSuite/TestSuite.ApiTests/ContentUpdateTests.Should_patch_content_with_upsert.verified.txt b/backend/tools/TestSuite/TestSuite.ApiTests/ContentUpdateTests.Should_patch_content_with_upsert.verified.txt new file mode 100644 index 000000000..731ee0573 --- /dev/null +++ b/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 + } + } +} \ No newline at end of file diff --git a/backend/tools/TestSuite/TestSuite.ApiTests/ContentUpdateTests.Should_patch_id_data_value.verified.txt b/backend/tools/TestSuite/TestSuite.ApiTests/ContentUpdateTests.Should_patch_id_data_value.verified.txt new file mode 100644 index 000000000..c4e6633e5 --- /dev/null +++ b/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 + } + } +} \ No newline at end of file diff --git a/backend/tools/TestSuite/TestSuite.ApiTests/ContentUpdateTests.Should_recreate_deleted_content.verified.txt b/backend/tools/TestSuite/TestSuite.ApiTests/ContentUpdateTests.Should_recreate_deleted_content.verified.txt new file mode 100644 index 000000000..d695292ef --- /dev/null +++ b/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 + } + } +} \ No newline at end of file diff --git a/backend/tools/TestSuite/TestSuite.ApiTests/ContentUpdateTests.Should_recreate_deleted_content_with_upsert.verified.txt b/backend/tools/TestSuite/TestSuite.ApiTests/ContentUpdateTests.Should_recreate_deleted_content_with_upsert.verified.txt new file mode 100644 index 000000000..695bca6cf --- /dev/null +++ b/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 + } + } +} \ No newline at end of file diff --git a/backend/tools/TestSuite/TestSuite.ApiTests/ContentUpdateTests.Should_update_singleton_content_with_special_id.verified.txt b/backend/tools/TestSuite/TestSuite.ApiTests/ContentUpdateTests.Should_update_singleton_content_with_special_id.verified.txt new file mode 100644 index 000000000..3570a7089 --- /dev/null +++ b/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 + } + } +} \ No newline at end of file diff --git a/backend/tools/TestSuite/TestSuite.ApiTests/ContentUpdateTests.cs b/backend/tools/TestSuite/TestSuite.ApiTests/ContentUpdateTests.cs index 501155105..989768206 100644 --- a/backend/tools/TestSuite/TestSuite.ApiTests/ContentUpdateTests.cs +++ b/backend/tools/TestSuite/TestSuite.ApiTests/ContentUpdateTests.cs @@ -9,7 +9,6 @@ using Newtonsoft.Json.Linq; using Squidex.ClientLibrary; using Squidex.ClientLibrary.Management; using TestSuite.Model; -using Xunit; #pragma warning disable CS0618 // Type or member is obsolete #pragma warning disable SA1300 // Element should begin with upper-case letter @@ -17,6 +16,7 @@ using Xunit; namespace TestSuite.ApiTests { + [UsesVerify] public class ContentUpdateTests : IClassFixture { public ContentFixture _ { get; } @@ -139,6 +139,8 @@ namespace TestSuite.ApiTests var updated = await _.Contents.GetAsync(content.Id); Assert.Equal(text, updated.Data.String); + + await Verify(updated); } finally { @@ -169,6 +171,8 @@ namespace TestSuite.ApiTests var updated = await _.Contents.GetAsync(content.Id, QueryContext.Default.IgnoreFallback()); Assert.Null(updated.Data.Localized["en"]); + + await Verify(updated); } finally { @@ -221,6 +225,8 @@ namespace TestSuite.ApiTests { return _.Contents.GetAsync(content.Id); }); + + await Verify(content); } finally { @@ -519,6 +525,8 @@ namespace TestSuite.ApiTests // Should not change other value with patch. Assert.Equal("test", updated.Data.String); + + await Verify(updated); } finally { @@ -545,6 +553,8 @@ namespace TestSuite.ApiTests var updated = await _.Contents.GetAsync(content.Id); Assert.Equal("id2", updated.Data.Id); + + await Verify(updated); } finally { @@ -571,6 +581,8 @@ namespace TestSuite.ApiTests var updated = await _.Contents.GetAsync(content.Id); Assert.Null(updated.Data.String); + + await Verify(updated); } finally { @@ -604,6 +616,8 @@ namespace TestSuite.ApiTests // Should not change other value with patch. Assert.Equal("test", updated.Data.String); + + await Verify(updated); } finally { @@ -671,6 +685,8 @@ namespace TestSuite.ApiTests // Should not change other value with patch. Assert.Equal("test", updated.Data.String); + + await Verify(updated); } finally { @@ -857,6 +873,8 @@ namespace TestSuite.ApiTests }); Assert.Equal("singleton", content_2.Data["my-field"]["iv"]); + + await Verify(content_2); } [Fact] @@ -889,6 +907,8 @@ namespace TestSuite.ApiTests var data_1 = await _.Contents.GetDataAsync(content.Id, content.Version - 1); Assert.Equal(1, data_1.Number); + + await Verify(data_1); } finally { diff --git a/backend/tools/TestSuite/TestSuite.ApiTests/DiagnosticsTests.cs b/backend/tools/TestSuite/TestSuite.ApiTests/DiagnosticsTests.cs new file mode 100644 index 000000000..47275ad6b --- /dev/null +++ b/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 + { + public CreatedAppFixture _ { get; } + + public DiagnosticsTests(CreatedAppFixture fixture) + { + _ = fixture; + } + + [Fact] + public async Task Should_create_gc_dump() + { + await _.Diagnostics.GetGCDumpAsync(); + } + } +} diff --git a/backend/tools/TestSuite/TestSuite.ApiTests/FrontendTests.cs b/backend/tools/TestSuite/TestSuite.ApiTests/FrontendTests.cs index 4acaa138c..96b804639 100644 --- a/backend/tools/TestSuite/TestSuite.ApiTests/FrontendTests.cs +++ b/backend/tools/TestSuite/TestSuite.ApiTests/FrontendTests.cs @@ -8,7 +8,6 @@ using Codeuctivity.ImageSharpCompare; using PuppeteerSharp; using TestSuite.Fixtures; -using Xunit; #pragma warning disable SA1300 // Element should begin with upper-case letter diff --git a/backend/tools/TestSuite/TestSuite.ApiTests/GraphQLTests.cs b/backend/tools/TestSuite/TestSuite.ApiTests/GraphQLTests.cs index 615efa372..f299ad454 100644 --- a/backend/tools/TestSuite/TestSuite.ApiTests/GraphQLTests.cs +++ b/backend/tools/TestSuite/TestSuite.ApiTests/GraphQLTests.cs @@ -9,7 +9,6 @@ using Newtonsoft.Json.Linq; using Squidex.ClientLibrary; using Squidex.ClientLibrary.Management; using TestSuite.Model; -using Xunit; #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 diff --git a/backend/tools/TestSuite/TestSuite.ApiTests/HistoryTests.cs b/backend/tools/TestSuite/TestSuite.ApiTests/HistoryTests.cs new file mode 100644 index 000000000..888b8fc19 --- /dev/null +++ b/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 + { + 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); + } + } +} diff --git a/backend/tools/TestSuite/TestSuite.ApiTests/LanguagesTests.cs b/backend/tools/TestSuite/TestSuite.ApiTests/LanguagesTests.cs index 4cac37907..ad9ea1af1 100644 --- a/backend/tools/TestSuite/TestSuite.ApiTests/LanguagesTests.cs +++ b/backend/tools/TestSuite/TestSuite.ApiTests/LanguagesTests.cs @@ -6,7 +6,6 @@ // ========================================================================== using TestSuite.Fixtures; -using Xunit; #pragma warning disable SA1300 // Element should begin with upper-case letter diff --git a/backend/tools/TestSuite/TestSuite.ApiTests/OpenApiTests.cs b/backend/tools/TestSuite/TestSuite.ApiTests/OpenApiTests.cs index 35bc991bb..4fea145e5 100644 --- a/backend/tools/TestSuite/TestSuite.ApiTests/OpenApiTests.cs +++ b/backend/tools/TestSuite/TestSuite.ApiTests/OpenApiTests.cs @@ -6,7 +6,6 @@ // ========================================================================== using NSwag; -using Xunit; #pragma warning disable SA1300 // Element should begin with upper-case letter diff --git a/backend/tools/TestSuite/TestSuite.ApiTests/PingTests.cs b/backend/tools/TestSuite/TestSuite.ApiTests/PingTests.cs index be84dfe7c..7e294c4f5 100644 --- a/backend/tools/TestSuite/TestSuite.ApiTests/PingTests.cs +++ b/backend/tools/TestSuite/TestSuite.ApiTests/PingTests.cs @@ -6,7 +6,6 @@ // ========================================================================== using TestSuite.Fixtures; -using Xunit; #pragma warning disable SA1300 // Element should begin with upper-case letter diff --git a/backend/tools/TestSuite/TestSuite.ApiTests/PlansTests.cs b/backend/tools/TestSuite/TestSuite.ApiTests/PlansTests.cs new file mode 100644 index 000000000..3e22028b0 --- /dev/null +++ b/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 + { + public CreatedAppFixture _ { get; } + + public PlansTests(CreatedAppFixture fixture) + { + _ = fixture; + } + + [Fact] + public async Task Should_get_plans() + { + var plans = await _.Plans.GetPlansAsync(_.AppName); + + Assert.NotNull(plans); + } + } +} diff --git a/backend/tools/TestSuite/TestSuite.ApiTests/RuleRunnerTests.cs b/backend/tools/TestSuite/TestSuite.ApiTests/RuleRunnerTests.cs index 5c1644a75..0e27a8f97 100644 --- a/backend/tools/TestSuite/TestSuite.ApiTests/RuleRunnerTests.cs +++ b/backend/tools/TestSuite/TestSuite.ApiTests/RuleRunnerTests.cs @@ -8,7 +8,6 @@ using Squidex.ClientLibrary.Management; using TestSuite.Fixtures; using TestSuite.Model; -using Xunit; #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 diff --git a/backend/tools/TestSuite/TestSuite.ApiTests/RuleTests.Should_create_rule.verified.txt b/backend/tools/TestSuite/TestSuite.ApiTests/RuleTests.Should_create_rule.verified.txt new file mode 100644 index 000000000..93091abd4 --- /dev/null +++ b/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 + } + } +} \ No newline at end of file diff --git a/backend/tools/TestSuite/TestSuite.ApiTests/RuleTests.Should_update_rule.verified.txt b/backend/tools/TestSuite/TestSuite.ApiTests/RuleTests.Should_update_rule.verified.txt new file mode 100644 index 000000000..2095a1de2 --- /dev/null +++ b/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 + } + } +} \ No newline at end of file diff --git a/backend/tools/TestSuite/TestSuite.ApiTests/RuleTests.cs b/backend/tools/TestSuite/TestSuite.ApiTests/RuleTests.cs index 0290564fa..791575600 100644 --- a/backend/tools/TestSuite/TestSuite.ApiTests/RuleTests.cs +++ b/backend/tools/TestSuite/TestSuite.ApiTests/RuleTests.cs @@ -7,13 +7,13 @@ using Squidex.ClientLibrary.Management; using TestSuite.Fixtures; -using Xunit; #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 namespace TestSuite.ApiTests { + [UsesVerify] public class RuleTests : IClassFixture { private readonly string appName = Guid.NewGuid().ToString(); @@ -52,6 +52,8 @@ namespace TestSuite.ApiTests var rule = await _.Rules.PostRuleAsync(appName, createRule); Assert.IsType(rule.Action); + + await Verify(rule); } [Fact] @@ -89,6 +91,8 @@ namespace TestSuite.ApiTests var rule_1 = await _.Rules.PutRuleAsync(appName, rule_0.Id, updateRequest); Assert.Equal(ruleName, rule_1.Name); + + await Verify(rule_1); } [Fact] diff --git a/backend/tools/TestSuite/TestSuite.ApiTests/SchemaTests.Should_create_singleton_schema.verified.txt b/backend/tools/TestSuite/TestSuite.ApiTests/SchemaTests.Should_create_singleton_schema.verified.txt new file mode 100644 index 000000000..8aacb52e8 --- /dev/null +++ b/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 + } + } +} \ No newline at end of file diff --git a/backend/tools/TestSuite/TestSuite.ApiTests/SchemaTests.Should_create_singleton_schema_with_obsolete_property.verified.txt b/backend/tools/TestSuite/TestSuite.ApiTests/SchemaTests.Should_create_singleton_schema_with_obsolete_property.verified.txt new file mode 100644 index 000000000..8aacb52e8 --- /dev/null +++ b/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 + } + } +} \ No newline at end of file diff --git a/backend/tools/TestSuite/TestSuite.ApiTests/SchemaTests.cs b/backend/tools/TestSuite/TestSuite.ApiTests/SchemaTests.cs index 40e5f563e..75b92a5ce 100644 --- a/backend/tools/TestSuite/TestSuite.ApiTests/SchemaTests.cs +++ b/backend/tools/TestSuite/TestSuite.ApiTests/SchemaTests.cs @@ -7,7 +7,6 @@ using Squidex.ClientLibrary.Management; using TestSuite.Fixtures; -using Xunit; #pragma warning disable CS0618 // Type or member is obsolete #pragma warning disable SA1300 // Element should begin with upper-case letter @@ -15,6 +14,7 @@ using Xunit; namespace TestSuite.ApiTests { + [UsesVerify] public class SchemaTests : IClassFixture { private readonly string schemaName = $"schema-{Guid.NewGuid()}"; @@ -87,6 +87,9 @@ namespace TestSuite.ApiTests // Should return created schemas with correct name. Assert.Equal(schemaName, schema.Name); + await Verify(schema) + .IgnoreMember(x => x.Name); + // STEP 2: Get all schemas var schemas = await _.Schemas.GetSchemasAsync(_.AppName); @@ -121,6 +124,9 @@ namespace TestSuite.ApiTests // Should return created schemas with correct name. Assert.Equal(schemaName, schema.Name); + await Verify(schema) + .IgnoreMember(x => x.Name); + // STEP 2: Get all schemas var schemas = await _.Schemas.GetSchemasAsync(_.AppName); diff --git a/backend/tools/TestSuite/TestSuite.ApiTests/SearchTests.cs b/backend/tools/TestSuite/TestSuite.ApiTests/SearchTests.cs new file mode 100644 index 000000000..bc242c2ba --- /dev/null +++ b/backend/tools/TestSuite/TestSuite.ApiTests/SearchTests.cs @@ -0,0 +1,98 @@ +// ========================================================================== +// Squidex Headless CMS +// ========================================================================== +// Copyright (c) Squidex UG (haftungsbeschraenkt) +// All rights reserved. Licensed under the MIT license. +// ========================================================================== + +using Squidex.ClientLibrary; +using Squidex.ClientLibrary.Management; +using TestSuite.Model; + +#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 + +namespace TestSuite.ApiTests +{ + public class SearchTests : IClassFixture + { + public ContentFixture _ { get; } + + public SearchTests(ContentFixture fixture) + { + _ = fixture; + } + + [Fact] + public async Task Should_search_asset() + { + // STEP 1: Create asset + await _.Assets.UploadFileAsync(_.AppName, "Assets/logo-wide.png", "image/png"); + + + // STEP 2: Search for schema. + var result = await _.Search.GetSearchResultsAsync(_.AppName, "logo"); + + Assert.Contains(result, x => x.Type == SearchResultType.Asset); + } + + [Fact] + public async Task Should_search_schema() + { + // STEP 1: Create schema + var schemaName = Guid.NewGuid().ToString(); + + var createRequest = new CreateSchemaDto + { + Name = schemaName + }; + + await _.Schemas.PostSchemaAsync(_.AppName, createRequest); + + + // STEP 2: Search for schema. + var result = await _.Search.WaitForSearchAsync(_.AppName, schemaName, x => x.Type == SearchResultType.Content, TimeSpan.FromSeconds(30)); + + Assert.NotEmpty(result); + } + + [Fact] + public async Task Should_search_content() + { + // STEP 1: Create content + var contentString = Guid.NewGuid().ToString(); + + var createRequest = new TestEntityData + { + String = contentString + }; + + await _.Contents.CreateAsync(createRequest, ContentCreateOptions.AsPublish); + + + // STEP 2: Search for schema. + var result = await _.Search.WaitForSearchAsync(_.AppName, contentString, x => x.Type == SearchResultType.Content, TimeSpan.FromSeconds(30)); + + Assert.NotEmpty(result); + } + + [Theory] + [InlineData(SearchResultType.Asset, "Assets")] + [InlineData(SearchResultType.Dashboard, "Dashboard")] + [InlineData(SearchResultType.Rule, "Rules")] + [InlineData(SearchResultType.Schema, "Schemas")] + [InlineData(SearchResultType.Setting, "Backups")] + [InlineData(SearchResultType.Setting, "Clients")] + [InlineData(SearchResultType.Setting, "Contributors")] + [InlineData(SearchResultType.Setting, "Languages")] + [InlineData(SearchResultType.Setting, "Roles")] + [InlineData(SearchResultType.Setting, "Subscription")] + [InlineData(SearchResultType.Setting, "Workflows")] + public async Task Should_search_for_dashboard_pages(SearchResultType expectedType, string query) + { + var result = await _.Search.GetSearchResultsAsync(_.AppName, query); + + Assert.Contains(result, x => x.Type == expectedType); + } + } +} diff --git a/backend/tools/TestSuite/TestSuite.ApiTests/Setup.cs b/backend/tools/TestSuite/TestSuite.ApiTests/Setup.cs index e8cc71a63..cb23d6a72 100644 --- a/backend/tools/TestSuite/TestSuite.ApiTests/Setup.cs +++ b/backend/tools/TestSuite/TestSuite.ApiTests/Setup.cs @@ -5,6 +5,4 @@ // All rights reserved. Licensed under the MIT license. // ========================================================================== -using Xunit; - [assembly: CollectionBehavior(CollectionBehavior.CollectionPerAssembly)] diff --git a/backend/tools/TestSuite/TestSuite.ApiTests/TestSuite.ApiTests.csproj b/backend/tools/TestSuite/TestSuite.ApiTests/TestSuite.ApiTests.csproj index 2b5915c98..e5abd3db4 100644 --- a/backend/tools/TestSuite/TestSuite.ApiTests/TestSuite.ApiTests.csproj +++ b/backend/tools/TestSuite/TestSuite.ApiTests/TestSuite.ApiTests.csproj @@ -24,6 +24,7 @@ + all diff --git a/backend/tools/TestSuite/TestSuite.Shared/ClientExtensions.cs b/backend/tools/TestSuite/TestSuite.Shared/ClientExtensions.cs index 7e111b203..42abe6639 100644 --- a/backend/tools/TestSuite/TestSuite.Shared/ClientExtensions.cs +++ b/backend/tools/TestSuite/TestSuite.Shared/ClientExtensions.cs @@ -5,7 +5,9 @@ // All rights reserved. Licensed under the MIT license. // ========================================================================== +using Squidex.ClientLibrary; using Squidex.ClientLibrary.Management; +using TestSuite.Fixtures; namespace TestSuite { @@ -38,7 +40,8 @@ namespace TestSuite return false; } - public static async Task> WaitForTagsAsync(this IAssetsClient assetsClient, string app, string id, TimeSpan timeout) + public static async Task> WaitForContentAsync(this IContentsClient contentsClient, ContentQuery q, + Func predicate, TimeSpan timeout) where TEntity : Content where TData : class, new() { try { @@ -46,11 +49,89 @@ namespace TestSuite while (!cts.IsCancellationRequested) { - var tags = await assetsClient.GetTagsAsync(app, cts.Token); + var result = await contentsClient.GetAsync(q, null, cts.Token); - if (tags.TryGetValue(id, out var count) && count > 0) + if (result.Items.Any(predicate)) { - return tags; + return result; + } + + await Task.Delay(200, cts.Token); + } + } + catch (OperationCanceledException) + { + } + + return new ContentsResult(); + } + + public static async Task> WaitForSearchAsync(this ISearchClient searchClient, string app, string query, + Func predicate, TimeSpan timeout) + { + try + { + using var cts = new CancellationTokenSource(timeout); + + while (!cts.IsCancellationRequested) + { + var result = await searchClient.GetSearchResultsAsync(app, query, cts.Token); + + if (result.Any(predicate)) + { + return result.ToList(); + } + + await Task.Delay(200, cts.Token); + } + } + catch (OperationCanceledException) + { + } + + return new List(); + } + + public static async Task> WaitForHistoryAsync(this IHistoryClient assetsClient, string app, string channel, + Func predicate, TimeSpan timeout) + { + try + { + using var cts = new CancellationTokenSource(timeout); + + while (!cts.IsCancellationRequested) + { + var result = await assetsClient.GetHistoryAsync(app, channel, cts.Token); + + if (result.Any(predicate)) + { + return result.ToList(); + } + + await Task.Delay(200, cts.Token); + } + } + catch (OperationCanceledException) + { + } + + return new List(); + } + + public static async Task> WaitForTagsAsync(this IAssetsClient assetsClient, string app, string id, + TimeSpan timeout) + { + try + { + using var cts = new CancellationTokenSource(timeout); + + while (!cts.IsCancellationRequested) + { + var result = await assetsClient.GetTagsAsync(app, cts.Token); + + if (result.TryGetValue(id, out var count) && count > 0) + { + return result; } await Task.Delay(200, cts.Token); @@ -63,7 +144,8 @@ namespace TestSuite return await assetsClient.GetTagsAsync(app); } - public static async Task WaitForBackupAsync(this IBackupsClient backupsClient, string app, TimeSpan timeout) + public static async Task> WaitForBackupsAsync(this IBackupsClient backupsClient, string app, + Func predicate, TimeSpan timeout) { try { @@ -71,12 +153,11 @@ namespace TestSuite while (!cts.IsCancellationRequested) { - var backups = await backupsClient.GetBackupsAsync(app, cts.Token); - var backup = backups.Items.Find(x => x.Status == JobStatus.Completed || x.Status == JobStatus.Failed); + var result = await backupsClient.GetBackupsAsync(app, cts.Token); - if (backup != null) + if (result.Items.Any(predicate)) { - return backup; + return result.Items; } await Task.Delay(200, cts.Token); @@ -89,7 +170,8 @@ namespace TestSuite return null; } - public static async Task WaitForRestoreAsync(this IBackupsClient backupsClient, Uri url, TimeSpan timeout) + public static async Task WaitForRestoreAsync(this IBackupsClient backupsClient, + Func predicate, TimeSpan timeout) { try { @@ -97,11 +179,11 @@ namespace TestSuite while (!cts.IsCancellationRequested) { - var restore = await backupsClient.GetRestoreJobAsync(cts.Token); + var result = await backupsClient.GetRestoreJobAsync(cts.Token); - if (restore.Url == url && restore.Status is JobStatus.Completed or JobStatus.Failed) + if (predicate(result)) { - return restore; + return result; } await Task.Delay(200, cts.Token); @@ -113,5 +195,93 @@ namespace TestSuite return null; } + + public static async Task DownloadAsync(this ClientManagerFixture fixture, AssetDto asset, int? version = null) + { + var temp = new MemoryStream(); + + using (var client = new HttpClient()) + { + client.BaseAddress = new Uri(fixture.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 static async Task UploadFileAsync(this IAssetsClient assetsClients, string app, string path, + AssetDto asset, string fileName = null) + { + var fileInfo = new FileInfo(path); + + await using (var stream = fileInfo.OpenRead()) + { + var upload = new FileParameter(stream, fileName ?? fileInfo.Name, asset.MimeType); + + return await assetsClients.PutAssetContentAsync(app, asset.Id, upload); + } + } + + public static async Task UploadFileAsync(this IAssetsClient assetsClients, string app, 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 ?? fileInfo.Name, mimeType); + + return await assetsClients.PostAssetAsync(app, parentId, id, true, upload); + } + } + + public static async Task UploadFileAsync(this IAssetsClient assetsClients, string app, 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 assetsClients.PostAssetAsync(app, 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; + } } } diff --git a/backend/tools/TestSuite/TestSuite.Shared/ClientManagerWrapper.cs b/backend/tools/TestSuite/TestSuite.Shared/ClientManagerWrapper.cs index 726486779..533478627 100644 --- a/backend/tools/TestSuite/TestSuite.Shared/ClientManagerWrapper.cs +++ b/backend/tools/TestSuite/TestSuite.Shared/ClientManagerWrapper.cs @@ -19,11 +19,16 @@ namespace TestSuite private readonly Lazy assets; private readonly Lazy comments; private readonly Lazy backups; + private readonly Lazy diagnostics; + private readonly Lazy history; private readonly Lazy languages; private readonly Lazy ping; + private readonly Lazy plans; private readonly Lazy rules; private readonly Lazy schemas; + private readonly Lazy search; private readonly Lazy templates; + private readonly Lazy translations; public SquidexClientManager ClientManager { get; } @@ -47,6 +52,16 @@ namespace TestSuite get => comments.Value; } + public IDiagnosticsClient Diagnostics + { + get => diagnostics.Value; + } + + public IHistoryClient History + { + get => history.Value; + } + public ILanguagesClient Languages { get => languages.Value; @@ -57,6 +72,11 @@ namespace TestSuite get => ping.Value; } + public IPlansClient Plans + { + get => plans.Value; + } + public IRulesClient Rules { get => rules.Value; @@ -67,11 +87,21 @@ namespace TestSuite get => schemas.Value; } + public ISearchClient Search + { + get => search.Value; + } + public ITemplatesClient Templates { get => templates.Value; } + public ITranslationsClient Translations + { + get => translations.Value; + } + public ClientManagerWrapper() { var appName = TestHelpers.GetAndPrintValue("config:app:name", "integration-tests"); @@ -110,6 +140,16 @@ namespace TestSuite return ClientManager.CreateCommentsClient(); }); + diagnostics = new Lazy(() => + { + return ClientManager.CreateDiagnosticsClient(); + }); + + history = new Lazy(() => + { + return ClientManager.CreateHistoryClient(); + }); + languages = new Lazy(() => { return ClientManager.CreateLanguagesClient(); @@ -120,6 +160,11 @@ namespace TestSuite return ClientManager.CreatePingClient(); }); + plans = new Lazy(() => + { + return ClientManager.CreatePlansClient(); + }); + rules = new Lazy(() => { return ClientManager.CreateRulesClient(); @@ -130,10 +175,20 @@ namespace TestSuite return ClientManager.CreateSchemasClient(); }); + search = new Lazy(() => + { + return ClientManager.CreateSearchClient(); + }); + templates = new Lazy(() => { return ClientManager.CreateTemplatesClient(); }); + + translations = new Lazy(() => + { + return ClientManager.CreateTranslationsClient(); + }); } public async Task ConnectAsync() diff --git a/backend/tools/TestSuite/TestSuite.Shared/Fixtures/ClientFixture.cs b/backend/tools/TestSuite/TestSuite.Shared/Fixtures/ClientFixture.cs index bdc0bffe7..8c061f2ea 100644 --- a/backend/tools/TestSuite/TestSuite.Shared/Fixtures/ClientFixture.cs +++ b/backend/tools/TestSuite/TestSuite.Shared/Fixtures/ClientFixture.cs @@ -19,14 +19,24 @@ namespace TestSuite.Fixtures public ICommentsClient Comments => Squidex.Comments; + public IDiagnosticsClient Diagnostics => Squidex.Diagnostics; + + public IHistoryClient History => Squidex.History; + public ILanguagesClient Languages => Squidex.Languages; public IPingClient Ping => Squidex.Ping; + public IPlansClient Plans => Squidex.Plans; + public IRulesClient Rules => Squidex.Rules; public ISchemasClient Schemas => Squidex.Schemas; + public ISearchClient Search => Squidex.Search; + public ITemplatesClient Templates => Squidex.Templates; + + public ITranslationsClient Translations => Squidex.Translations; } } diff --git a/backend/tools/TestSuite/TestSuite.Shared/Fixtures/ClientManagerFixture.cs b/backend/tools/TestSuite/TestSuite.Shared/Fixtures/ClientManagerFixture.cs index 35e2bae51..dc6ec78e2 100644 --- a/backend/tools/TestSuite/TestSuite.Shared/Fixtures/ClientManagerFixture.cs +++ b/backend/tools/TestSuite/TestSuite.Shared/Fixtures/ClientManagerFixture.cs @@ -24,6 +24,20 @@ namespace TestSuite.Fixtures public SquidexClientManager ClientManager => Squidex.ClientManager; + static ClientManagerFixture() + { + VerifierSettings.IgnoreMember("AppName"); + VerifierSettings.IgnoreMember("Created"); + VerifierSettings.IgnoreMember("CreatedBy"); + VerifierSettings.IgnoreMember("EditToken"); + VerifierSettings.IgnoreMember("Href"); + VerifierSettings.IgnoreMember("LastModified"); + VerifierSettings.IgnoreMember("LastModifiedBy"); + VerifierSettings.IgnoreMember("RoleProperties"); + VerifierSettings.IgnoreMember("SchemaName"); + VerifierSettings.IgnoreMembersWithType(); + } + public virtual async Task InitializeAsync() { Squidex = await Factories.CreateAsync(nameof(ClientManagerWrapper), async () => diff --git a/backend/tools/TestSuite/TestSuite.Shared/TestSuite.Shared.csproj b/backend/tools/TestSuite/TestSuite.Shared/TestSuite.Shared.csproj index 515f8bbe0..6c819d5e6 100644 --- a/backend/tools/TestSuite/TestSuite.Shared/TestSuite.Shared.csproj +++ b/backend/tools/TestSuite/TestSuite.Shared/TestSuite.Shared.csproj @@ -16,8 +16,9 @@ - + +