Skip to content

Commit e7c3c66

Browse files
authored
Merge pull request #1097 from dlcs/develop
Merge branch 'develop'
2 parents b8e40f9 + 94bc624 commit e7c3c66

File tree

59 files changed

+4968
-163
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+4968
-163
lines changed

.github/actions/docker-build-and-push/action.yml

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,11 @@ runs:
1919
using: "composite"
2020
steps:
2121
- id: checkout
22-
uses: actions/checkout@v2
22+
uses: actions/checkout@v6
2323
- id: docker-setup-buildx
24-
uses: docker/setup-buildx-action@v2
25-
with:
26-
driver-opts: |
27-
image=moby/buildkit:v0.10.6
24+
uses: docker/setup-buildx-action@v3
2825
- id: docker-meta
29-
uses: docker/metadata-action@v3
26+
uses: docker/metadata-action@v5
3027
with:
3128
images: ghcr.io/dlcs/${{ inputs.image-name }}
3229
tags: |
@@ -37,7 +34,7 @@ runs:
3734
type=semver,pattern={{major}}.{{minor}}
3835
type=semver,pattern={{major}}
3936
- id: docker-login
40-
uses: docker/login-action@v1
37+
uses: docker/login-action@v3
4138
with:
4239
registry: ghcr.io
4340
username: ${{ github.actor }}

.github/workflows/run_build.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ jobs:
2121
SOLUTION: "protagonist.sln"
2222
steps:
2323
- id: checkout
24-
uses: actions/checkout@v5
24+
uses: actions/checkout@v6
2525
- id: setup-dotnet
26-
uses: actions/setup-dotnet@v4
26+
uses: actions/setup-dotnet@v5
2727
with:
2828
dotnet-version: "8.0.x"
2929
- id: restore-dotnet-dependencies
@@ -56,7 +56,7 @@ jobs:
5656
- image: "migrator"
5757
dockerfile: "Dockerfile.Migrator"
5858
steps:
59-
- uses: actions/checkout@v5
59+
- uses: actions/checkout@v6
6060
- uses: ./.github/actions/docker-build-and-push
6161
with:
6262
image-name: ${{ matrix.image }}

.github/workflows/run_sonar.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,18 @@ jobs:
1313
SOLUTION: "protagonist.sln"
1414
steps:
1515
- name: Set up JDK 17
16-
uses: actions/setup-java@v4
16+
uses: actions/setup-java@v5
1717
with:
1818
java-version: 17
1919
distribution: 'zulu' # Alternative distribution options are available.
2020
- id: checkout
21-
uses: actions/checkout@v5
21+
uses: actions/checkout@v6
2222
- id: setup-dotnet
23-
uses: actions/setup-dotnet@v4
23+
uses: actions/setup-dotnet@v5
2424
with:
2525
dotnet-version: "8.0.x"
2626
- name: Cache SonarCloud packages
27-
uses: actions/cache@v4
27+
uses: actions/cache@v5
2828
with:
2929
path: ~/sonar/cache
3030
key: ${{ runner.os }}-sonar

compose/.env.dist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ Thumbs__UpscaleThreshold=40
3232

3333
# Appetiser
3434
# ------------------------------------------------------------------------------
35-
KAKADU_APPS_LOCATION=s3://bucket/kakadu/kdu.tar.gz
35+
KDU_BINARIES=s3://bucket/kakadu/kdu.tar.gz
3636

3737
# Special Server
3838
# ------------------------------------------------------------------------------

compose/docker-compose.local.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
version: '3'
2-
31
volumes:
42
dlcs_postgres_data: {}
53
dlcs_postgres_data_backups: {}
@@ -50,7 +48,7 @@ services:
5048
- .env
5149

5250
appetiser:
53-
image: ghcr.io/dlcs/appetiser:pr-25 # TODO - temp use PR until release cut
51+
image: ghcr.io/dlcs/appetiser:2.1.0
5452
ports:
5553
- "5031:8000"
5654
volumes:

docs/adr/0010-replace-maxunauthorised.md

Lines changed: 222 additions & 0 deletions
Large diffs are not rendered by default.

