amendmends after code-review
This commit is contained in:
parent
c58bc7a82a
commit
c85c05c40c
@ -23,8 +23,8 @@ public class HostingAssetEntityValidatorRegistry {
|
|||||||
register(DOMAIN_SETUP, new HsDomainSetupHostingAssetValidator());
|
register(DOMAIN_SETUP, new HsDomainSetupHostingAssetValidator());
|
||||||
register(DOMAIN_DNS_SETUP, new HsDomainDnsSetupHostingAssetValidator());
|
register(DOMAIN_DNS_SETUP, new HsDomainDnsSetupHostingAssetValidator());
|
||||||
register(DOMAIN_HTTP_SETUP, new HsDomainHttpSetupHostingAssetValidator());
|
register(DOMAIN_HTTP_SETUP, new HsDomainHttpSetupHostingAssetValidator());
|
||||||
register(DOMAIN_SMTP_SETUP, new HsDomainEMailSubmissionSetupHostingAssetValidator());
|
register(DOMAIN_SMTP_SETUP, new HsDomainSmtpSetupHostingAssetValidator());
|
||||||
register(DOMAIN_MBOX_SETUP, new HsDomainEMailMailboxSetupHostingAssetValidator());
|
register(DOMAIN_MBOX_SETUP, new HsDomainMboxSetupHostingAssetValidator());
|
||||||
register(EMAIL_ADDRESS, new HsEMailAddressHostingAssetValidator());
|
register(EMAIL_ADDRESS, new HsEMailAddressHostingAssetValidator());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,7 +60,7 @@ class HsDomainDnsSetupHostingAssetValidator extends HostingAssetEntityValidator
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Pattern identifierPattern(final HsHostingAssetEntity assetEntity) {
|
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
|
@Override
|
||||||
|
@ -43,7 +43,7 @@ class HsDomainHttpSetupHostingAssetValidator extends HostingAssetEntityValidator
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Pattern identifierPattern(final HsHostingAssetEntity assetEntity) {
|
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
|
@Override
|
||||||
|
@ -5,15 +5,15 @@ import net.hostsharing.hsadminng.hs.hosting.asset.HsHostingAssetEntity;
|
|||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
import static java.util.Optional.ofNullable;
|
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";
|
public static final String IDENTIFIER_SUFFIX = "|MBOX";
|
||||||
|
|
||||||
HsDomainEMailMailboxSetupHostingAssetValidator() {
|
HsDomainMboxSetupHostingAssetValidator() {
|
||||||
super(
|
super(
|
||||||
DOMAIN_SMTP_SETUP,
|
DOMAIN_MBOX_SETUP,
|
||||||
AlarmContact.isOptional(),
|
AlarmContact.isOptional(),
|
||||||
|
|
||||||
NO_EXTRA_PROPERTIES);
|
NO_EXTRA_PROPERTIES);
|
||||||
@ -21,7 +21,7 @@ class HsDomainEMailMailboxSetupHostingAssetValidator extends HostingAssetEntityV
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Pattern identifierPattern(final HsHostingAssetEntity assetEntity) {
|
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
|
@Override
|
@ -7,11 +7,11 @@ import java.util.regex.Pattern;
|
|||||||
import static java.util.Optional.ofNullable;
|
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_SMTP_SETUP;
|
||||||
|
|
||||||
class HsDomainEMailSubmissionSetupHostingAssetValidator extends HostingAssetEntityValidator {
|
class HsDomainSmtpSetupHostingAssetValidator extends HostingAssetEntityValidator {
|
||||||
|
|
||||||
public static final String IDENTIFIER_SUFFIX = "|SMTP";
|
public static final String IDENTIFIER_SUFFIX = "|SMTP";
|
||||||
|
|
||||||
HsDomainEMailSubmissionSetupHostingAssetValidator() {
|
HsDomainSmtpSetupHostingAssetValidator() {
|
||||||
super(
|
super(
|
||||||
DOMAIN_SMTP_SETUP,
|
DOMAIN_SMTP_SETUP,
|
||||||
AlarmContact.isOptional(),
|
AlarmContact.isOptional(),
|
||||||
@ -21,7 +21,7 @@ class HsDomainEMailSubmissionSetupHostingAssetValidator extends HostingAssetEnti
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Pattern identifierPattern(final HsHostingAssetEntity assetEntity) {
|
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
|
@Override
|
@ -97,7 +97,7 @@ class HsDomainDnsSetupHostingAssetValidatorUnitTest {
|
|||||||
|
|
||||||
// then
|
// then
|
||||||
assertThat(result).containsExactly(
|
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'"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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.DOMAIN_SETUP;
|
||||||
import static net.hostsharing.hsadminng.hs.hosting.asset.HsHostingAssetType.MANAGED_WEBSPACE;
|
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.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;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
class HsDomainHttpSetupHostingAssetValidatorUnitTest {
|
class HsDomainHttpSetupHostingAssetValidatorUnitTest {
|
||||||
@ -93,7 +87,7 @@ class HsDomainHttpSetupHostingAssetValidatorUnitTest {
|
|||||||
|
|
||||||
// then
|
// then
|
||||||
assertThat(result).containsExactly(
|
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}(?<!-)] but '@' does not match",
|
"'DOMAIN_HTTP_SETUP:example.org|HTTP.config.subdomains' is expected to match any of [(?!-)[A-Za-z0-9-]{1,63}(?<!-)] but '@' does not match",
|
||||||
"'DOMAIN_HTTP_SETUP:example.org|HTTP.config.subdomains' is expected to match any of [(?!-)[A-Za-z0-9-]{1,63}(?<!-)] but 'example.com' does not match");
|
"'DOMAIN_HTTP_SETUP:example.org|HTTP.config.subdomains' is expected to match any of [(?!-)[A-Za-z0-9-]{1,63}(?<!-)] but 'example.com' does not match");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
void validStringMatchesRegEx() {
|
|
||||||
assertThat("@ ").matches(RR_REGEX_NAME);
|
|
||||||
assertThat("ns ").matches(RR_REGEX_NAME);
|
|
||||||
assertThat("example.com. ").matches(RR_REGEX_NAME);
|
|
||||||
|
|
||||||
assertThat("12400 ").matches(RR_REGEX_TTL);
|
|
||||||
assertThat("12400\t\t ").matches(RR_REGEX_TTL);
|
|
||||||
assertThat("12400 \t\t").matches(RR_REGEX_TTL);
|
|
||||||
assertThat("1h30m ").matches(RR_REGEX_TTL);
|
|
||||||
assertThat("30m ").matches(RR_REGEX_TTL);
|
|
||||||
|
|
||||||
assertThat("IN ").matches(RR_REGEX_IN);
|
|
||||||
assertThat("IN\t\t ").matches(RR_REGEX_IN);
|
|
||||||
assertThat("IN \t\t").matches(RR_REGEX_IN);
|
|
||||||
|
|
||||||
assertThat("CNAME ").matches(RR_RECORD_TYPE);
|
|
||||||
assertThat("CNAME\t\t ").matches(RR_RECORD_TYPE);
|
|
||||||
assertThat("CNAME \t\t").matches(RR_RECORD_TYPE);
|
|
||||||
|
|
||||||
assertThat("example.com.").matches(RR_RECORD_DATA);
|
|
||||||
assertThat("123.123.123.123").matches(RR_RECORD_DATA);
|
|
||||||
assertThat("(some more complex argument in parenthesis)").matches(RR_RECORD_DATA);
|
|
||||||
assertThat("\"some more complex argument; including a semicolon\"").matches(RR_RECORD_DATA);
|
|
||||||
|
|
||||||
assertThat("; whatever ; \" really anything").matches(RR_COMMENT);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,7 @@ import static net.hostsharing.hsadminng.hs.hosting.asset.HsHostingAssetType.DOMA
|
|||||||
import static net.hostsharing.hsadminng.hs.hosting.asset.HsHostingAssetType.MANAGED_WEBSPACE;
|
import static net.hostsharing.hsadminng.hs.hosting.asset.HsHostingAssetType.MANAGED_WEBSPACE;
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
class HsDomainEmailMailboxSetupHostingAssetValidatorUnitTest {
|
class HsDomainMboxHostingAssetValidatorUnitTest {
|
||||||
|
|
||||||
static final HsHostingAssetEntity validDomainSetupEntity = HsHostingAssetEntity.builder()
|
static final HsHostingAssetEntity validDomainSetupEntity = HsHostingAssetEntity.builder()
|
||||||
.type(DOMAIN_SETUP)
|
.type(DOMAIN_SETUP)
|
||||||
@ -63,7 +63,7 @@ class HsDomainEmailMailboxSetupHostingAssetValidatorUnitTest {
|
|||||||
|
|
||||||
// then
|
// then
|
||||||
assertThat(result).containsExactly(
|
assertThat(result).containsExactly(
|
||||||
"'identifier' expected to match '^example.org\\Q|MBOX\\E$', but is 'example.org'"
|
"'identifier' expected to match '^\\Qexample.org|MBOX\\E$', but is 'example.org'"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
@ -14,7 +14,7 @@ import static net.hostsharing.hsadminng.hs.hosting.asset.HsHostingAssetType.DOMA
|
|||||||
import static net.hostsharing.hsadminng.hs.hosting.asset.HsHostingAssetType.MANAGED_WEBSPACE;
|
import static net.hostsharing.hsadminng.hs.hosting.asset.HsHostingAssetType.MANAGED_WEBSPACE;
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
class HsDomainEmailSubmissionSetupHostingAssetValidatorUnitTest {
|
class HsDomainSmtpSetupHostingAssetValidatorUnitTest {
|
||||||
|
|
||||||
static final HsHostingAssetEntity validDomainSetupEntity = HsHostingAssetEntity.builder()
|
static final HsHostingAssetEntity validDomainSetupEntity = HsHostingAssetEntity.builder()
|
||||||
.type(DOMAIN_SETUP)
|
.type(DOMAIN_SETUP)
|
||||||
@ -63,7 +63,7 @@ class HsDomainEmailSubmissionSetupHostingAssetValidatorUnitTest {
|
|||||||
|
|
||||||
// then
|
// then
|
||||||
assertThat(result).containsExactly(
|
assertThat(result).containsExactly(
|
||||||
"'identifier' expected to match '^example.org\\Q|SMTP\\E$', but is 'example.org'"
|
"'identifier' expected to match '^\\Qexample.org|SMTP\\E$', but is 'example.org'"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
@ -15,14 +15,14 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||||||
|
|
||||||
class HsEMailAddressHostingAssetValidatorUnitTest {
|
class HsEMailAddressHostingAssetValidatorUnitTest {
|
||||||
|
|
||||||
final static HsHostingAssetEntity domainEmailMailboxSetup = HsHostingAssetEntity.builder()
|
final static HsHostingAssetEntity domainMboxetup = HsHostingAssetEntity.builder()
|
||||||
.type(DOMAIN_MBOX_SETUP)
|
.type(DOMAIN_MBOX_SETUP)
|
||||||
.identifier("example.org")
|
.identifier("example.org")
|
||||||
.build();
|
.build();
|
||||||
static HsHostingAssetEntity.HsHostingAssetEntityBuilder validEntityBuilder() {
|
static HsHostingAssetEntity.HsHostingAssetEntityBuilder validEntityBuilder() {
|
||||||
return HsHostingAssetEntity.builder()
|
return HsHostingAssetEntity.builder()
|
||||||
.type(EMAIL_ADDRESS)
|
.type(EMAIL_ADDRESS)
|
||||||
.parentAsset(domainEmailMailboxSetup)
|
.parentAsset(domainMboxetup)
|
||||||
.identifier("test@example.org")
|
.identifier("test@example.org")
|
||||||
.config(Map.ofEntries(
|
.config(Map.ofEntries(
|
||||||
entry("local-part", "test"),
|
entry("local-part", "test"),
|
||||||
|
Loading…
Reference in New Issue
Block a user