user-definable verificationCode and more business-level-validation-tests #100

Merged
hsh-michaelhoennig merged 8 commits from user-definable-verificationCode-and-bi-validation-tests into master 2024-09-12 10:52:45 +02:00
Showing only changes of commit 8d69f2ed39 - Show all commits

View File

@ -281,7 +281,7 @@ class HsDomainSetupHostingAssetValidatorUnitTest {
} }
@Test @Test
void rejectsSetupOfHostsharingDmain() { void rejectsSetupOfHostsharingDomain() {
domainSetupFor("hostsharing.net").notRegistered() domainSetupFor("hostsharing.net").notRegistered()
.isRejectedWithCauseForbidden("Hostsharing domain name"); .isRejectedWithCauseForbidden("Hostsharing domain name");
} }
@ -322,6 +322,18 @@ class HsDomainSetupHostingAssetValidatorUnitTest {
.isAccepted(); .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 @Test
void allowSetupOfUnregisteredSubdomainWithValidDnsVerificationInSuperDomain() { void allowSetupOfUnregisteredSubdomainWithValidDnsVerificationInSuperDomain() {
domainSetupFor("sub.example.org").notRegistered().withVerificationIn("example.org") 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() { void isAccepted() {
assertThat(validate()).isEmpty(); assertThat(validate()).isEmpty();
} }
@ -490,6 +508,12 @@ class HsDomainSetupHostingAssetValidatorUnitTest {
return HostingAssetEntityValidatorRegistry.forType(DOMAIN_SETUP) return HostingAssetEntityValidatorRegistry.forType(DOMAIN_SETUP)
.validateEntity(domainAsset); .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) { private DomainSetupBuilder domainSetupFor(final String domainName) {