Skip to content

Commit

Permalink
Test strange IDs and minor fix to handle APP ID.
Browse files Browse the repository at this point in the history
  • Loading branch information
SebastianStehle committed Jan 24, 2024
1 parent 8573a28 commit 752c9f9
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ private static DomainId GetAppId(DomainId key)
// 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.");
}
Expand Down
22 changes: 22 additions & 0 deletions tools/TestSuite/TestSuite.ApiTests/ContentUpdateTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,28 @@ public async Task Should_create_content_with_custom_id_and_upsert()
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)]
Expand Down

0 comments on commit 752c9f9

Please sign in to comment.