mirror of
https://github.com/VinylDNS/vinyldns
synced 2025-08-30 05:47:56 +00:00
update tests
This commit is contained in:
parent
4896f4e823
commit
3adb04b8e6
@ -73,7 +73,7 @@ object DomainValidations {
|
||||
val checkRegex = validReverseZoneFQDNRegex
|
||||
.findFirstIn(name)
|
||||
.map(_.validNel)
|
||||
.getOrElse(InvalidReverseZoneCame(name).invalidNel)
|
||||
.getOrElse(InvalidCname(name,isReverse).invalidNel)
|
||||
val checkLength = validateStringLength(name, Some(HOST_MIN_LENGTH), HOST_MAX_LENGTH)
|
||||
|
||||
checkRegex.combine(checkLength).map(_ => name)
|
||||
@ -81,7 +81,7 @@ object DomainValidations {
|
||||
val checkRegex = validForwardZoneFQDNRegex
|
||||
.findFirstIn(name)
|
||||
.map(_.validNel)
|
||||
.getOrElse(InvalidForwardZoneCame(name).invalidNel)
|
||||
.getOrElse(InvalidCname(name,isReverse).invalidNel)
|
||||
val checkLength = validateStringLength(name, Some(HOST_MIN_LENGTH), HOST_MAX_LENGTH)
|
||||
|
||||
checkRegex.combine(checkLength).map(_ => name)
|
||||
|
@ -22,7 +22,7 @@ import org.scalatestplus.scalacheck.ScalaCheckDrivenPropertyChecks
|
||||
import org.scalatest.propspec.AnyPropSpec
|
||||
import org.scalatest.matchers.should.Matchers
|
||||
import vinyldns.api.ValidationTestImprovements._
|
||||
import vinyldns.core.domain.{InvalidDomainName, InvalidForwardZoneCame, InvalidLength}
|
||||
import vinyldns.core.domain.{InvalidDomainName, InvalidCname, InvalidLength}
|
||||
|
||||
class DomainValidationsSpec
|
||||
extends AnyPropSpec
|
||||
@ -154,8 +154,8 @@ class DomainValidationsSpec
|
||||
validateCname("slash.cname./name.",true).isValid
|
||||
}
|
||||
property("Cname names with forward slash should fail with forward zone") {
|
||||
validateCname("/slash.cname.name.",false).failWith[InvalidForwardZoneCame]
|
||||
validateCname("slash./cname.name.",false).failWith[InvalidForwardZoneCame]
|
||||
validateCname("slash.cname./name.",false).failWith[InvalidForwardZoneCame]
|
||||
validateCname("/slash.cname.name.",false).failWith[InvalidCname]
|
||||
validateCname("slash./cname.name.",false).failWith[InvalidCname]
|
||||
validateCname("slash.cname./name.",false).failWith[InvalidCname]
|
||||
}
|
||||
}
|
||||
|
@ -712,7 +712,7 @@ class BatchChangeValidationsSpec
|
||||
)
|
||||
val result = validateAddChangeInput(change, false)
|
||||
|
||||
result should haveInvalid[DomainValidationError](InvalidDomainName(s"$invalidCNAMERecordData."))
|
||||
result should haveInvalid[DomainValidationError](InvalidCname(s"$invalidCNAMERecordData.",false))
|
||||
}
|
||||
|
||||
property("""validateAddChangeInput: should fail with InvalidLength
|
||||
@ -2670,7 +2670,7 @@ class BatchChangeValidationsSpec
|
||||
property("validateAddChangeInput: should fail for a CNAME addChangeInput with forward slash for forward zone") {
|
||||
val cnameWithForwardSlash = AddChangeInput("cname.ok.", RecordType.CNAME, ttl, CNAMEData(Fqdn("cname/")))
|
||||
val result = validateAddChangeInput(cnameWithForwardSlash, false)
|
||||
result should haveInvalid[DomainValidationError](InvalidDomainName("cname/."))
|
||||
result should haveInvalid[DomainValidationError](InvalidCname("cname/.",false))
|
||||
}
|
||||
property("validateAddChangeInput: should succeed for a valid CNAME addChangeInput without forward slash for forward zone") {
|
||||
val cname = AddChangeInput("cname.ok.", RecordType.CNAME, ttl, CNAMEData(Fqdn("cname")))
|
||||
|
@ -52,16 +52,16 @@ final case class InvalidDomainName(param: String) extends DomainValidationError
|
||||
"joined by dots, and terminated with a dot."
|
||||
}
|
||||
|
||||
final case class InvalidReverseZoneCame(param: String) extends DomainValidationError {
|
||||
final case class InvalidCname(param: String, isReverseZone: Boolean) extends DomainValidationError {
|
||||
def message: String =
|
||||
s"""Invalid Cname: "$param", valid cnames must be letters, numbers, slashes, underscores, and hyphens, """ +
|
||||
"joined by dots, and terminated with a dot."
|
||||
}
|
||||
|
||||
final case class InvalidForwardZoneCame(param: String) extends DomainValidationError {
|
||||
def message: String =
|
||||
s"""Invalid Cname: "$param", valid cnames must be letters, numbers, underscores, and hyphens, """ +
|
||||
"joined by dots, and terminated with a dot."
|
||||
isReverseZone match {
|
||||
case true =>
|
||||
s"""Invalid Cname: "$param", valid cnames must be letters, numbers, slashes, underscores, and hyphens, """ +
|
||||
"joined by dots, and terminated with a dot."
|
||||
case false =>
|
||||
s"""Invalid Cname: "$param", valid cnames must be letters, numbers, underscores, and hyphens, """ +
|
||||
"joined by dots, and terminated with a dot."
|
||||
}
|
||||
}
|
||||
|
||||
final case class InvalidLength(param: String, minLengthInclusive: Int, maxLengthInclusive: Int)
|
||||
|
@ -30,7 +30,7 @@ object DomainValidationErrorType extends Enumeration {
|
||||
type DomainValidationErrorType = Value
|
||||
// NOTE: once defined, an error code type cannot be changed!
|
||||
val ChangeLimitExceeded, BatchChangeIsEmpty, GroupDoesNotExist, NotAMemberOfOwnerGroup,
|
||||
InvalidDomainName, InvalidReverseZoneCame, InvalidForwardZoneCame, InvalidLength, InvalidEmail, InvalidRecordType, InvalidPortNumber,
|
||||
InvalidDomainName, InvalidCname, InvalidLength, InvalidEmail, InvalidRecordType, InvalidPortNumber,
|
||||
InvalidIpv4Address, InvalidIpv6Address, InvalidIPAddress, InvalidTTL, InvalidMxPreference,
|
||||
InvalidBatchRecordType, ZoneDiscoveryError, RecordAlreadyExists, RecordDoesNotExist,
|
||||
CnameIsNotUniqueError, UserIsNotAuthorized, UserIsNotAuthorizedError, RecordNameNotUniqueInBatch,
|
||||
@ -46,8 +46,7 @@ object DomainValidationErrorType extends Enumeration {
|
||||
case _: GroupDoesNotExist => GroupDoesNotExist
|
||||
case _: NotAMemberOfOwnerGroup => NotAMemberOfOwnerGroup
|
||||
case _: InvalidDomainName => InvalidDomainName
|
||||
case _: InvalidReverseZoneCame => InvalidReverseZoneCame
|
||||
case _: InvalidForwardZoneCame => InvalidForwardZoneCame
|
||||
case _: InvalidCname => InvalidCname
|
||||
case _: InvalidLength => InvalidLength
|
||||
case _: InvalidEmail => InvalidEmail
|
||||
case _: InvalidRecordType => InvalidRecordType
|
||||
|
Loading…
x
Reference in New Issue
Block a user