docs/adr/readme.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,5 @@
99
7. [Engine ImageServer](0006-engine-imageserver.md)
1010
8. [In-house Image Server](0007-inhouse-image-server.md)
1111
9. [ElasticTranscoder Replacement](0008-et-replacement.md)
12-
10. [Engine Use Appetiser for Thumbs](0009-engine-appetiser-thumbs.md)
12+
10. [Engine Use Appetiser for Thumbs](0009-engine-appetiser-thumbs.md)
13+
11. [Replace `maxUnauthorised`](0010-replace-maxunauthorised.md)
Lines changed: 187 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,187 @@
1+
using API.Features.Adjuncts.Validation;
2+
using API.Settings;
3+
using DLCS.HydraModel;
4+
using FluentValidation.TestHelper;
5+
using Microsoft.Extensions.Options;
6+
7+
namespace API.Tests.Features.Adjuncts.Validation;
8+
9+
public class HydraAdjunctValidatorTests
10+
{
11+
private readonly HydraAdjunctValidator sut = new(Options.Create(
12+
new ApiSettings
13+
{
14+
RestrictedResourceIdCharacterString = "\\ /"
15+
}));
16+
17+
[Fact]
18+
public void Valid_WhenAllValidatorsUsed()
19+
{
20+
var adjunct = new Adjunct("https://localhost", 1, 1, "assetId", "adjunctId")
21+
{
22+
ExternalId = "https://localhost:2000/some-id",
23+
MediaType = "mediaType",
24+
IIIFLink = "seeAlso",
25+
Type = "Image",
26+
Language = ["fra", "en"]
27+
};
28+
var result = sut.TestValidate(adjunct);
29+
result.ShouldNotHaveAnyValidationErrors();
30+
}
31+
32+
[Fact]
33+
public void ExternalId_NotValidUri()
34+
{
35+
var adjunct = new Adjunct("https://localhost", 1, 1, "assetId", "adjunctId")
36+
{
37+
ExternalId = "not-uri",
38+
MediaType = "mediaType",
39+
IIIFLink = "seeAlso",
40+
Type = "Image"
41+
};
42+
var result = sut.TestValidate(adjunct);
43+
result.ShouldHaveValidationErrorFor(r => r.ExternalId)
44+
.WithErrorMessage("'externalId' is required and must be a well formed URI");
45+
}
46+
47+
[Fact]
48+
public void ExternalId_Null()
49+
{
50+
var adjunct = new Adjunct
51+
{
52+
ExternalId = null,
53+
MediaType = "mediaType",
54+
IIIFLink = "seeAlso",
55+
Type = "Image"
56+
};
57+
var result = sut.TestValidate(adjunct);
58+
result.ShouldHaveValidationErrorFor(r => r.ExternalId)
59+
.WithErrorMessage("'externalId' is required and must be a well formed URI");
60+
}
61+
62+
[Theory]
63+
[InlineData("SeeAlso")]
64+
[InlineData("Invalid")]
65+
public void IIIFLink_NotValid(string iiifLink)
66+
{
67+
var adjunct = new Adjunct
68+
{
69+
MediaType = "mediaType",
70+
IIIFLink = iiifLink,
71+
Type = "Image",
72+
ExternalId = "https://localhost/customers/1/spaces/1/images/assetId/valid"
73+
};
74+
var result = sut.TestValidate(adjunct);
75+
result.ShouldHaveValidationErrorFor(r => r.IIIFLink)
76+
.WithErrorMessage("Valid values for 'iiifLink' are 'seeAlso', 'annotations', 'rendering'");
77+
}
78+
79+
[Fact]
80+
public void IIIFLink_Null()
81+
{
82+
var adjunct = new Adjunct
83+
{
84+
MediaType = "mediaType",
85+
Type = "Image",
86+
ExternalId = "https://localhost/customers/1/spaces/1/images/assetId/valid"
87+
};
88+
var result = sut.TestValidate(adjunct);
89+
result.ShouldHaveValidationErrorFor(r => r.IIIFLink)
90+
.WithErrorMessage("'iiifLink' is required");
91+
}
92+
93+
[Fact]
94+
public void MediaType_Null()
95+
{
96+
var adjunct = new Adjunct
97+
{
98+
IIIFLink = "seeAlso",
99+
Type = "Image",
100+
ExternalId = "https://localhost/customers/1/spaces/1/images/assetId/valid"
101+
};
102+
var result = sut.TestValidate(adjunct);
103+
result.ShouldHaveValidationErrorFor(r => r.MediaType)
104+
.WithErrorMessage("'mediaType' is required");
105+
}
106+
107+
[Fact]
108+
public void ModelId_Null()
109+
{
110+
var adjunct = new Adjunct
111+
{
112+
MediaType = "mediaType",
113+
IIIFLink = "seeAlso",
114+
Type = "Image",
115+
ExternalId = "https://localhost/customers/1/spaces/1/images/assetId/valid"
116+
};
117+
var result = sut.TestValidate(adjunct);
118+
result.ShouldHaveValidationErrorFor(r => r.ModelId)
119+
.WithErrorMessage("Adjunct identifier could not be found");
120+
}
121+
122+
[Theory]
123+
[InlineData(" space")]
124+
[InlineData("slash\\")]
125+
[InlineData("other/slash")]
126+
public void ModelId_InvalidCharacters(string modelId)
127+
{
128+
var adjunct = new Adjunct
129+
{
130+
MediaType = "mediaType",
131+
IIIFLink = "seeAlso",
132+
Type = "Image",
133+
ExternalId = "https://localhost/customers/1/spaces/1/images/assetId/valid",
134+
ModelId = modelId
135+
};
136+
var result = sut.TestValidate(adjunct);
137+
result.ShouldHaveValidationErrorFor(r => r.ModelId)
138+
.WithErrorMessage("Adjunct id contains at least one of the following restricted characters. Invalid values are: \\ /");
139+
}
140+
141+
[Fact]
142+
public void ModelId_TooLong()
143+
{
144+
var adjunct = new Adjunct
145+
{
146+
MediaType = "mediaType",
147+
IIIFLink = "seeAlso",
148+
Type = "Image",
149+
ExternalId = "https://localhost/customers/1/spaces/1/images/assetId/valid",
150+
ModelId = new string('a', 201),
151+
};
152+
var result = sut.TestValidate(adjunct);
153+
result.ShouldHaveValidationErrorFor(r => r.ModelId)
154+
.WithErrorMessage("Adjunct id must be 200 characters or less");
155+
}
156+
157+
[Fact]
158+
public void Type_Error_WhenNotSet()
159+
{
160+
var adjunct = new Adjunct
161+
{
162+
MediaType = "mediaType",
163+
IIIFLink = "seeAlso",
164+
Type = null,
165+
ExternalId = "https://localhost/customers/1/spaces/1/images/assetId"
166+
};
167+
var result = sut.TestValidate(adjunct);
168+
result.ShouldHaveValidationErrorFor(r => r.Type)
169+
.WithErrorMessage("'@type' is required");
170+
}
171+
172+
[Fact]
173+
public void Language_Error_TooLong()
174+
{
175+
var adjunct = new Adjunct
176+
{
177+
MediaType = "mediaType",
178+
IIIFLink = "seeAlso",
179+
Type = "AnnotationPage",
180+
Language = ["en", "an overly long language string"],
181+
ExternalId = "https://localhost/customers/1/spaces/1/images/assetId"
182+
};
183+
var result = sut.TestValidate(adjunct);
184+
result.ShouldHaveValidationErrorFor(r => r.Language)
185+
.WithErrorMessage("All 'language' values must be 10 characters or less. e.g. ISO language codes, sub-codes or 'none'");
186+
}
187+
}

src/protagonist/API.Tests/Features/Assets/ApiAssetRepositoryTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ public void AssetRepository_FailsToSaveAsset_WhichHasRestrictedCharacters()
304304

305305
var result = AssetPreparer.PrepareAssetForUpsert(null, newAsset, false, false, new []{' '});
306306
result.Success.Should().BeFalse();
307-
result.ErrorMessage.Should().Be("Asset id contains at least one of the following restricted characters. Valid values are: ");
307+
result.ErrorMessage.Should().Be("Asset id contains at least one of the following restricted characters. Invalid values are: ");
308308
}
309309

310310
[Fact]

0 commit comments

Comments
 (0)