mirror of
https://github.com/VinylDNS/vinyldns
synced 2025-08-31 14:25:30 +00:00
Update in tests
This commit is contained in:
@@ -72,6 +72,9 @@ lazy val apiAssemblySettings = Seq(
|
|||||||
MergeStrategy.discard
|
MergeStrategy.discard
|
||||||
case PathList("scala", "tools", "nsc", "doc", "html", "resource", "lib", "template.js") =>
|
case PathList("scala", "tools", "nsc", "doc", "html", "resource", "lib", "template.js") =>
|
||||||
MergeStrategy.discard
|
MergeStrategy.discard
|
||||||
|
case "simulacrum/op.class" | "simulacrum/op$.class" | "simulacrum/typeclass$.class"
|
||||||
|
| "simulacrum/typeclass.class" | "simulacrum/noop.class" =>
|
||||||
|
MergeStrategy.discard
|
||||||
case x if x.endsWith("module-info.class") => MergeStrategy.discard
|
case x if x.endsWith("module-info.class") => MergeStrategy.discard
|
||||||
case x =>
|
case x =>
|
||||||
val oldStrategy = (assemblyMergeStrategy in assembly).value
|
val oldStrategy = (assemblyMergeStrategy in assembly).value
|
||||||
|
@@ -17,7 +17,7 @@
|
|||||||
package vinyldns.api.domain
|
package vinyldns.api.domain
|
||||||
|
|
||||||
import cats.implicits._
|
import cats.implicits._
|
||||||
import com.comcast.ip4s.{Cidr, IpAddress, Ipv4Address}
|
import com.comcast.ip4s.{Cidr, Ipv4Address, Ipv6Address}
|
||||||
import vinyldns.api.domain.zone.InvalidRequest
|
import vinyldns.api.domain.zone.InvalidRequest
|
||||||
import vinyldns.core.domain.zone.Zone
|
import vinyldns.core.domain.zone.Zone
|
||||||
import vinyldns.api.backend.dns.DnsConversions._
|
import vinyldns.api.backend.dns.DnsConversions._
|
||||||
@@ -30,8 +30,9 @@ object ReverseZoneHelpers {
|
|||||||
if (zone.isIPv4) {
|
if (zone.isIPv4) {
|
||||||
recordsetIsWithinCidrMaskIpv4(mask: String, zone: Zone, recordName: String)
|
recordsetIsWithinCidrMaskIpv4(mask: String, zone: Zone, recordName: String)
|
||||||
} else {
|
} else {
|
||||||
val ipAddr = IpAddress.fromString(convertPTRtoIPv6(zone, recordName)).get
|
val ipAddr = Ipv6Address.fromString(convertPTRtoIPv6(zone, recordName))
|
||||||
Try(Cidr.fromString(mask).contains(ipAddr)).getOrElse(false)
|
Try(Cidr(Cidr.fromString6(mask).get.address,Cidr.fromString6(mask).get.prefixBits).contains(ipAddr.get))
|
||||||
|
.getOrElse(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
// NOTE: this will not work for zones with less than 3 octets
|
// NOTE: this will not work for zones with less than 3 octets
|
||||||
@@ -86,7 +87,8 @@ object ReverseZoneHelpers {
|
|||||||
zone: Zone,
|
zone: Zone,
|
||||||
recordName: String
|
recordName: String
|
||||||
): Boolean = {
|
): Boolean = {
|
||||||
val recordIpAddr = Ipv4Address.fromString(convertPTRtoIPv4(zone, recordName)).get
|
|
||||||
|
val recordIpAddr = Ipv4Address.fromString(convertPTRtoIPv4(zone, recordName))
|
||||||
|
|
||||||
Try {
|
Try {
|
||||||
// make sure mask contains 4 octets, expand if not
|
// make sure mask contains 4 octets, expand if not
|
||||||
@@ -100,8 +102,7 @@ object ReverseZoneHelpers {
|
|||||||
}
|
}
|
||||||
|
|
||||||
val updatedMask = Cidr(Ipv4Address.fromString(fullIp).get,Cidr.fromString4(mask).get.prefixBits)
|
val updatedMask = Cidr(Ipv4Address.fromString(fullIp).get,Cidr.fromString4(mask).get.prefixBits)
|
||||||
|
updatedMask.contains(recordIpAddr.get)
|
||||||
updatedMask.contains(recordIpAddr)
|
|
||||||
}.getOrElse(false)
|
}.getOrElse(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -19,12 +19,7 @@ package vinyldns.api.domain.zone
|
|||||||
import cats.implicits._
|
import cats.implicits._
|
||||||
import cats.data._
|
import cats.data._
|
||||||
import com.comcast.ip4s.IpAddress
|
import com.comcast.ip4s.IpAddress
|
||||||
import vinyldns.core.domain.{
|
import vinyldns.core.domain.{DomainHelpers, DomainValidationError, HighValueDomainError, RecordRequiresManualReview}
|
||||||
DomainHelpers,
|
|
||||||
DomainValidationError,
|
|
||||||
HighValueDomainError,
|
|
||||||
RecordRequiresManualReview
|
|
||||||
}
|
|
||||||
import vinyldns.core.domain.record.{NSData, RecordSet}
|
import vinyldns.core.domain.record.{NSData, RecordSet}
|
||||||
|
|
||||||
import scala.util.matching.Regex
|
import scala.util.matching.Regex
|
||||||
|
@@ -56,10 +56,10 @@ class ZoneValidations(syncDelayMillis: Int) {
|
|||||||
def aclRuleMaskIsValid(rule: ACLRule): Either[Throwable, Unit] =
|
def aclRuleMaskIsValid(rule: ACLRule): Either[Throwable, Unit] =
|
||||||
rule.recordMask match {
|
rule.recordMask match {
|
||||||
case Some(mask) if rule.recordTypes == Set(RecordType.PTR) =>
|
case Some(mask) if rule.recordTypes == Set(RecordType.PTR) =>
|
||||||
Try(Cidr.fromString(mask)) match {
|
Try(Cidr.fromString(mask).get) match {
|
||||||
case Success(_) => Right(())
|
case Success(_) => Right(())
|
||||||
case Failure(e) =>
|
case Failure(_) =>
|
||||||
InvalidRequest(s"PTR types must have no mask or a valid CIDR mask: ${e.getMessage}").asLeft
|
InvalidRequest(s"PTR types must have no mask or a valid CIDR mask: Invalid CIDR block").asLeft
|
||||||
}
|
}
|
||||||
case Some(_) if rule.recordTypes.contains(RecordType.PTR) =>
|
case Some(_) if rule.recordTypes.contains(RecordType.PTR) =>
|
||||||
InvalidRequest("Multiple record types including PTR must have no mask").asLeft
|
InvalidRequest("Multiple record types including PTR must have no mask").asLeft
|
||||||
|
@@ -29,9 +29,9 @@ trait VinylDNSTestHelpers {
|
|||||||
|
|
||||||
val highValueDomainRegexList: List[Regex] = List(new Regex("high-value-domain.*"))
|
val highValueDomainRegexList: List[Regex] = List(new Regex("high-value-domain.*"))
|
||||||
val highValueDomainIpList: List[IpAddress] =
|
val highValueDomainIpList: List[IpAddress] =
|
||||||
(IpAddress("192.0.2.252") ++ IpAddress("192.0.2.253") ++ IpAddress(
|
(IpAddress.fromString("192.0.2.252") ++ IpAddress.fromString("192.0.2.253") ++ IpAddress.fromString(
|
||||||
"fd69:27cc:fe91:0:0:0:0:ffff"
|
"fd69:27cc:fe91:0:0:0:0:ffff"
|
||||||
) ++ IpAddress(
|
) ++ IpAddress.fromString(
|
||||||
"fd69:27cc:fe91:0:0:0:ffff:0"
|
"fd69:27cc:fe91:0:0:0:ffff:0"
|
||||||
)).toList
|
)).toList
|
||||||
|
|
||||||
@@ -45,9 +45,9 @@ trait VinylDNSTestHelpers {
|
|||||||
val manualReviewDomainList: List[Regex] = List(new Regex("needs-review.*"))
|
val manualReviewDomainList: List[Regex] = List(new Regex("needs-review.*"))
|
||||||
|
|
||||||
val manualReviewIpList: List[IpAddress] =
|
val manualReviewIpList: List[IpAddress] =
|
||||||
(IpAddress("192.0.2.254") ++ IpAddress("192.0.2.255") ++ IpAddress(
|
(IpAddress.fromString("192.0.2.254") ++ IpAddress.fromString("192.0.2.255") ++ IpAddress.fromString(
|
||||||
"fd69:27cc:fe91:0:0:0:ffff:1"
|
"fd69:27cc:fe91:0:0:0:ffff:1"
|
||||||
) ++ IpAddress("fd69:27cc:fe91:0:0:0:ffff:2")).toList
|
) ++ IpAddress.fromString("fd69:27cc:fe91:0:0:0:ffff:2")).toList
|
||||||
|
|
||||||
val manualReviewZoneNameList: Set[String] = Set("zone.needs.review.")
|
val manualReviewZoneNameList: Set[String] = Set("zone.needs.review.")
|
||||||
|
|
||||||
|
@@ -136,8 +136,8 @@ class ReverseZoneHelpersSpec
|
|||||||
}
|
}
|
||||||
"recordsetIsWithinCidrMask" should {
|
"recordsetIsWithinCidrMask" should {
|
||||||
"when testing IPv4" should {
|
"when testing IPv4" should {
|
||||||
"filter in/out record set based on CIDR rule of 0 (lower bound for ip4 CIDR rules)" in {
|
"filter in/out record set based on CIDR rule of 1 (lower bound for ip4 CIDR rules)" in {
|
||||||
val mask = "120.1.2.0/0"
|
val mask = "120.1.2.0/1"
|
||||||
val znTrue = Zone("40.120.in-addr.arpa.", "email")
|
val znTrue = Zone("40.120.in-addr.arpa.", "email")
|
||||||
val rsTrue =
|
val rsTrue =
|
||||||
RecordSet("id", "20.3", RecordType.PTR, 200, RecordSetStatus.Active, DateTime.now)
|
RecordSet("id", "20.3", RecordType.PTR, 200, RecordSetStatus.Active, DateTime.now)
|
||||||
@@ -150,7 +150,7 @@ class ReverseZoneHelpersSpec
|
|||||||
}
|
}
|
||||||
|
|
||||||
"filter in/out record set based on CIDR rule of 8" in {
|
"filter in/out record set based on CIDR rule of 8" in {
|
||||||
val mask = "10.10.32/19"
|
val mask = "10.10.32.0/19"
|
||||||
val zone = Zone("10.10.in-addr.arpa.", "email")
|
val zone = Zone("10.10.in-addr.arpa.", "email")
|
||||||
val recordSet =
|
val recordSet =
|
||||||
RecordSet("id", "90.44", RecordType.PTR, 200, RecordSetStatus.Active, DateTime.now)
|
RecordSet("id", "90.44", RecordType.PTR, 200, RecordSetStatus.Active, DateTime.now)
|
||||||
|
@@ -957,8 +957,8 @@ class AccessValidationsSpec
|
|||||||
|
|
||||||
"ruleAppliesToRecordNameIPv4" should {
|
"ruleAppliesToRecordNameIPv4" should {
|
||||||
|
|
||||||
"filter in/out record set based on CIDR rule of 0 (lower bound for ip4 CIDR rules)" in {
|
"filter in/out record set based on CIDR rule of 1 (lower bound for ip4 CIDR rules)" in {
|
||||||
val aclRule = userReadAcl.copy(recordMask = Some("120.1.2.0/0"))
|
val aclRule = userReadAcl.copy(recordMask = Some("120.1.2.0/1"))
|
||||||
val znTrue = Zone("40.120.in-addr.arpa.", "email")
|
val znTrue = Zone("40.120.in-addr.arpa.", "email")
|
||||||
val rsTrue =
|
val rsTrue =
|
||||||
RecordSet("id", "20.3", RecordType.PTR, 200, RecordSetStatus.Active, DateTime.now)
|
RecordSet("id", "20.3", RecordType.PTR, 200, RecordSetStatus.Active, DateTime.now)
|
||||||
|
@@ -47,7 +47,7 @@ object Dependencies {
|
|||||||
"com.typesafe" % "config" % configV,
|
"com.typesafe" % "config" % configV,
|
||||||
"org.typelevel" %% "cats-effect" % catsEffectV,
|
"org.typelevel" %% "cats-effect" % catsEffectV,
|
||||||
"com.47deg" %% "github4s" % "0.18.6",
|
"com.47deg" %% "github4s" % "0.18.6",
|
||||||
"com.comcast" % "ip4s-core_2.12" % "3.1.3",
|
"com.comcast" %% "ip4s-core" % "3.1.3",
|
||||||
"com.iheart" %% "ficus" % ficusV,
|
"com.iheart" %% "ficus" % ficusV,
|
||||||
"com.sun.mail" % "javax.mail" % "1.6.2",
|
"com.sun.mail" % "javax.mail" % "1.6.2",
|
||||||
"javax.mail" % "javax.mail-api" % "1.6.2",
|
"javax.mail" % "javax.mail-api" % "1.6.2",
|
||||||
|
Reference in New Issue
Block a user