2
0
mirror of https://github.com/VinylDNS/vinyldns synced 2025-08-29 13:27:43 +00:00

naptr flags validation

This commit is contained in:
Aravindh-Raju 2023-05-22 11:40:05 +05:30
parent c24fbf53d9
commit afadf9f290
No known key found for this signature in database
GPG Key ID: 6B4D566AC36626F6
6 changed files with 15 additions and 3 deletions

View File

@ -163,4 +163,8 @@ object DomainValidations {
def validateMX_NAPTR_SRVData(number: Int, recordDataType: String, recordType: String): ValidatedNel[DomainValidationError, Int] =
if (number >= INTEGER_MIN_VALUE && number <= INTEGER_MAX_VALUE) number.validNel
else InvalidMX_NAPTR_SRVData(number, INTEGER_MIN_VALUE, INTEGER_MAX_VALUE, recordDataType, recordType).invalidNel[Int]
def validateNaptrFlag(value: String): ValidatedNel[DomainValidationError, String] =
if (value == "U" || value == "S" || value == "A" || value == "P") value.validNel
else InvalidNaptrFlag(value).invalidNel[String]
}

View File

@ -248,7 +248,7 @@ class BatchChangeValidations(
case mx: MXData =>
validateMX_NAPTR_SRVData(mx.preference, "preference", "MX").asUnit |+| validateHostName(mx.exchange).asUnit
case ns: NSData => validateHostName(ns.nsdname).asUnit
case naptr: NAPTRData => validateMX_NAPTR_SRVData(naptr.preference, "preference", "NAPTR").asUnit |+| validateMX_NAPTR_SRVData(naptr.order, "order", "NAPTR").asUnit |+| validateHostName(naptr.replacement).asUnit
case naptr: NAPTRData => validateMX_NAPTR_SRVData(naptr.preference, "preference", "NAPTR").asUnit |+| validateMX_NAPTR_SRVData(naptr.order, "order", "NAPTR").asUnit |+| validateHostName(naptr.replacement).asUnit |+| validateNaptrFlag(naptr.flags).asUnit
case srv: SRVData => validateMX_NAPTR_SRVData(srv.priority, "priority", "SRV").asUnit |+| validateMX_NAPTR_SRVData(srv.port, "port", "SRV").asUnit |+| validateMX_NAPTR_SRVData(srv.weight, "weight", "SRV").asUnit |+| validateHostName(srv.target).asUnit
case other =>
InvalidBatchRecordType(other.toString, SupportedBatchChangeRecordTypes.get).invalidNel[Unit]

View File

@ -113,6 +113,12 @@ final case class InvalidMX_NAPTR_SRVData(param: Long, min: Long, max: Long, reco
s"""Invalid $recordType $recordDataType: "${param.toString}", must be a number between $min and $max."""
}
final case class InvalidNaptrFlag(value: String)
extends DomainValidationError {
def message: String =
s"""Invalid NAPTR flag value: '$value'. Valid NAPTR flag value must be U, S, A or P."""
}
final case class InvalidBatchRecordType(param: String, supported: Set[RecordType])
extends DomainValidationError {
def message: String =

View File

@ -31,7 +31,7 @@ object DomainValidationErrorType extends Enumeration {
// NOTE: once defined, an error code type cannot be changed!
val ChangeLimitExceeded, BatchChangeIsEmpty, GroupDoesNotExist, NotAMemberOfOwnerGroup,
InvalidDomainName, InvalidCname, InvalidLength, InvalidEmail, InvalidRecordType, InvalidPortNumber,
InvalidIpv4Address, InvalidIpv6Address, InvalidIPAddress, InvalidTTL, InvalidMX_NAPTR_SRVData,
InvalidIpv4Address, InvalidIpv6Address, InvalidIPAddress, InvalidTTL, InvalidMX_NAPTR_SRVData, InvalidNaptrFlag,
InvalidBatchRecordType, ZoneDiscoveryError, RecordAlreadyExists, RecordDoesNotExist, InvalidUpdateRequest,
CnameIsNotUniqueError, UserIsNotAuthorized, UserIsNotAuthorizedError, RecordNameNotUniqueInBatch,
RecordInReverseZoneError, HighValueDomainError, MissingOwnerGroupId, ExistingMultiRecordError,
@ -56,6 +56,7 @@ object DomainValidationErrorType extends Enumeration {
case _: InvalidIPAddress => InvalidIPAddress
case _: InvalidTTL => InvalidTTL
case _: InvalidMX_NAPTR_SRVData => InvalidMX_NAPTR_SRVData
case _: InvalidNaptrFlag => InvalidNaptrFlag
case _: InvalidBatchRecordType => InvalidBatchRecordType
case _: ZoneDiscoveryError => ZoneDiscoveryError
case _: RecordAlreadyExists => RecordAlreadyExists

View File

@ -281,7 +281,7 @@
<br />
<label class="batch-label">Flags</label>
<input name="record_naptr_flags_{{$index}}" type="text" ng-model="change.record.flags" ng-required="change.changeType=='Add'" class="form-control" placeholder="e.g. U, S, A or P">
<select name="record_naptr_flags_{{$index}}" type="text" ng-model="change.record.flags" ng-required="change.changeType=='Add'" ng-options="flag for flag in naptrFlags" class="form-control" placeholder="e.g. U, S, A or P"></select>
<p ng-show="createBatchChangeForm.$submitted">
<span ng-show="createBatchChangeForm.record_naptr_flags_{{$index}}.$error.required" class="batch-change-error-help">Flags is required!</span>
</p>

View File

@ -42,6 +42,7 @@
$scope.allowManualReview = false;
$scope.confirmationPrompt = "Are you sure you want to submit this batch change request?";
$scope.manualReviewEnabled;
$scope.naptrFlags = ["U", "S", "A", "P"];
$scope.addSingleChange = function() {
$scope.newBatch.changes.push({changeType: "Add", type: "A+PTR"});