amend test data+assertions to new validation rules

This commit is contained in:
Michael Hoennig 2024-09-05 13:51:08 +02:00
parent 0ed7264fc1
commit 4a3af3f6fe
2 changed files with 12 additions and 7 deletions

View File

@ -257,7 +257,7 @@ class HsHostingAssetControllerAcceptanceTest extends ContextBasedTestWithCleanup
.type(HsBookingItemType.DOMAIN_SETUP)
.caption("some temp domain setup booking item")
.resources(Map.ofEntries(
entry("domainName", "example.org")))
entry("domainName", "example.com")))
.build()
);

View File

@ -18,17 +18,22 @@ import static org.assertj.core.api.Assertions.assertThat;
class HsDomainSetupHostingAssetValidatorUnitTest {
static HsHostingAssetRbacEntity.HsHostingAssetRbacEntityBuilder<?, ?> validEntityBuilder() {
static HsHostingAssetRbacEntity.HsHostingAssetRbacEntityBuilder<?, ?> validEntityBuilder(final String domainName) {
final HsBookingItemRealEntity bookingItem = HsBookingItemRealEntity.builder()
.type(HsBookingItemType.DOMAIN_SETUP)
.resources(Map.ofEntries(
Map.entry("domainName", "example.org")
Map.entry("domainName", domainName)
))
.build();
return HsHostingAssetRbacEntity.builder()
.type(DOMAIN_SETUP)
.bookingItem(bookingItem)
.identifier("example.org");
.identifier(domainName);
}
static HsHostingAssetRbacEntity.HsHostingAssetRbacEntityBuilder<?, ?> validEntityBuilder() {
return validEntityBuilder("example.org");
}
enum InvalidDomainNameIdentifier {
@ -57,13 +62,13 @@ class HsDomainSetupHostingAssetValidatorUnitTest {
// then
assertThat(result).containsExactly(
"'identifier' expected to match '^((?!-)[A-Za-z0-9-]{1,63}(?<!-)\\.)+[A-Za-z]{2,12}', but is '"+testCase.domainName+"'"
"'identifier' expected to match 'example.org', but is '"+testCase.domainName+"'"
);
}
enum ValidDomainNameIdentifier {
SIMPLE("exampe.org"),
SIMPLE("example.org"),
MAX_LENGTH("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz01234568901.de"),
WITH_DASH("example-test.com"),
SUBDOMAIN("test.example.com");
@ -79,7 +84,7 @@ class HsDomainSetupHostingAssetValidatorUnitTest {
@EnumSource(ValidDomainNameIdentifier.class)
void acceptsValidIdentifier(final ValidDomainNameIdentifier testCase) {
// given
final var givenEntity = validEntityBuilder().identifier(testCase.domainName).build();
final var givenEntity = validEntityBuilder(testCase.domainName).identifier(testCase.domainName).build();
final var validator = HostingAssetEntityValidatorRegistry.forType(givenEntity.getType());
// when