-
Notifications
You must be signed in to change notification settings - Fork 0
Consistent POST/PUT behaviour #503
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
p-kaczynski
wants to merge
26
commits into
develop
Choose a base branch
from
feature/464/consistent_put_post
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
e8a554b
Manifest path test
p-kaczynski cdedc7e
Implement handling `id` in manifest body
p-kaczynski b7f2d46
Add differentiation of hierarchical posts manifest/collection
p-kaczynski 153355f
Add tests for valid collection creation paths
p-kaczynski d791b3b
Implement/fix POST/PUT hierarchical collection endpoints per tests
p-kaczynski 0a9c377
Make UpsertCollection return Created/Updated result correctly
p-kaczynski 2e2d8ab
Update Collection PUT/POST tests
p-kaczynski a0126a2
Create CollectionWriteRequest.cs
p-kaczynski 718558a
Add class that produced "pure" IIIF from our Presentation* classes
p-kaczynski 80f0470
Add test method `HttpRequestMessageBuilder.GetPlainRequest` that can …
p-kaczynski 539ffa3
Add `Forbidden` result/error
p-kaczynski bd6f7c8
Update `ModifyCollectionTests` as per docs
p-kaczynski 8d43be6
Handle `Forbidden` result in Controller base
p-kaczynski b97b90f
Add explicit `ExtraHeaderRequired` to modify collection type enumeration
p-kaczynski 3463487
Prevent invalid collection hierarchy retrieval if provided slug ends …
p-kaczynski d65fbfb
Unify collection handling to support all required scenarios
p-kaczynski 501ae47
Include ETags in collection tests per new functionality
p-kaczynski d8edee2
Add necessary root validation
p-kaczynski 91a230a
TEMP: Manifest handling
p-kaczynski 4fb40c9
Revert previous id handling from MWS
p-kaczynski ed53e4a
Implement a unified manifest dispatch request
p-kaczynski f8f231d
Update to use new DispatchManifestRequest
p-kaczynski a4622ce
Fix validation in updated manifest handling
p-kaczynski 495e86a
Add code that checks hierarchical parent from path with flat parent f…
p-kaczynski b1a3272
Fix invalid test cases
p-kaczynski 5cb2849
Clean-up code, update comments and ensure all cases are handled
p-kaczynski File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
106 changes: 106 additions & 0 deletions
106
src/IIIFPresentation/API.Tests/Converters/FastJsonPropertyReadTests.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,106 @@ | ||
| using API.Converters; | ||
|
|
||
| namespace API.Tests.Converters; | ||
|
|
||
| public class FastJsonPropertyReadTests | ||
| { | ||
| [Fact] | ||
| public void FindAtLevel_FindsValue_DefaultTopLevel() | ||
| { | ||
| FastJsonPropertyRead.FindAtLevel(Json, "searchedProperty").Should() | ||
| .Be("fnord", "it's the value of 'searchedProperty' in sample JSON"); | ||
| } | ||
|
|
||
| [Fact] | ||
| public void FindAtLevel_FindsValue_Deeper() | ||
| { | ||
| FastJsonPropertyRead.FindAtLevel(Json, "priority", 3).Should() | ||
| .Be("high", "it's the value of first instance of 'priority' property in sample JSON"); | ||
| } | ||
|
|
||
| [Fact] | ||
| public void FindAtLevel_ReturnsNull_IfNotFound() | ||
| { | ||
| FastJsonPropertyRead.FindAtLevel(Json, "i don't exist in the json").Should() | ||
| .BeNull("no such property in the JSON"); | ||
| } | ||
|
|
||
| // just some arbitrary JSON - the method under test is not IIIF specific | ||
| private const string Json = | ||
|
|
||
| #region <sample json> | ||
|
|
||
| """ | ||
| { | ||
| "id": 42, | ||
| "name": "Sample Root", | ||
| "enabled": true, | ||
| "tags": ["alpha", "beta", "gamma"], | ||
| "metadata": { | ||
| "created": "2025-02-15T12:34:56Z", | ||
| "updated": "2025-03-01T08:12:45Z", | ||
| "attributes": { | ||
| "priority": "high", | ||
| "flags": { | ||
| "archived": false, | ||
| "requiresReview": true, | ||
| "internal": { | ||
| "level": 3, | ||
| "notes": ["check format", "verify fields"] | ||
| } | ||
| } | ||
| } | ||
| }, | ||
| "items": [ | ||
| { | ||
| "id": "a1", | ||
| "quantity": 10, | ||
| "details": { | ||
| "manufacturer": "Acme Corp", | ||
| "dimensions": { | ||
| "width": 10.5, | ||
| "height": 20.0, | ||
| "depth": 5.75 | ||
| } | ||
| } | ||
| }, | ||
| { | ||
| "id": "b2", | ||
| "quantity": 4, | ||
| "details": { | ||
| "manufacturer": "Globex", | ||
| "dimensions": { | ||
| "width": 5.0, | ||
| "height": 8.0, | ||
| "depth": 1.25, | ||
| "history": [ | ||
| { | ||
| "revision": 1, | ||
| "notes": { "editor": "system", "timestamp": "2025-01-01T00:00:00Z" } | ||
| }, | ||
| { | ||
| "revision": 2, | ||
| "notes": { "editor": "qa", "timestamp": "2025-02-01T00:00:00Z" } | ||
| } | ||
| ] | ||
| } | ||
| } | ||
| } | ||
| ], | ||
| "config": { | ||
| "mode": "full", | ||
| "retry": 3, | ||
| "options": { | ||
| "validate": true, | ||
| "paths": [ | ||
| { "name": "input", "value": "/var/data/in" }, | ||
| { "name": "output", "value": "/var/data/out" } | ||
| ] | ||
| } | ||
| }, | ||
| "searchedProperty": "fnord" | ||
| } | ||
| """; | ||
|
|
||
| #endregion | ||
| } |
87 changes: 87 additions & 0 deletions
87
src/IIIFPresentation/API.Tests/Converters/PresentationIIIFCleanerTests.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,87 @@ | ||
| using API.Converters; | ||
| using IIIF.Presentation.V3; | ||
| using IIIF.Presentation.V3.Content; | ||
| using IIIF.Presentation.V3.Strings; | ||
| using Models.API.Collection; | ||
| using Models.API.Manifest; | ||
|
|
||
| namespace API.Tests.Converters; | ||
|
|
||
| public class PresentationIIIFCleanerTests | ||
| { | ||
| [Fact] | ||
| public void TestCleanManifest() | ||
| { | ||
| var manifest = new PresentationManifest | ||
| { | ||
| // From IIIF | ||
| Id = "this/is/some/Id", | ||
| Label = new LanguageMap("en", "some label"), | ||
| Thumbnail = | ||
| [ | ||
| new Image | ||
| { | ||
| Id = "https://localhost/thumbs/12/23/blabla/full/143,200/0/default.jpg" | ||
| } | ||
| ], | ||
| Rights = "https://creativecommons.org/licenses/by/4.0/", | ||
| Items = | ||
| [ | ||
| new Canvas | ||
| { | ||
| Id = "some id" | ||
| } | ||
| ] | ||
| // outside IIIF | ||
| , | ||
| Slug = "some slug", | ||
| Parent = "some parent", | ||
| PublicId = "some public id" | ||
| }; | ||
|
|
||
| var clean = PresentationIIIFCleaner.OnlyIIIFProperties(manifest); | ||
|
|
||
| clean.Slug.Should().BeNull("not in IIIF"); | ||
| clean.Parent.Should().BeNull("not in IIIF"); | ||
| clean.PublicId.Should().BeNull("not in IIIF"); | ||
|
|
||
| clean.Rights.Should().Be(manifest.Rights, "in the IIIF"); | ||
| clean.Id.Should().Be(manifest.Id, "in the IIIF"); | ||
| clean.Thumbnail.Should().BeEquivalentTo(manifest.Thumbnail, "in the IIIF"); | ||
| clean.Items.Should().BeEquivalentTo(manifest.Items, "in the IIIF"); | ||
| } | ||
|
|
||
| [Fact] | ||
| public void TestCleanCollection() | ||
| { | ||
| var collection = new PresentationCollection | ||
| { | ||
| // From IIIF | ||
| Id = "this/is/some/Id", | ||
| Label = new LanguageMap("en", "some label"), | ||
| Thumbnail = | ||
| [ | ||
| new Image | ||
| { | ||
| Id = "https://localhost/thumbs/12/23/blabla/full/143,200/0/default.jpg" | ||
| } | ||
| ], | ||
| Rights = "https://creativecommons.org/licenses/by/4.0/" | ||
| // outside IIIF | ||
| , | ||
| Slug = "some slug", | ||
| Parent = "some parent", | ||
| PublicId = "some public id" | ||
| }; | ||
|
|
||
| var clean = PresentationIIIFCleaner.OnlyIIIFProperties(collection); | ||
|
|
||
| clean.Slug.Should().BeNull("not in IIIF"); | ||
| clean.Parent.Should().BeNull("not in IIIF"); | ||
| clean.PublicId.Should().BeNull("not in IIIF"); | ||
|
|
||
| clean.Rights.Should().Be(collection.Rights, "in the IIIF"); | ||
| clean.Id.Should().Be(collection.Id, "in the IIIF"); | ||
| clean.Thumbnail.Should().BeEquivalentTo(collection.Thumbnail, "in the IIIF"); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
formatting?