From c85c05c40cbbebcdbe99022c8ce95ef144c2f743 Mon Sep 17 00:00:00 2001 From: Michael Hoennig Date: Thu, 11 Jul 2024 10:41:21 +0200 Subject: [PATCH] amendmends after code-review --- .../HostingAssetEntityValidatorRegistry.java | 4 +-- ...HsDomainDnsSetupHostingAssetValidator.java | 2 +- ...sDomainHttpSetupHostingAssetValidator.java | 2 +- ...DomainMboxSetupHostingAssetValidator.java} | 10 +++--- ...DomainSmtpSetupHostingAssetValidator.java} | 6 ++-- ...DnsSetupHostingAssetValidatorUnitTest.java | 2 +- ...ttpSetupHostingAssetValidatorUnitTest.java | 36 +------------------ ...ainMboxHostingAssetValidatorUnitTest.java} | 4 +-- ...tpSetupHostingAssetValidatorUnitTest.java} | 4 +-- ...lAddressHostingAssetValidatorUnitTest.java | 4 +-- 10 files changed, 20 insertions(+), 54 deletions(-) rename src/main/java/net/hostsharing/hsadminng/hs/hosting/asset/validators/{HsDomainEMailMailboxSetupHostingAssetValidator.java => HsDomainMboxSetupHostingAssetValidator.java} (71%) rename src/main/java/net/hostsharing/hsadminng/hs/hosting/asset/validators/{HsDomainEMailSubmissionSetupHostingAssetValidator.java => HsDomainSmtpSetupHostingAssetValidator.java} (76%) rename src/test/java/net/hostsharing/hsadminng/hs/hosting/asset/validators/{HsDomainEmailMailboxSetupHostingAssetValidatorUnitTest.java => HsDomainMboxHostingAssetValidatorUnitTest.java} (97%) rename src/test/java/net/hostsharing/hsadminng/hs/hosting/asset/validators/{HsDomainEmailSubmissionSetupHostingAssetValidatorUnitTest.java => HsDomainSmtpSetupHostingAssetValidatorUnitTest.java} (97%) diff --git a/src/main/java/net/hostsharing/hsadminng/hs/hosting/asset/validators/HostingAssetEntityValidatorRegistry.java b/src/main/java/net/hostsharing/hsadminng/hs/hosting/asset/validators/HostingAssetEntityValidatorRegistry.java index 927d0070..c44bf92a 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/hosting/asset/validators/HostingAssetEntityValidatorRegistry.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/hosting/asset/validators/HostingAssetEntityValidatorRegistry.java @@ -23,8 +23,8 @@ public class HostingAssetEntityValidatorRegistry { register(DOMAIN_SETUP, new HsDomainSetupHostingAssetValidator()); register(DOMAIN_DNS_SETUP, new HsDomainDnsSetupHostingAssetValidator()); register(DOMAIN_HTTP_SETUP, new HsDomainHttpSetupHostingAssetValidator()); - register(DOMAIN_SMTP_SETUP, new HsDomainEMailSubmissionSetupHostingAssetValidator()); - register(DOMAIN_MBOX_SETUP, new HsDomainEMailMailboxSetupHostingAssetValidator()); + register(DOMAIN_SMTP_SETUP, new HsDomainSmtpSetupHostingAssetValidator()); + register(DOMAIN_MBOX_SETUP, new HsDomainMboxSetupHostingAssetValidator()); register(EMAIL_ADDRESS, new HsEMailAddressHostingAssetValidator()); } diff --git a/src/main/java/net/hostsharing/hsadminng/hs/hosting/asset/validators/HsDomainDnsSetupHostingAssetValidator.java b/src/main/java/net/hostsharing/hsadminng/hs/hosting/asset/validators/HsDomainDnsSetupHostingAssetValidator.java index 06e8b72a..97c44ce2 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/hosting/asset/validators/HsDomainDnsSetupHostingAssetValidator.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/hosting/asset/validators/HsDomainDnsSetupHostingAssetValidator.java @@ -60,7 +60,7 @@ class HsDomainDnsSetupHostingAssetValidator extends HostingAssetEntityValidator @Override protected Pattern identifierPattern(final HsHostingAssetEntity assetEntity) { - return Pattern.compile("^" + assetEntity.getParentAsset().getIdentifier() + Pattern.quote(IDENTIFIER_SUFFIX) + "$"); + return Pattern.compile("^" + Pattern.quote(assetEntity.getParentAsset().getIdentifier() + IDENTIFIER_SUFFIX) + "$"); } @Override diff --git a/src/main/java/net/hostsharing/hsadminng/hs/hosting/asset/validators/HsDomainHttpSetupHostingAssetValidator.java b/src/main/java/net/hostsharing/hsadminng/hs/hosting/asset/validators/HsDomainHttpSetupHostingAssetValidator.java index 9065f7d9..32a2cb30 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/hosting/asset/validators/HsDomainHttpSetupHostingAssetValidator.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/hosting/asset/validators/HsDomainHttpSetupHostingAssetValidator.java @@ -43,7 +43,7 @@ class HsDomainHttpSetupHostingAssetValidator extends HostingAssetEntityValidator @Override protected Pattern identifierPattern(final HsHostingAssetEntity assetEntity) { - return Pattern.compile("^" + assetEntity.getParentAsset().getIdentifier() + Pattern.quote(IDENTIFIER_SUFFIX) + "$"); + return Pattern.compile("^" + Pattern.quote(assetEntity.getParentAsset().getIdentifier() + IDENTIFIER_SUFFIX) + "$"); } @Override diff --git a/src/main/java/net/hostsharing/hsadminng/hs/hosting/asset/validators/HsDomainEMailMailboxSetupHostingAssetValidator.java b/src/main/java/net/hostsharing/hsadminng/hs/hosting/asset/validators/HsDomainMboxSetupHostingAssetValidator.java similarity index 71% rename from src/main/java/net/hostsharing/hsadminng/hs/hosting/asset/validators/HsDomainEMailMailboxSetupHostingAssetValidator.java rename to src/main/java/net/hostsharing/hsadminng/hs/hosting/asset/validators/HsDomainMboxSetupHostingAssetValidator.java index 85291aeb..0172fda4 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/hosting/asset/validators/HsDomainEMailMailboxSetupHostingAssetValidator.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/hosting/asset/validators/HsDomainMboxSetupHostingAssetValidator.java @@ -5,15 +5,15 @@ import net.hostsharing.hsadminng.hs.hosting.asset.HsHostingAssetEntity; import java.util.regex.Pattern; import static java.util.Optional.ofNullable; -import static net.hostsharing.hsadminng.hs.hosting.asset.HsHostingAssetType.DOMAIN_SMTP_SETUP; +import static net.hostsharing.hsadminng.hs.hosting.asset.HsHostingAssetType.DOMAIN_MBOX_SETUP; -class HsDomainEMailMailboxSetupHostingAssetValidator extends HostingAssetEntityValidator { +class HsDomainMboxSetupHostingAssetValidator extends HostingAssetEntityValidator { public static final String IDENTIFIER_SUFFIX = "|MBOX"; - HsDomainEMailMailboxSetupHostingAssetValidator() { + HsDomainMboxSetupHostingAssetValidator() { super( - DOMAIN_SMTP_SETUP, + DOMAIN_MBOX_SETUP, AlarmContact.isOptional(), NO_EXTRA_PROPERTIES); @@ -21,7 +21,7 @@ class HsDomainEMailMailboxSetupHostingAssetValidator extends HostingAssetEntityV @Override protected Pattern identifierPattern(final HsHostingAssetEntity assetEntity) { - return Pattern.compile("^" + assetEntity.getParentAsset().getIdentifier() + Pattern.quote(IDENTIFIER_SUFFIX) + "$"); + return Pattern.compile("^" + Pattern.quote(assetEntity.getParentAsset().getIdentifier() + IDENTIFIER_SUFFIX) + "$"); } @Override diff --git a/src/main/java/net/hostsharing/hsadminng/hs/hosting/asset/validators/HsDomainEMailSubmissionSetupHostingAssetValidator.java b/src/main/java/net/hostsharing/hsadminng/hs/hosting/asset/validators/HsDomainSmtpSetupHostingAssetValidator.java similarity index 76% rename from src/main/java/net/hostsharing/hsadminng/hs/hosting/asset/validators/HsDomainEMailSubmissionSetupHostingAssetValidator.java rename to src/main/java/net/hostsharing/hsadminng/hs/hosting/asset/validators/HsDomainSmtpSetupHostingAssetValidator.java index 7c1bbecb..e92eba10 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/hosting/asset/validators/HsDomainEMailSubmissionSetupHostingAssetValidator.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/hosting/asset/validators/HsDomainSmtpSetupHostingAssetValidator.java @@ -7,11 +7,11 @@ import java.util.regex.Pattern; import static java.util.Optional.ofNullable; import static net.hostsharing.hsadminng.hs.hosting.asset.HsHostingAssetType.DOMAIN_SMTP_SETUP; -class HsDomainEMailSubmissionSetupHostingAssetValidator extends HostingAssetEntityValidator { +class HsDomainSmtpSetupHostingAssetValidator extends HostingAssetEntityValidator { public static final String IDENTIFIER_SUFFIX = "|SMTP"; - HsDomainEMailSubmissionSetupHostingAssetValidator() { + HsDomainSmtpSetupHostingAssetValidator() { super( DOMAIN_SMTP_SETUP, AlarmContact.isOptional(), @@ -21,7 +21,7 @@ class HsDomainEMailSubmissionSetupHostingAssetValidator extends HostingAssetEnti @Override protected Pattern identifierPattern(final HsHostingAssetEntity assetEntity) { - return Pattern.compile("^" + assetEntity.getParentAsset().getIdentifier() + Pattern.quote(IDENTIFIER_SUFFIX) + "$"); + return Pattern.compile("^" + Pattern.quote(assetEntity.getParentAsset().getIdentifier() + IDENTIFIER_SUFFIX) + "$"); } @Override diff --git a/src/test/java/net/hostsharing/hsadminng/hs/hosting/asset/validators/HsDomainDnsSetupHostingAssetValidatorUnitTest.java b/src/test/java/net/hostsharing/hsadminng/hs/hosting/asset/validators/HsDomainDnsSetupHostingAssetValidatorUnitTest.java index 22ed60a1..7f66379c 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/hosting/asset/validators/HsDomainDnsSetupHostingAssetValidatorUnitTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/hosting/asset/validators/HsDomainDnsSetupHostingAssetValidatorUnitTest.java @@ -97,7 +97,7 @@ class HsDomainDnsSetupHostingAssetValidatorUnitTest { // then assertThat(result).containsExactly( - "'identifier' expected to match '^example.org\\Q|DNS\\E$', but is 'example.org'" + "'identifier' expected to match '^\\Qexample.org|DNS\\E$', but is 'example.org'" ); } diff --git a/src/test/java/net/hostsharing/hsadminng/hs/hosting/asset/validators/HsDomainHttpSetupHostingAssetValidatorUnitTest.java b/src/test/java/net/hostsharing/hsadminng/hs/hosting/asset/validators/HsDomainHttpSetupHostingAssetValidatorUnitTest.java index fa75cded..29b4c05b 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/hosting/asset/validators/HsDomainHttpSetupHostingAssetValidatorUnitTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/hosting/asset/validators/HsDomainHttpSetupHostingAssetValidatorUnitTest.java @@ -14,12 +14,6 @@ import static net.hostsharing.hsadminng.hs.hosting.asset.HsHostingAssetType.DOMA import static net.hostsharing.hsadminng.hs.hosting.asset.HsHostingAssetType.DOMAIN_SETUP; import static net.hostsharing.hsadminng.hs.hosting.asset.HsHostingAssetType.MANAGED_WEBSPACE; import static net.hostsharing.hsadminng.hs.hosting.asset.HsHostingAssetType.UNIX_USER; -import static net.hostsharing.hsadminng.hs.hosting.asset.validators.HsDomainDnsSetupHostingAssetValidator.RR_COMMENT; -import static net.hostsharing.hsadminng.hs.hosting.asset.validators.HsDomainDnsSetupHostingAssetValidator.RR_RECORD_DATA; -import static net.hostsharing.hsadminng.hs.hosting.asset.validators.HsDomainDnsSetupHostingAssetValidator.RR_RECORD_TYPE; -import static net.hostsharing.hsadminng.hs.hosting.asset.validators.HsDomainDnsSetupHostingAssetValidator.RR_REGEX_IN; -import static net.hostsharing.hsadminng.hs.hosting.asset.validators.HsDomainDnsSetupHostingAssetValidator.RR_REGEX_NAME; -import static net.hostsharing.hsadminng.hs.hosting.asset.validators.HsDomainDnsSetupHostingAssetValidator.RR_REGEX_TTL; import static org.assertj.core.api.Assertions.assertThat; class HsDomainHttpSetupHostingAssetValidatorUnitTest { @@ -93,7 +87,7 @@ class HsDomainHttpSetupHostingAssetValidatorUnitTest { // then assertThat(result).containsExactly( - "'identifier' expected to match '^example.org\\Q|HTTP\\E$', but is 'example.org'" + "'identifier' expected to match '^\\Qexample.org|HTTP\\E$', but is 'example.org'" ); } @@ -166,32 +160,4 @@ class HsDomainHttpSetupHostingAssetValidatorUnitTest { "'DOMAIN_HTTP_SETUP:example.org|HTTP.config.subdomains' is expected to match any of [(?!-)[A-Za-z0-9-]{1,63}(?