mirror of https://github.com/Squidex/squidex.git
Browse Source
* Started with test suite. * Unified test suite. * Backup tests. * Asset test * Fix asset metada. * Fix element removed.pull/479/head
committed by
GitHub
47 changed files with 1329 additions and 423 deletions
@ -1,25 +0,0 @@ |
|||
|
|||
Microsoft Visual Studio Solution File, Format Version 12.00 |
|||
# Visual Studio Version 16 |
|||
VisualStudioVersion = 16.0.29123.88 |
|||
MinimumVisualStudioVersion = 10.0.40219.1 |
|||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LoadTest", "LoadTest.csproj", "{EC732B4F-576E-4853-880D-AA676966D017}" |
|||
EndProject |
|||
Global |
|||
GlobalSection(SolutionConfigurationPlatforms) = preSolution |
|||
Debug|Any CPU = Debug|Any CPU |
|||
Release|Any CPU = Release|Any CPU |
|||
EndGlobalSection |
|||
GlobalSection(ProjectConfigurationPlatforms) = postSolution |
|||
{EC732B4F-576E-4853-880D-AA676966D017}.Debug|Any CPU.ActiveCfg = Debug|Any CPU |
|||
{EC732B4F-576E-4853-880D-AA676966D017}.Debug|Any CPU.Build.0 = Debug|Any CPU |
|||
{EC732B4F-576E-4853-880D-AA676966D017}.Release|Any CPU.ActiveCfg = Release|Any CPU |
|||
{EC732B4F-576E-4853-880D-AA676966D017}.Release|Any CPU.Build.0 = Release|Any CPU |
|||
EndGlobalSection |
|||
GlobalSection(SolutionProperties) = preSolution |
|||
HideSolutionNode = FALSE |
|||
EndGlobalSection |
|||
GlobalSection(ExtensibilityGlobals) = postSolution |
|||
SolutionGuid = {8ABC073D-D6C6-47F0-AFB6-D42F177D468A} |
|||
EndGlobalSection |
|||
EndGlobal |
|||
@ -1,67 +0,0 @@ |
|||
// ==========================================================================
|
|||
// Squidex Headless CMS
|
|||
// ==========================================================================
|
|||
// Copyright (c) Squidex UG (haftungsbeschraenkt)
|
|||
// All rights reserved. Licensed under the MIT license.
|
|||
// ==========================================================================
|
|||
|
|||
using System.Threading.Tasks; |
|||
using LoadTest.Model; |
|||
using LoadTest.Utils; |
|||
using Squidex.ClientLibrary; |
|||
using Xunit; |
|||
|
|||
namespace LoadTest |
|||
{ |
|||
public class ManyItemsTests |
|||
{ |
|||
private readonly SquidexClient<TestEntity, TestEntityData> client; |
|||
|
|||
public ManyItemsTests() |
|||
{ |
|||
client = TestClient.BuildAsync("multiple").Result; |
|||
} |
|||
|
|||
[Fact] |
|||
public async Task Should_read_many_async() |
|||
{ |
|||
var contents = await client.GetAsync(); |
|||
|
|||
for (var i = contents.Total; i < 20000; i++) |
|||
{ |
|||
await client.CreateAsync(new TestEntityData |
|||
{ |
|||
String = RandomString.Create(1000) |
|||
}, publish: true); |
|||
} |
|||
|
|||
var found = await client.GetAll2Async(); |
|||
|
|||
Assert.Equal(20000, found.Items.Count); |
|||
} |
|||
} |
|||
|
|||
public static class SquidexClientExtensions |
|||
{ |
|||
public static async Task<SquidexEntities<TEntity, TData>> GetAll2Async<TEntity, TData>(this SquidexClient<TEntity, TData> client, int batchSize = 200) |
|||
where TEntity : SquidexEntityBase<TData> |
|||
where TData : class, new() |
|||
{ |
|||
var query = new ODataQuery { Top = batchSize, Skip = 0 }; |
|||
|
|||
var entities = new SquidexEntities<TEntity, TData>(); |
|||
do |
|||
{ |
|||
var getResult = await client.GetAsync(query); |
|||
|
|||
entities.Total = getResult.Total; |
|||
entities.Items.AddRange(getResult.Items); |
|||
|
|||
query.Skip += getResult.Items.Count; |
|||
} |
|||
while (query.Skip < entities.Total); |
|||
|
|||
return entities; |
|||
} |
|||
} |
|||
} |
|||
@ -1,102 +0,0 @@ |
|||
// ==========================================================================
|
|||
// Squidex Headless CMS
|
|||
// ==========================================================================
|
|||
// Copyright (c) Squidex UG (haftungsbeschraenkt)
|
|||
// All rights reserved. Licensed under the MIT license.
|
|||
// ==========================================================================
|
|||
|
|||
using System.Collections.Generic; |
|||
using System.Threading.Tasks; |
|||
using Squidex.ClientLibrary; |
|||
using Squidex.ClientLibrary.Management; |
|||
|
|||
namespace LoadTest.Model |
|||
{ |
|||
public static class TestClient |
|||
{ |
|||
public const string ServerUrl = "http://localhost:5000"; |
|||
|
|||
public const string ClientId = "root"; |
|||
public const string ClientSecret = "xeLd6jFxqbXJrfmNLlO2j1apagGGGSyZJhFnIuHp4I0="; |
|||
|
|||
public const string TestAppName = "integration-tests"; |
|||
|
|||
public static readonly SquidexClientManager ClientManager = |
|||
new SquidexClientManager( |
|||
ServerUrl, |
|||
TestAppName, |
|||
ClientId, |
|||
ClientSecret) |
|||
{ |
|||
ReadResponseAsString = true |
|||
}; |
|||
|
|||
public static async Task<SquidexClient<TestEntity, TestEntityData>> BuildAsync(string schemaName) |
|||
{ |
|||
await CreateAppIfNotExistsAsync(); |
|||
await CreateSchemaIfNotExistsAsync(schemaName); |
|||
|
|||
return ClientManager.GetClient<TestEntity, TestEntityData>(schemaName); |
|||
} |
|||
|
|||
private static async Task CreateAppIfNotExistsAsync() |
|||
{ |
|||
try |
|||
{ |
|||
var apps = ClientManager.CreateAppsClient(); |
|||
|
|||
await apps.PostAppAsync(new CreateAppDto |
|||
{ |
|||
Name = TestAppName |
|||
}); |
|||
} |
|||
catch (SquidexManagementException ex) |
|||
{ |
|||
if (ex.StatusCode != 400) |
|||
{ |
|||
throw; |
|||
} |
|||
} |
|||
} |
|||
|
|||
private static async Task CreateSchemaIfNotExistsAsync(string schemaName) |
|||
{ |
|||
try |
|||
{ |
|||
var schemas = ClientManager.CreateSchemasClient(); |
|||
|
|||
await schemas.PostSchemaAsync(TestAppName, new CreateSchemaDto |
|||
{ |
|||
Name = schemaName, |
|||
Fields = new List<UpsertSchemaFieldDto> |
|||
{ |
|||
new UpsertSchemaFieldDto |
|||
{ |
|||
Name = "number", |
|||
Properties = new NumberFieldPropertiesDto |
|||
{ |
|||
IsRequired = true |
|||
} |
|||
}, |
|||
new UpsertSchemaFieldDto |
|||
{ |
|||
Name = "string", |
|||
Properties = new StringFieldPropertiesDto |
|||
{ |
|||
IsRequired = false |
|||
} |
|||
} |
|||
}, |
|||
IsPublished = true |
|||
}); |
|||
} |
|||
catch (SquidexManagementException ex) |
|||
{ |
|||
if (ex.StatusCode != 400) |
|||
{ |
|||
throw; |
|||
} |
|||
} |
|||
} |
|||
} |
|||
} |
|||
@ -1,51 +0,0 @@ |
|||
// ==========================================================================
|
|||
// Squidex Headless CMS
|
|||
// ==========================================================================
|
|||
// Copyright (c) Squidex UG (haftungsbeschraenkt)
|
|||
// All rights reserved. Licensed under the MIT license.
|
|||
// ==========================================================================
|
|||
|
|||
using System; |
|||
using System.Threading.Tasks; |
|||
using LoadTest.Model; |
|||
using Squidex.ClientLibrary; |
|||
using Squidex.ClientLibrary.Management; |
|||
|
|||
namespace LoadTest |
|||
{ |
|||
public sealed class ReadingFixture : IDisposable |
|||
{ |
|||
public SquidexClient<TestEntity, TestEntityData> Client { get; private set; } |
|||
|
|||
public IAppsClient AppsClient { get; private set; } |
|||
|
|||
public ReadingFixture() |
|||
{ |
|||
Task.Run(async () => |
|||
{ |
|||
Client = await TestClient.BuildAsync("reading"); |
|||
|
|||
var contents = await Client.GetAllAsync(); |
|||
|
|||
if (contents.Total != 10) |
|||
{ |
|||
foreach (var content in contents.Items) |
|||
{ |
|||
await Client.DeleteAsync(content); |
|||
} |
|||
|
|||
for (var i = 10; i > 0; i--) |
|||
{ |
|||
await Client.CreateAsync(new TestEntityData { Number = i }, true); |
|||
} |
|||
} |
|||
|
|||
AppsClient = TestClient.ClientManager.CreateAppsClient(); |
|||
}).Wait(); |
|||
} |
|||
|
|||
public void Dispose() |
|||
{ |
|||
} |
|||
} |
|||
} |
|||
@ -1,31 +0,0 @@ |
|||
// ==========================================================================
|
|||
// Squidex Headless CMS
|
|||
// ==========================================================================
|
|||
// Copyright (c) Squidex UG (haftungsbeschraenkt)
|
|||
// All rights reserved. Licensed under the MIT license.
|
|||
// ==========================================================================
|
|||
|
|||
using System.Threading.Tasks; |
|||
using LoadTest.Model; |
|||
using Squidex.ClientLibrary.Management; |
|||
using Xunit; |
|||
|
|||
namespace LoadTest |
|||
{ |
|||
public sealed class TestUtils |
|||
{ |
|||
[Fact] |
|||
public async Task GenerateAppManyContributorsAsync() |
|||
{ |
|||
var client = TestClient.ClientManager.CreateAppsClient(); |
|||
|
|||
for (var i = 0; i < 200; i++) |
|||
{ |
|||
await client.PostContributorAsync("test", new AssignContributorDto |
|||
{ |
|||
ContributorId = $"hello{i}@squidex.io", Invite = true, Role = "Editor" |
|||
}); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,70 @@ |
|||
// ==========================================================================
|
|||
// Squidex Headless CMS
|
|||
// ==========================================================================
|
|||
// Copyright (c) Squidex UG (haftungsbeschraenkt)
|
|||
// All rights reserved. Licensed under the MIT license.
|
|||
// ==========================================================================
|
|||
|
|||
using System; |
|||
using System.Threading.Tasks; |
|||
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 |
|||
{ |
|||
public class AppCreationTests : IClassFixture<ClientFixture> |
|||
{ |
|||
public ClientFixture _ { get; } |
|||
|
|||
public AppCreationTests(ClientFixture fixture) |
|||
{ |
|||
_ = fixture; |
|||
} |
|||
|
|||
[Fact] |
|||
public async Task Should_create_app() |
|||
{ |
|||
var appName = Guid.NewGuid().ToString(); |
|||
|
|||
var createRequest = new CreateAppDto { Name = appName }; |
|||
|
|||
var app = await _.Apps.PostAppAsync(createRequest); |
|||
|
|||
// Should return create app with correct name.
|
|||
Assert.Equal(appName, app.Name); |
|||
|
|||
var apps = await _.Apps.GetAppsAsync(); |
|||
|
|||
// Should provide new app when apps are queried.
|
|||
Assert.Contains(apps, x => x.Name == appName); |
|||
|
|||
var contributors = await _.Apps.GetContributorsAsync(appName); |
|||
|
|||
// Should not client itself as a contributor.
|
|||
Assert.Empty(contributors.Items); |
|||
|
|||
var clients = await _.Apps.GetClientsAsync(appName); |
|||
|
|||
// Should create default client.
|
|||
Assert.Contains(clients.Items, x => x.Id == "default"); |
|||
} |
|||
|
|||
[Fact] |
|||
public async Task Should_remove_app() |
|||
{ |
|||
var appName = Guid.NewGuid().ToString(); |
|||
|
|||
await _.Apps.PostAppAsync(new CreateAppDto { Name = appName }); |
|||
await _.Apps.DeleteAppAsync(appName); |
|||
|
|||
var apps = await _.Apps.GetAppsAsync(); |
|||
|
|||
// Should not provide deleted app when apps are queried.
|
|||
Assert.DoesNotContain(apps, x => x.Name == appName); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,175 @@ |
|||
// ==========================================================================
|
|||
// Squidex Headless CMS
|
|||
// ==========================================================================
|
|||
// Copyright (c) Squidex UG (haftungsbeschraenkt)
|
|||
// All rights reserved. Licensed under the MIT license.
|
|||
// ==========================================================================
|
|||
|
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Threading.Tasks; |
|||
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 |
|||
{ |
|||
public sealed class AppsTests : IClassFixture<CreatedAppFixture> |
|||
{ |
|||
public CreatedAppFixture _ { get; } |
|||
|
|||
public AppsTests(CreatedAppFixture fixture) |
|||
{ |
|||
_ = fixture; |
|||
} |
|||
|
|||
[Fact] |
|||
public async Task Should_manage_clients() |
|||
{ |
|||
var clientId = "my-client"; |
|||
var clientName = "My Client"; |
|||
var clientRole = "Owner"; |
|||
|
|||
// STEP 1: Create client
|
|||
var createRequest = new CreateClientDto { Id = clientId }; |
|||
|
|||
var clients1 = await _.Apps.PostClientAsync(_.AppName, createRequest); |
|||
|
|||
// Should return client with correct name and id.
|
|||
Assert.Contains(clients1.Items, x => x.Id == clientId && x.Name == clientId && x.Role == "Editor"); |
|||
|
|||
|
|||
// STEP 2: Update client name.
|
|||
var updateNameRequest = new UpdateClientDto { Name = clientName }; |
|||
|
|||
var clients2 = await _.Apps.PutClientAsync(_.AppName, clientId, updateNameRequest); |
|||
|
|||
// Should update client name.
|
|||
Assert.Contains(clients2.Items, x => x.Id == clientId && x.Name == clientName && x.Role == "Editor"); |
|||
|
|||
|
|||
// STEP 3: Update client role.
|
|||
var updateRoleRequest = new UpdateClientDto { Role = clientRole }; |
|||
|
|||
var clients3 = await _.Apps.PutClientAsync(_.AppName, clientId, updateRoleRequest); |
|||
|
|||
// Should update client role.
|
|||
Assert.Contains(clients3.Items, x => x.Id == clientId && x.Name == clientName && x.Role == clientRole); |
|||
|
|||
|
|||
// STEP 4: Delete client
|
|||
var clients4 = await _.Apps.DeleteClientAsync(_.AppName, clientId); |
|||
|
|||
// Should not return deleted client.
|
|||
Assert.DoesNotContain(clients4.Items, x => x.Id == clientId); |
|||
} |
|||
|
|||
[Fact] |
|||
public async Task Should_manage_contributors() |
|||
{ |
|||
var contributorEmail = "hello@squidex.io"; |
|||
var contributorRole = "Owner"; |
|||
|
|||
// STEP 0: Do not invite contributors when flag is false.
|
|||
var createRequest = new AssignContributorDto { ContributorId = "test@squidex.io" }; |
|||
|
|||
var ex = await Assert.ThrowsAsync<SquidexManagementException>(() => |
|||
{ |
|||
return _.Apps.PostContributorAsync(_.AppName, createRequest); |
|||
}); |
|||
|
|||
Assert.Equal(404, ex.StatusCode); |
|||
|
|||
|
|||
// STEP 1: Assign contributor.
|
|||
var createInviteRequest = new AssignContributorDto { ContributorId = contributorEmail, Invite = true }; |
|||
|
|||
var contributors1 = await _.Apps.PostContributorAsync(_.AppName, createInviteRequest); |
|||
|
|||
var id = contributors1.Items.FirstOrDefault(x => x.ContributorName == contributorEmail).ContributorId; |
|||
|
|||
// Should return contributor with correct email.
|
|||
Assert.Contains(contributors1.Items, x => x.ContributorName == contributorEmail && x.Role == "Developer"); |
|||
|
|||
|
|||
// STEP 2: Update contributor role.
|
|||
var updateRequest = new AssignContributorDto { ContributorId = contributorEmail, Role = contributorRole }; |
|||
|
|||
var contributors2 = await _.Apps.PostContributorAsync(_.AppName, updateRequest); |
|||
|
|||
// Should return contributor with correct role.
|
|||
Assert.Contains(contributors2.Items, x => x.ContributorId == id && x.Role == contributorRole); |
|||
|
|||
|
|||
// STEP 3: Remove contributor.
|
|||
var contributors3 = await _.Apps.DeleteContributorAsync(_.AppName, id); |
|||
|
|||
// Should not return deleted contributor.
|
|||
Assert.DoesNotContain(contributors3.Items, x => x.ContributorId == id); |
|||
} |
|||
|
|||
[Fact] |
|||
public async Task Should_manage_roles() |
|||
{ |
|||
var roleName = Guid.NewGuid().ToString(); |
|||
var roleClient = Guid.NewGuid().ToString(); |
|||
var roleContributor = "role@squidex.io"; |
|||
|
|||
// STEP 1: Add role.
|
|||
var createRequest = new AddRoleDto { Name = roleName }; |
|||
|
|||
var roles1 = await _.Apps.PostRoleAsync(_.AppName, createRequest); |
|||
|
|||
// Should return role with correct name.
|
|||
Assert.Contains(roles1.Items, x => x.Name == roleName && x.Permissions.Count == 0); |
|||
|
|||
|
|||
// STEP 2: Update role.
|
|||
var updateRequest = new UpdateRoleDto { Permissions = new List<string> { "a", "b" } }; |
|||
|
|||
var roles2 = await _.Apps.PutRoleAsync(_.AppName, roleName, updateRequest); |
|||
|
|||
// Should return role with correct name.
|
|||
Assert.Contains(roles2.Items, x => x.Name == roleName && x.Permissions.SequenceEqual(updateRequest.Permissions)); |
|||
|
|||
|
|||
// STEP 3: Assign client and contributor.
|
|||
await _.Apps.PostClientAsync(_.AppName, new CreateClientDto { Id = roleClient }); |
|||
await _.Apps.PutClientAsync(_.AppName, roleClient, new UpdateClientDto { Role = roleName }); |
|||
|
|||
await _.Apps.PostContributorAsync(_.AppName, new AssignContributorDto { ContributorId = roleContributor, Role = roleName, Invite = true }); |
|||
|
|||
var roles3 = await _.Apps.GetRolesAsync(_.AppName); |
|||
|
|||
// Should return role with correct number of users and clients.
|
|||
Assert.Contains(roles3.Items, x => x.Name == roleName && x.NumClients == 1 && x.NumContributors == 1); |
|||
|
|||
|
|||
// STEP 4: Try to delete role.
|
|||
var ex = await Assert.ThrowsAsync<SquidexManagementException<ErrorDto>>(() => |
|||
{ |
|||
return _.Apps.DeleteRoleAsync(_.AppName, roleName); |
|||
}); |
|||
|
|||
Assert.Equal(400, ex.StatusCode); |
|||
|
|||
|
|||
// Step 5: Remove after client and contributor removed.
|
|||
var fallbackRole = "Developer"; |
|||
|
|||
await _.Apps.PutClientAsync(_.AppName, roleClient, new UpdateClientDto { Role = fallbackRole }); |
|||
await _.Apps.PostContributorAsync(_.AppName, new AssignContributorDto { ContributorId = roleContributor, Role = fallbackRole }); |
|||
|
|||
await _.Apps.DeleteRoleAsync(_.AppName, roleName); |
|||
|
|||
var roles4 = await _.Apps.GetRolesAsync(_.AppName); |
|||
|
|||
// Should not return deleted role.
|
|||
Assert.DoesNotContain(roles4.Items, x => x.Name == roleName); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,58 @@ |
|||
// ==========================================================================
|
|||
// Squidex Headless CMS
|
|||
// ==========================================================================
|
|||
// Copyright (c) Squidex UG (haftungsbeschraenkt)
|
|||
// All rights reserved. Licensed under the MIT license.
|
|||
// ==========================================================================
|
|||
|
|||
using System; |
|||
using System.IO; |
|||
using System.Threading.Tasks; |
|||
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 |
|||
{ |
|||
public class AssetTests : IClassFixture<AssetFixture> |
|||
{ |
|||
public AssetFixture _ { get; } |
|||
|
|||
public AssetTests(AssetFixture fixture) |
|||
{ |
|||
_ = fixture; |
|||
} |
|||
|
|||
[Fact] |
|||
public async Task Should_upload_image() |
|||
{ |
|||
var fileName = $"{Guid.NewGuid()}.png"; |
|||
|
|||
using (var stream = new FileStream("Assets/logo-squared.png", FileMode.Open)) |
|||
{ |
|||
var asset = await _.Assets.CreateAssetAsync(fileName, "image/png", stream); |
|||
|
|||
Assert.True(asset.IsImage); |
|||
Assert.Equal(600, asset.PixelHeight); |
|||
Assert.Equal(600, asset.PixelWidth); |
|||
} |
|||
} |
|||
|
|||
[Fact] |
|||
public async Task Should_upload_image_without_extension() |
|||
{ |
|||
var fileName = $"{Guid.NewGuid()}.png"; |
|||
|
|||
using (var stream = new FileStream("Assets/logo-squared.png", FileMode.Open)) |
|||
{ |
|||
var asset = await _.Assets.CreateAssetAsync(fileName, "image/png", stream); |
|||
|
|||
Assert.True(asset.IsImage); |
|||
Assert.Equal(600, asset.PixelHeight); |
|||
Assert.Equal(600, asset.PixelWidth); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
|
After Width: | Height: | Size: 19 KiB |
@ -0,0 +1,92 @@ |
|||
// ==========================================================================
|
|||
// Squidex Headless CMS
|
|||
// ==========================================================================
|
|||
// Copyright (c) Squidex UG (haftungsbeschraenkt)
|
|||
// All rights reserved. Licensed under the MIT license.
|
|||
// ==========================================================================
|
|||
|
|||
using System; |
|||
using System.Linq; |
|||
using System.Threading; |
|||
using System.Threading.Tasks; |
|||
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 |
|||
{ |
|||
public class BackupTests : IClassFixture<ClientFixture> |
|||
{ |
|||
public ClientFixture _ { get; } |
|||
|
|||
public BackupTests(ClientFixture fixture) |
|||
{ |
|||
_ = fixture; |
|||
} |
|||
|
|||
[Fact] |
|||
public async Task Should_backup_and_restore_app() |
|||
{ |
|||
var appName = Guid.NewGuid().ToString(); |
|||
var appNameRestore = $"{appName}-restore"; |
|||
|
|||
// STEP 1: Create app
|
|||
var createRequest = new CreateAppDto { Name = appName }; |
|||
|
|||
await _.Apps.PostAppAsync(createRequest); |
|||
|
|||
|
|||
// STEP 2: Create backup
|
|||
await _.Backups.PostBackupAsync(appName); |
|||
|
|||
BackupJobDto backup = null; |
|||
|
|||
using (var cts = new CancellationTokenSource(TimeSpan.FromSeconds(20))) |
|||
{ |
|||
while (true) |
|||
{ |
|||
cts.Token.ThrowIfCancellationRequested(); |
|||
|
|||
await Task.Delay(1000); |
|||
|
|||
var backups = await _.Backups.GetBackupsAsync(appName); |
|||
|
|||
if (backups.Items.Count > 0) |
|||
{ |
|||
backup = backups.Items.FirstOrDefault(); |
|||
|
|||
break; |
|||
} |
|||
} |
|||
} |
|||
|
|||
|
|||
// STEP 3: Restore backup
|
|||
var uri = new Uri($"{_.ServerUrl}{backup._links["download"].Href}"); |
|||
|
|||
var restoreRequest = new RestoreRequestDto { Url = uri, Name = appNameRestore }; |
|||
|
|||
await _.Backups.PostRestoreJobAsync(restoreRequest); |
|||
|
|||
using (var cts = new CancellationTokenSource(TimeSpan.FromSeconds(60))) |
|||
{ |
|||
while (true) |
|||
{ |
|||
cts.Token.ThrowIfCancellationRequested(); |
|||
|
|||
await Task.Delay(1000); |
|||
|
|||
var job = await _.Backups.GetRestoreJobAsync(); |
|||
|
|||
if (job != null && job.Url == uri && job.Status == JobStatus.Completed) |
|||
{ |
|||
break; |
|||
} |
|||
} |
|||
} |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,165 @@ |
|||
// ==========================================================================
|
|||
// Squidex Headless CMS
|
|||
// ==========================================================================
|
|||
// Copyright (c) Squidex UG (haftungsbeschraenkt)
|
|||
// All rights reserved. Licensed under the MIT license.
|
|||
// ==========================================================================
|
|||
|
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Threading.Tasks; |
|||
using Newtonsoft.Json; |
|||
using Newtonsoft.Json.Linq; |
|||
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
|
|||
|
|||
namespace TestSuite.ApiTests |
|||
{ |
|||
public class ContentQueryTests : IClassFixture<ContentQueryFixture> |
|||
{ |
|||
public ContentQueryFixture _ { get; } |
|||
|
|||
public ContentQueryTests(ContentQueryFixture fixture) |
|||
{ |
|||
_ = fixture; |
|||
} |
|||
|
|||
[Fact] |
|||
public async Task Should_query_by_ids() |
|||
{ |
|||
var items = await _.Contents.GetAsync(new ODataQuery { OrderBy = "data/number/iv asc" }); |
|||
|
|||
var itemsById = await _.Contents.GetAsync(new HashSet<Guid>(items.Items.Take(3).Select(x => x.EntityId))); |
|||
|
|||
Assert.Equal(3, itemsById.Items.Count); |
|||
Assert.Equal(3, itemsById.Total); |
|||
|
|||
foreach (var item in itemsById.Items) |
|||
{ |
|||
Assert.Equal(_.AppName, item.AppName); |
|||
Assert.Equal(_.SchemaName, item.SchemaName); |
|||
} |
|||
} |
|||
|
|||
[Fact] |
|||
public async Task Should_return_all() |
|||
{ |
|||
var items = await _.Contents.GetAsync(new ODataQuery { OrderBy = "data/number/iv asc" }); |
|||
|
|||
AssertItems(items, 10, new[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }); |
|||
} |
|||
|
|||
[Fact] |
|||
public async Task Should_return_items_with_skip() |
|||
{ |
|||
var items = await _.Contents.GetAsync(new ODataQuery { Skip = 5, OrderBy = "data/number/iv asc" }); |
|||
|
|||
AssertItems(items, 10, new[] { 6, 7, 8, 9, 10 }); |
|||
} |
|||
|
|||
[Fact] |
|||
public async Task Should_return_items_with_skip_and_top() |
|||
{ |
|||
var items = await _.Contents.GetAsync(new ODataQuery { Skip = 2, Top = 5, OrderBy = "data/number/iv asc" }); |
|||
|
|||
AssertItems(items, 10, new[] { 3, 4, 5, 6, 7 }); |
|||
} |
|||
|
|||
[Fact] |
|||
public async Task Should_return_items_with_ordering() |
|||
{ |
|||
var items = await _.Contents.GetAsync(new ODataQuery { Skip = 2, Top = 5, OrderBy = "data/number/iv desc" }); |
|||
|
|||
AssertItems(items, 10, new[] { 8, 7, 6, 5, 4 }); |
|||
} |
|||
|
|||
[Fact] |
|||
public async Task Should_return_items_with_filter() |
|||
{ |
|||
var items = await _.Contents.GetAsync(new ODataQuery { Filter = "data/number/iv gt 3 and data/number/iv lt 7", OrderBy = "data/number/iv asc" }); |
|||
|
|||
AssertItems(items, 3, new[] { 4, 5, 6 }); |
|||
} |
|||
|
|||
[Fact] |
|||
public async Task Should_query_items_with_graphql() |
|||
{ |
|||
var query = new |
|||
{ |
|||
query = @"
|
|||
{ |
|||
queryNumbersContents(filter: ""data/number/iv gt 3 and data/number/iv lt 7"", orderby: ""data/number/iv asc"") { |
|||
id, |
|||
data { |
|||
value { |
|||
iv |
|||
} |
|||
} |
|||
} |
|||
}"
|
|||
}; |
|||
|
|||
var result = await _.Contents.GraphQlAsync<QueryResult>(query); |
|||
|
|||
var items = result.Items; |
|||
|
|||
Assert.Equal(items.Select(x => x.Data.Value).ToArray(), new[] { 4, 5, 6 }); |
|||
} |
|||
|
|||
[Fact] |
|||
public async Task Should_query_items_with_graphql_with_dynamic() |
|||
{ |
|||
var query = new |
|||
{ |
|||
query = @"
|
|||
{ |
|||
queryNumbersContents(filter: ""data/number/iv gt 3 and data/number/iv lt 7"", orderby: ""data/number/iv asc"") { |
|||
id, |
|||
data { |
|||
value { |
|||
iv |
|||
} |
|||
} |
|||
} |
|||
}"
|
|||
}; |
|||
|
|||
var result = await _.Contents.GraphQlAsync<JObject>(query); |
|||
|
|||
var items = result["queryNumbersContents"]; |
|||
|
|||
Assert.Equal(items.Select(x => x["data"]["value"]["iv"].Value<int>()).ToArray(), new[] { 4, 5, 6 }); |
|||
} |
|||
|
|||
private sealed class QueryResult |
|||
{ |
|||
[JsonProperty("queryNumbersContents")] |
|||
public QueryItem[] Items { get; set; } |
|||
} |
|||
|
|||
private sealed class QueryItem |
|||
{ |
|||
public Guid Id { get; set; } |
|||
|
|||
public QueryItemData Data { get; set; } |
|||
} |
|||
|
|||
private sealed class QueryItemData |
|||
{ |
|||
[JsonConverter(typeof(InvariantConverter))] |
|||
public int Value { get; set; } |
|||
} |
|||
|
|||
private void AssertItems(SquidexEntities<TestEntity, TestEntityData> entities, int total, int[] expected) |
|||
{ |
|||
Assert.Equal(total, entities.Total); |
|||
Assert.Equal(expected, entities.Items.Select(x => x.Data.Number).ToArray()); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,186 @@ |
|||
// ==========================================================================
|
|||
// Squidex Headless CMS
|
|||
// ==========================================================================
|
|||
// Copyright (c) Squidex UG (haftungsbeschraenkt)
|
|||
// All rights reserved. Licensed under the MIT license.
|
|||
// ==========================================================================
|
|||
|
|||
using System.Threading.Tasks; |
|||
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
|
|||
|
|||
namespace TestSuite.ApiTests |
|||
{ |
|||
public class ContentUpdateTests : IClassFixture<ContentFixture> |
|||
{ |
|||
public ContentFixture _ { get; } |
|||
|
|||
public ContentUpdateTests(ContentFixture fixture) |
|||
{ |
|||
_ = fixture; |
|||
} |
|||
|
|||
[Fact] |
|||
public async Task Should_create_strange_text() |
|||
{ |
|||
const string text = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.88 Safari/537.36"; |
|||
|
|||
TestEntity content = null; |
|||
try |
|||
{ |
|||
content = await _.Contents.CreateAsync(new TestEntityData { String = text }, true); |
|||
|
|||
var updated = await _.Contents.GetAsync(content.Id); |
|||
|
|||
Assert.Equal(text, updated.Data.String); |
|||
} |
|||
finally |
|||
{ |
|||
await _.Contents.DeleteAsync(content.Id); |
|||
} |
|||
} |
|||
|
|||
[Fact] |
|||
public async Task Should_not_return_not_published_item() |
|||
{ |
|||
TestEntity content = null; |
|||
try |
|||
{ |
|||
content = await _.Contents.CreateAsync(new TestEntityData { Number = 1 }); |
|||
|
|||
await Assert.ThrowsAsync<SquidexException>(() => _.Contents.GetAsync(content.Id)); |
|||
} |
|||
finally |
|||
{ |
|||
await _.Contents.DeleteAsync(content.Id); |
|||
} |
|||
} |
|||
|
|||
[Fact] |
|||
public async Task Should_return_item_published_with_creation() |
|||
{ |
|||
TestEntity content = null; |
|||
try |
|||
{ |
|||
content = await _.Contents.CreateAsync(new TestEntityData { Number = 1 }, true); |
|||
|
|||
await _.Contents.GetAsync(content.Id); |
|||
} |
|||
finally |
|||
{ |
|||
await _.Contents.DeleteAsync(content.Id); |
|||
} |
|||
} |
|||
|
|||
[Fact] |
|||
public async Task Should_return_item_published_item() |
|||
{ |
|||
TestEntity content = null; |
|||
try |
|||
{ |
|||
content = await _.Contents.CreateAsync(new TestEntityData { Number = 1 }); |
|||
|
|||
await _.Contents.ChangeStatusAsync(content.Id, Status.Published); |
|||
await _.Contents.GetAsync(content.Id); |
|||
} |
|||
finally |
|||
{ |
|||
await _.Contents.DeleteAsync(content.Id); |
|||
} |
|||
} |
|||
|
|||
[Fact] |
|||
public async Task Should_not_return_archived_item() |
|||
{ |
|||
TestEntity content = null; |
|||
try |
|||
{ |
|||
content = await _.Contents.CreateAsync(new TestEntityData { Number = 1 }, true); |
|||
|
|||
await _.Contents.ChangeStatusAsync(content.Id, Status.Archived); |
|||
|
|||
await Assert.ThrowsAsync<SquidexException>(() => _.Contents.GetAsync(content.Id)); |
|||
} |
|||
finally |
|||
{ |
|||
await _.Contents.DeleteAsync(content.Id); |
|||
} |
|||
} |
|||
|
|||
[Fact] |
|||
public async Task Should_not_return_unpublished_item() |
|||
{ |
|||
TestEntity content = null; |
|||
try |
|||
{ |
|||
content = await _.Contents.CreateAsync(new TestEntityData { Number = 1 }); |
|||
|
|||
await _.Contents.ChangeStatusAsync(content.Id, Status.Published); |
|||
await _.Contents.ChangeStatusAsync(content.Id, Status.Draft); |
|||
|
|||
await Assert.ThrowsAsync<SquidexException>(() => _.Contents.GetAsync(content.Id)); |
|||
} |
|||
finally |
|||
{ |
|||
await _.Contents.DeleteAsync(content.Id); |
|||
} |
|||
} |
|||
|
|||
[Fact] |
|||
public async Task Should_update_item() |
|||
{ |
|||
TestEntity content = null; |
|||
try |
|||
{ |
|||
content = await _.Contents.CreateAsync(new TestEntityData { Number = 2 }, true); |
|||
|
|||
await _.Contents.UpdateAsync(content.Id, new TestEntityData { Number = 2 }); |
|||
|
|||
var updated = await _.Contents.GetAsync(content.Id); |
|||
|
|||
Assert.Equal(2, updated.Data.Number); |
|||
} |
|||
finally |
|||
{ |
|||
await _.Contents.DeleteAsync(content.Id); |
|||
} |
|||
} |
|||
|
|||
[Fact] |
|||
public async Task Should_patch_item() |
|||
{ |
|||
TestEntity content = null; |
|||
try |
|||
{ |
|||
content = await _.Contents.CreateAsync(new TestEntityData { Number = 1 }, true); |
|||
|
|||
await _.Contents.PatchAsync(content.Id, new TestEntityData { Number = 2 }); |
|||
|
|||
var updated = await _.Contents.GetAsync(content.Id); |
|||
|
|||
Assert.Equal(2, updated.Data.Number); |
|||
} |
|||
finally |
|||
{ |
|||
await _.Contents.DeleteAsync(content.Id); |
|||
} |
|||
} |
|||
|
|||
[Fact] |
|||
public async Task Should_delete_item() |
|||
{ |
|||
var content = await _.Contents.CreateAsync(new TestEntityData { Number = 2 }, true); |
|||
|
|||
await _.Contents.DeleteAsync(content.Id); |
|||
|
|||
var updated = await _.Contents.GetAsync(); |
|||
|
|||
Assert.DoesNotContain(updated.Items, x => x.Id == content.Id); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,33 @@ |
|||
<Project Sdk="Microsoft.NET.Sdk"> |
|||
<PropertyGroup> |
|||
<OutputType>Exe</OutputType> |
|||
<TargetFramework>netcoreapp3.0</TargetFramework> |
|||
</PropertyGroup> |
|||
<ItemGroup> |
|||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.4.0" /> |
|||
<PackageReference Include="RefactoringEssentials" Version="5.6.0" PrivateAssets="all" /> |
|||
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118" PrivateAssets="all" /> |
|||
<PackageReference Include="xunit" Version="2.4.1" /> |
|||
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1"> |
|||
<PrivateAssets>all</PrivateAssets> |
|||
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets> |
|||
</PackageReference> |
|||
</ItemGroup> |
|||
<PropertyGroup> |
|||
<CodeAnalysisRuleSet>..\..\..\Squidex.ruleset</CodeAnalysisRuleSet> |
|||
</PropertyGroup> |
|||
<ItemGroup> |
|||
<AdditionalFiles Include="..\..\..\stylecop.json" Link="stylecop.json" /> |
|||
</ItemGroup> |
|||
<ItemGroup> |
|||
<ProjectReference Include="..\TestSuite.Shared\TestSuite.Shared.csproj" /> |
|||
</ItemGroup> |
|||
<ItemGroup> |
|||
<Folder Include="Assets\" /> |
|||
</ItemGroup> |
|||
<ItemGroup> |
|||
<None Update="Assets\logo-squared.png"> |
|||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> |
|||
</None> |
|||
</ItemGroup> |
|||
</Project> |
|||
@ -0,0 +1,71 @@ |
|||
// ==========================================================================
|
|||
// Squidex Headless CMS
|
|||
// ==========================================================================
|
|||
// Copyright (c) Squidex UG (haftungsbeschraenkt)
|
|||
// All rights reserved. Licensed under the MIT license.
|
|||
// ==========================================================================
|
|||
|
|||
using System.Collections.Generic; |
|||
using System.Threading.Tasks; |
|||
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.LoadTests |
|||
{ |
|||
public class ReadingBenchmarks : IClassFixture<CreatedAppFixture> |
|||
{ |
|||
public CreatedAppFixture _ { get; } |
|||
|
|||
public ReadingBenchmarks(CreatedAppFixture fixture) |
|||
{ |
|||
_ = fixture; |
|||
} |
|||
|
|||
public static IEnumerable<object[]> Loads() |
|||
{ |
|||
int[] users = |
|||
{ |
|||
1, |
|||
5, |
|||
10, |
|||
20, |
|||
50, |
|||
100 |
|||
}; |
|||
|
|||
int[] loads = |
|||
{ |
|||
1, |
|||
5, |
|||
10, |
|||
20, |
|||
50, |
|||
100, |
|||
1000 |
|||
}; |
|||
|
|||
foreach (var user in users) |
|||
{ |
|||
foreach (var load in loads) |
|||
{ |
|||
yield return new object[] { user, load }; |
|||
} |
|||
} |
|||
|
|||
yield return new object[] { 1, 20000 }; |
|||
} |
|||
|
|||
[Theory] |
|||
[MemberData(nameof(Loads))] |
|||
public async Task Should_return_clients(int numUsers, int numIterationsPerUser) |
|||
{ |
|||
await Run.Parallel(numUsers, numIterationsPerUser, async () => |
|||
{ |
|||
await _.Apps.GetClientsAsync(_.AppName); |
|||
}); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,19 @@ |
|||
// ==========================================================================
|
|||
// Squidex Headless CMS
|
|||
// ==========================================================================
|
|||
// Copyright (c) Squidex UG (haftungsbeschraenkt)
|
|||
// All rights reserved. Licensed under the MIT license.
|
|||
// ==========================================================================
|
|||
|
|||
using TestSuite.Fixtures; |
|||
|
|||
namespace TestSuite.LoadTests |
|||
{ |
|||
public sealed class ReadingFixture : ContentFixture |
|||
{ |
|||
public ReadingFixture() |
|||
: base("benchmark_reading") |
|||
{ |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,21 @@ |
|||
// ==========================================================================
|
|||
// Squidex Headless CMS
|
|||
// ==========================================================================
|
|||
// Copyright (c) Squidex UG (haftungsbeschraenkt)
|
|||
// All rights reserved. Licensed under the MIT license.
|
|||
// ==========================================================================
|
|||
|
|||
using Squidex.ClientLibrary; |
|||
|
|||
namespace TestSuite.Fixtures |
|||
{ |
|||
public class AssetFixture : CreatedAppFixture |
|||
{ |
|||
public SquidexAssetClient Assets { get; } |
|||
|
|||
public AssetFixture() |
|||
{ |
|||
Assets = ClientManager.GetAssetClient(); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,38 @@ |
|||
// ==========================================================================
|
|||
// Squidex Headless CMS
|
|||
// ==========================================================================
|
|||
// Copyright (c) Squidex UG (haftungsbeschraenkt)
|
|||
// All rights reserved. Licensed under the MIT license.
|
|||
// ==========================================================================
|
|||
|
|||
using System; |
|||
using Squidex.ClientLibrary; |
|||
using Squidex.ClientLibrary.Management; |
|||
using TestSuite.Model; |
|||
|
|||
namespace TestSuite.Fixtures |
|||
{ |
|||
public class ClientFixture : IDisposable |
|||
{ |
|||
public SquidexClientManager ClientManager { get; } |
|||
|
|||
public IAppsClient Apps { get; } |
|||
|
|||
public IBackupsClient Backups { get; } |
|||
|
|||
public string ServerUrl { get; } = TestClient.ServerUrl; |
|||
|
|||
public ClientFixture() |
|||
{ |
|||
ClientManager = TestClient.ClientManager; |
|||
|
|||
Apps = ClientManager.CreateAppsClient(); |
|||
|
|||
Backups = ClientManager.CreateBackupsClient(); |
|||
} |
|||
|
|||
public virtual void Dispose() |
|||
{ |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,73 @@ |
|||
// ==========================================================================
|
|||
// Squidex Headless CMS
|
|||
// ==========================================================================
|
|||
// Copyright (c) Squidex UG (haftungsbeschraenkt)
|
|||
// All rights reserved. Licensed under the MIT license.
|
|||
// ==========================================================================
|
|||
|
|||
using System.Collections.Generic; |
|||
using System.Threading.Tasks; |
|||
using Squidex.ClientLibrary; |
|||
using Squidex.ClientLibrary.Management; |
|||
using TestSuite.Model; |
|||
|
|||
namespace TestSuite.Fixtures |
|||
{ |
|||
public class ContentFixture : CreatedAppFixture |
|||
{ |
|||
public SquidexClient<TestEntity, TestEntityData> Contents { get; } |
|||
|
|||
public string SchemaName { get; } |
|||
|
|||
public string FieldNumber { get; } = "number"; |
|||
|
|||
public string FieldString { get; } = "string"; |
|||
|
|||
public ContentFixture(string schemaName = "my-schema") |
|||
{ |
|||
SchemaName = schemaName; |
|||
|
|||
Task.Run(async () => |
|||
{ |
|||
try |
|||
{ |
|||
var schemas = ClientManager.CreateSchemasClient(); |
|||
|
|||
await schemas.PostSchemaAsync(TestClient.TestAppName, new CreateSchemaDto |
|||
{ |
|||
Name = SchemaName, |
|||
Fields = new List<UpsertSchemaFieldDto> |
|||
{ |
|||
new UpsertSchemaFieldDto |
|||
{ |
|||
Name = FieldNumber, |
|||
Properties = new NumberFieldPropertiesDto |
|||
{ |
|||
IsRequired = true |
|||
} |
|||
}, |
|||
new UpsertSchemaFieldDto |
|||
{ |
|||
Name = FieldString, |
|||
Properties = new StringFieldPropertiesDto |
|||
{ |
|||
IsRequired = false |
|||
} |
|||
} |
|||
}, |
|||
IsPublished = true |
|||
}); |
|||
} |
|||
catch (SquidexManagementException ex) |
|||
{ |
|||
if (ex.StatusCode != 400) |
|||
{ |
|||
throw; |
|||
} |
|||
} |
|||
}); |
|||
|
|||
Contents = ClientManager.GetClient<TestEntity, TestEntityData>(SchemaName); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,43 @@ |
|||
// ==========================================================================
|
|||
// Squidex Headless CMS
|
|||
// ==========================================================================
|
|||
// Copyright (c) Squidex UG (haftungsbeschraenkt)
|
|||
// All rights reserved. Licensed under the MIT license.
|
|||
// ==========================================================================
|
|||
|
|||
using System.Threading.Tasks; |
|||
using Squidex.ClientLibrary; |
|||
using TestSuite.Model; |
|||
|
|||
namespace TestSuite.Fixtures |
|||
{ |
|||
public class ContentQueryFixture : ContentFixture |
|||
{ |
|||
public ContentQueryFixture(string schemaName = "my-schema") |
|||
: base(schemaName) |
|||
{ |
|||
Task.Run(async () => |
|||
{ |
|||
Dispose(); |
|||
|
|||
for (var i = 10; i > 0; i--) |
|||
{ |
|||
await Contents.CreateAsync(new TestEntityData { Number = i }, true); |
|||
} |
|||
}).Wait(); |
|||
} |
|||
|
|||
public override void Dispose() |
|||
{ |
|||
Task.Run(async () => |
|||
{ |
|||
var contents = await Contents.GetAllAsync(); |
|||
|
|||
foreach (var content in contents.Items) |
|||
{ |
|||
await Contents.DeleteAsync(content); |
|||
} |
|||
}); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,38 @@ |
|||
// ==========================================================================
|
|||
// Squidex Headless CMS
|
|||
// ==========================================================================
|
|||
// Copyright (c) Squidex UG (haftungsbeschraenkt)
|
|||
// All rights reserved. Licensed under the MIT license.
|
|||
// ==========================================================================
|
|||
|
|||
using System.Threading.Tasks; |
|||
using Squidex.ClientLibrary.Management; |
|||
using TestSuite.Model; |
|||
|
|||
namespace TestSuite.Fixtures |
|||
{ |
|||
public class CreatedAppFixture : ClientFixture |
|||
{ |
|||
public string AppName { get; } = TestClient.TestAppName; |
|||
|
|||
public CreatedAppFixture() |
|||
{ |
|||
Task.Run(async () => |
|||
{ |
|||
try |
|||
{ |
|||
await Apps.PostAppAsync(new CreateAppDto { Name = AppName }); |
|||
} |
|||
catch (SquidexManagementException ex) |
|||
{ |
|||
if (ex.StatusCode != 400) |
|||
{ |
|||
throw; |
|||
} |
|||
} |
|||
|
|||
await Apps.PostContributorAsync(AppName, new AssignContributorDto { ContributorId = "sebastian@squidex.io", Invite = true, Role = "Owner" }); |
|||
}).Wait(); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,31 @@ |
|||
// ==========================================================================
|
|||
// Squidex Headless CMS
|
|||
// ==========================================================================
|
|||
// Copyright (c) Squidex UG (haftungsbeschraenkt)
|
|||
// All rights reserved. Licensed under the MIT license.
|
|||
// ==========================================================================
|
|||
|
|||
using Squidex.ClientLibrary; |
|||
|
|||
namespace TestSuite.Model |
|||
{ |
|||
internal static class TestClient |
|||
{ |
|||
public const string ServerUrl = "http://localhost:5000"; |
|||
|
|||
public const string ClientId = "root"; |
|||
public const string ClientSecret = "xeLd6jFxqbXJrfmNLlO2j1apagGGGSyZJhFnIuHp4I0="; |
|||
|
|||
public const string TestAppName = "integration-tests"; |
|||
|
|||
public static readonly SquidexClientManager ClientManager = |
|||
new SquidexClientManager( |
|||
ServerUrl, |
|||
TestAppName, |
|||
ClientId, |
|||
ClientSecret) |
|||
{ |
|||
ReadResponseAsString = true |
|||
}; |
|||
} |
|||
} |
|||
@ -0,0 +1,18 @@ |
|||
<Project Sdk="Microsoft.NET.Sdk"> |
|||
<PropertyGroup> |
|||
<TargetFramework>netcoreapp3.0</TargetFramework> |
|||
</PropertyGroup> |
|||
<ItemGroup> |
|||
<PackageReference Include="RefactoringEssentials" Version="5.6.0" PrivateAssets="all" /> |
|||
<PackageReference Include="Squidex.ClientLibrary" Version="4.0.2" /> |
|||
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118" PrivateAssets="all" /> |
|||
<PackageReference Include="xunit" Version="2.4.1" /> |
|||
</ItemGroup> |
|||
<PropertyGroup> |
|||
<CodeAnalysisRuleSet>..\..\..\Squidex.ruleset</CodeAnalysisRuleSet> |
|||
<RootNamespace>TestSuite</RootNamespace> |
|||
</PropertyGroup> |
|||
<ItemGroup> |
|||
<AdditionalFiles Include="..\..\..\stylecop.json" Link="stylecop.json" /> |
|||
</ItemGroup> |
|||
</Project> |
|||
@ -0,0 +1,37 @@ |
|||
|
|||
Microsoft Visual Studio Solution File, Format Version 12.00 |
|||
# Visual Studio Version 16 |
|||
VisualStudioVersion = 16.0.29613.14 |
|||
MinimumVisualStudioVersion = 10.0.40219.1 |
|||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestSuite.Shared", "TestSuite.Shared\TestSuite.Shared.csproj", "{37484845-5542-4E52-AB00-C4576B84FE75}" |
|||
EndProject |
|||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestSuite.ApiTests", "TestSuite.ApiTests\TestSuite.ApiTests.csproj", "{E5F048CB-5307-4E4C-8DAB-2F1C0E5CACF3}" |
|||
EndProject |
|||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestSuite.LoadTests", "TestSuite.LoadTests\TestSuite.LoadTests.csproj", "{F37572D9-4880-40F4-B3CB-83F58A40CA48}" |
|||
EndProject |
|||
Global |
|||
GlobalSection(SolutionConfigurationPlatforms) = preSolution |
|||
Debug|Any CPU = Debug|Any CPU |
|||
Release|Any CPU = Release|Any CPU |
|||
EndGlobalSection |
|||
GlobalSection(ProjectConfigurationPlatforms) = postSolution |
|||
{37484845-5542-4E52-AB00-C4576B84FE75}.Debug|Any CPU.ActiveCfg = Debug|Any CPU |
|||
{37484845-5542-4E52-AB00-C4576B84FE75}.Debug|Any CPU.Build.0 = Debug|Any CPU |
|||
{37484845-5542-4E52-AB00-C4576B84FE75}.Release|Any CPU.ActiveCfg = Release|Any CPU |
|||
{37484845-5542-4E52-AB00-C4576B84FE75}.Release|Any CPU.Build.0 = Release|Any CPU |
|||
{E5F048CB-5307-4E4C-8DAB-2F1C0E5CACF3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU |
|||
{E5F048CB-5307-4E4C-8DAB-2F1C0E5CACF3}.Debug|Any CPU.Build.0 = Debug|Any CPU |
|||
{E5F048CB-5307-4E4C-8DAB-2F1C0E5CACF3}.Release|Any CPU.ActiveCfg = Release|Any CPU |
|||
{E5F048CB-5307-4E4C-8DAB-2F1C0E5CACF3}.Release|Any CPU.Build.0 = Release|Any CPU |
|||
{F37572D9-4880-40F4-B3CB-83F58A40CA48}.Debug|Any CPU.ActiveCfg = Debug|Any CPU |
|||
{F37572D9-4880-40F4-B3CB-83F58A40CA48}.Debug|Any CPU.Build.0 = Debug|Any CPU |
|||
{F37572D9-4880-40F4-B3CB-83F58A40CA48}.Release|Any CPU.ActiveCfg = Release|Any CPU |
|||
{F37572D9-4880-40F4-B3CB-83F58A40CA48}.Release|Any CPU.Build.0 = Release|Any CPU |
|||
EndGlobalSection |
|||
GlobalSection(SolutionProperties) = preSolution |
|||
HideSolutionNode = FALSE |
|||
EndGlobalSection |
|||
GlobalSection(ExtensibilityGlobals) = postSolution |
|||
SolutionGuid = {9F1CDBED-7D91-4B46-B4C5-0FE086E29285} |
|||
EndGlobalSection |
|||
EndGlobal |
|||
Loading…
Reference in new issue