add business-level tests with parent asset

This commit is contained in:
Michael Hoennig 2024-09-12 07:13:15 +02:00
parent ca63d957e4
commit 8d69f2ed39

View File

@ -281,7 +281,7 @@ class HsDomainSetupHostingAssetValidatorUnitTest {
}
@Test
void rejectsSetupOfHostsharingDmain() {
void rejectsSetupOfHostsharingDomain() {
domainSetupFor("hostsharing.net").notRegistered()
.isRejectedWithCauseForbidden("Hostsharing domain name");
}
@ -322,6 +322,18 @@ class HsDomainSetupHostingAssetValidatorUnitTest {
.isAccepted();
}
@Test
void allowSetupOfUnregisteredSubdomainIfSuperDomainParentAssetIsSpecified() {
domainSetupFor("sub.example.org").notRegistered().withParentAsset("example.org")
.isAccepted();
}
@Test
void rejectSetupOfUnregisteredSubdomainIfWrongParentAssetIsSpecified() {
domainSetupFor("sub.example.org").notRegistered().withParentAsset("example.net")
.isRejectedDueToInvalidIdentifier();
}
@Test
void allowSetupOfUnregisteredSubdomainWithValidDnsVerificationInSuperDomain() {
domainSetupFor("sub.example.org").notRegistered().withVerificationIn("example.org")
@ -470,6 +482,12 @@ class HsDomainSetupHostingAssetValidatorUnitTest {
);
}
void isRejectedDueToInvalidIdentifier() {
assertThat(validate()).contains(
"'identifier' expected to match '(\\*|(?!-)[A-Za-z0-9-]{1,63}(?<!-))\\.example\\.net', but is 'sub.example.org'"
);
}
void isAccepted() {
assertThat(validate()).isEmpty();
}
@ -490,6 +508,12 @@ class HsDomainSetupHostingAssetValidatorUnitTest {
return HostingAssetEntityValidatorRegistry.forType(DOMAIN_SETUP)
.validateEntity(domainAsset);
}
DomainSetupBuilder withParentAsset(final String parentAssetDomainName) {
domainAsset.setBookingItem(null);
domainAsset.setParentAsset(HsHostingAssetRealEntity.builder().type(DOMAIN_SETUP).identifier(parentAssetDomainName).build());
return this;
}
}
private DomainSetupBuilder domainSetupFor(final String domainName) {