Browse Source

Test strange IDs and minor fix to handle APP ID.

pull/1069/head 7.13.0
Sebastian Stehle 3 years ago
parent
commit
752c9f967c
  1. 2
      backend/src/Squidex.Domain.Apps.Entities.MongoDb/ShardedSnapshotStore.cs
  2. 22
      tools/TestSuite/TestSuite.ApiTests/ContentUpdateTests.cs

2
backend/src/Squidex.Domain.Apps.Entities.MongoDb/ShardedSnapshotStore.cs

@ -91,7 +91,7 @@ public abstract class ShardedSnapshotStore<T, TState> : ShardedService<T>, ISnap
// This is a leaky abstraction, but the only option to implement that in a fast way.
var parts = key.ToString().Split(DomainId.IdSeparator);
if (parts.Length != 2)
if (parts.Length < 2)
{
throw new InvalidOperationException("The key does not contain an app id.");
}

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

@ -330,6 +330,28 @@ public class ContentUpdateTests : IClassFixture<ContentFixture>
Assert.Equal(3, content.Data.Number);
}
[Theory]
[InlineData("e5f7c399-6024-4367-9538-b7de4bced0f9' UNION ALL SELECT NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL-- vIGQ")]
[InlineData("e5f7c399-6024-4367-9538-b7de4bced0f9') UNION ALL SELECT 59,59,59,'qkjvq'||'FWUHnOHbQqCmewsQoKRPxqUXmHZMTtqHmyYoRhwu'||'qvpkq',59-- dLuxn")]
public async Task Should_create_and_delete_content_with_strange_id(string id)
{
// STEP 1: Upsert a new item with a custom id.
var content_0 = await _.Contents.UpsertAsync(id, new TestEntityData(), ContentUpsertOptions.AsPublish);
Assert.Equal(id, content_0.Id);
// STEP 2: Find content
var content_1 = await _.Contents.GetAsync(id);
Assert.Equal(id, content_1.Id);
// STEP 3: Delete content.
await _.Contents.DeleteAsync(id);
await Assert.ThrowsAnyAsync<SquidexException>(() => _.Contents.GetAsync(id));
}
[Theory]
[InlineData(ContentStrategies.Update.Normal)]
[InlineData(ContentStrategies.Update.Upsert)]

Loading…
Cancel
Save