Skip to content

Commit

Permalink
Add HandleRequest_ProxiesToThumbs_IfRegionEquivalentToFull_AndKnownSi…
Browse files Browse the repository at this point in the history
…ze test
  • Loading branch information
griffri committed Apr 11, 2024
1 parent eed5784 commit c4d6e3d
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,32 @@ public async Task HandleRequest_ProxiesToThumbs_IfFullRegion_AndKnownSize()
result.Path.Should().Be("thumbs/2/2/test-image/full/!150,150/0/default.jpg");
}

[Fact]
public async Task HandleRequest_ProxiesToThumbs_IfRegionEquivalentToFull_AndKnownSize()
{
// Arrange
var context = new DefaultHttpContext();
context.Request.Path = "/iiif-img/2/2/test-image/0,0,512,512/256,256/0/default.jpg";

A.CallTo(() => customerRepository.GetCustomerPathElement("2")).Returns(new CustomerPathElement(2, "Test-Cust"));
var assetId = new AssetId(2, 2, "test-image");
A.CallTo(() => assetTracker.GetOrchestrationAsset<OrchestrationImage>(assetId))
.Returns(new OrchestrationImage
{
AssetId = assetId, OpenThumbs = new List<int[]> { new[] { 256, 256 } },
Height = 512, Width = 512, S3Location = "s3://storage/2/2/test-image",
Channels = AvailableDeliveryChannel.Image
});
var sut = GetImageRequestHandlerWithMockPathParser();

// Act
var result = await sut.HandleRequest(context) as ProxyActionResult;

// Assert
result.Target.Should().Be(ProxyDestination.Thumbs);
result.Path.Should().Be("thumbs/2/2/test-image/0,0,512,512/256,256/0/default.jpg");
}

[Theory]
[InlineData(AssetAccessResult.Open)]
[InlineData(AssetAccessResult.Authorized)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ public async Task<IProxyActionResult> HandleRequest(HttpContext httpContext)
}

// /full/ that cannot be handled by thumbs (e.g. format, size, rotation, quality), handle with special-server
if (IsRequestFullOrEquivalent(assetRequest, orchestrationImage))
if (assetRequest.IIIFImageRequest.Region.Full)
{
if (orchestrationImage.S3Location.IsNullOrEmpty())
{
Expand Down

0 comments on commit c4d6e3d

Please sign in to comment.