mirror of
https://github.com/VinylDNS/vinyldns
synced 2025-09-02 15:25:44 +00:00
Update messages
This commit is contained in:
@@ -24,6 +24,7 @@ import vinyldns.core.domain.membership.LockStatus.LockStatus
|
|||||||
import vinyldns.core.domain.zone.ZoneRepository
|
import vinyldns.core.domain.zone.ZoneRepository
|
||||||
import vinyldns.core.domain.membership._
|
import vinyldns.core.domain.membership._
|
||||||
import vinyldns.core.domain.record.RecordSetRepository
|
import vinyldns.core.domain.record.RecordSetRepository
|
||||||
|
import vinyldns.core.Messages._
|
||||||
|
|
||||||
object MembershipService {
|
object MembershipService {
|
||||||
def apply(dataAccessor: ApiDataAccessor): MembershipService =
|
def apply(dataAccessor: ApiDataAccessor): MembershipService =
|
||||||
@@ -235,7 +236,7 @@ class MembershipService(
|
|||||||
.getGroupByName(name)
|
.getGroupByName(name)
|
||||||
.map {
|
.map {
|
||||||
case Some(existingGroup) if existingGroup.status != GroupStatus.Deleted =>
|
case Some(existingGroup) if existingGroup.status != GroupStatus.Deleted =>
|
||||||
GroupAlreadyExistsError(s"Group with name $name already exists").asLeft
|
GroupAlreadyExistsError(GroupAlreadyExistsErrorMsg.format(name, existingGroup.email)).asLeft
|
||||||
case _ =>
|
case _ =>
|
||||||
().asRight
|
().asRight
|
||||||
}
|
}
|
||||||
@@ -257,7 +258,7 @@ class MembershipService(
|
|||||||
.map {
|
.map {
|
||||||
case Some(existingGroup)
|
case Some(existingGroup)
|
||||||
if existingGroup.status != GroupStatus.Deleted && existingGroup.id != groupId =>
|
if existingGroup.status != GroupStatus.Deleted && existingGroup.id != groupId =>
|
||||||
GroupAlreadyExistsError(s"Group with name $name already exists").asLeft
|
GroupAlreadyExistsError(GroupAlreadyExistsErrorMsg.format(name, existingGroup.email)).asLeft
|
||||||
case _ =>
|
case _ =>
|
||||||
().asRight
|
().asRight
|
||||||
}
|
}
|
||||||
@@ -267,7 +268,7 @@ class MembershipService(
|
|||||||
zoneRepo
|
zoneRepo
|
||||||
.getZonesByAdminGroupId(group.id)
|
.getZonesByAdminGroupId(group.id)
|
||||||
.map { zones =>
|
.map { zones =>
|
||||||
ensuring(InvalidGroupRequestError(s"${group.name} is the admin of a zone. Cannot delete."))(
|
ensuring(InvalidGroupRequestError(ZoneAdminError.format(group.name)))(
|
||||||
zones.isEmpty
|
zones.isEmpty
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -279,7 +280,7 @@ class MembershipService(
|
|||||||
.map { rsId =>
|
.map { rsId =>
|
||||||
ensuring(
|
ensuring(
|
||||||
InvalidGroupRequestError(
|
InvalidGroupRequestError(
|
||||||
s"${group.name} is the owner for a record set including $rsId. Cannot delete."
|
RecordSetOwnerError.format(group.name, rsId)
|
||||||
)
|
)
|
||||||
)(rsId.isEmpty)
|
)(rsId.isEmpty)
|
||||||
}
|
}
|
||||||
@@ -291,7 +292,7 @@ class MembershipService(
|
|||||||
.map { zId =>
|
.map { zId =>
|
||||||
ensuring(
|
ensuring(
|
||||||
InvalidGroupRequestError(
|
InvalidGroupRequestError(
|
||||||
s"${group.name} has an ACL rule for a zone including $zId. Cannot delete."
|
ACLRuleError.format(group.name, zId)
|
||||||
)
|
)
|
||||||
)(zId.isEmpty)
|
)(zId.isEmpty)
|
||||||
}
|
}
|
||||||
|
@@ -28,6 +28,7 @@ import vinyldns.core.domain.auth.AuthPrincipal
|
|||||||
import vinyldns.core.domain.membership.Group
|
import vinyldns.core.domain.membership.Group
|
||||||
import vinyldns.core.domain.record.{RecordSet, RecordType}
|
import vinyldns.core.domain.record.{RecordSet, RecordType}
|
||||||
import vinyldns.core.domain.zone.Zone
|
import vinyldns.core.domain.zone.Zone
|
||||||
|
import vinyldns.core.Messages._
|
||||||
|
|
||||||
import scala.util.matching.Regex
|
import scala.util.matching.Regex
|
||||||
|
|
||||||
@@ -316,7 +317,7 @@ object RecordSetValidations {
|
|||||||
|
|
||||||
def validRecordNameFilterLength(recordNameFilter: String): Either[Throwable, Unit] =
|
def validRecordNameFilterLength(recordNameFilter: String): Either[Throwable, Unit] =
|
||||||
ensuring(
|
ensuring(
|
||||||
InvalidRequest("recordNameFilter must contain at least two letters or numbers.")
|
InvalidRequest(RecordNameFilterError)
|
||||||
) {
|
) {
|
||||||
val searchRegex: Regex = """[a-zA-Z0-9].*[a-zA-Z0-9]+""".r
|
val searchRegex: Regex = """[a-zA-Z0-9].*[a-zA-Z0-9]+""".r
|
||||||
searchRegex.findFirstIn(recordNameFilter).isDefined
|
searchRegex.findFirstIn(recordNameFilter).isDefined
|
||||||
|
@@ -30,6 +30,7 @@ import vinyldns.core.domain.DomainHelpers.removeWhitespace
|
|||||||
import vinyldns.core.domain.Fqdn
|
import vinyldns.core.domain.Fqdn
|
||||||
import vinyldns.core.domain.record._
|
import vinyldns.core.domain.record._
|
||||||
import vinyldns.core.domain.zone._
|
import vinyldns.core.domain.zone._
|
||||||
|
import vinyldns.core.Messages._
|
||||||
|
|
||||||
trait DnsJsonProtocol extends JsonValidation {
|
trait DnsJsonProtocol extends JsonValidation {
|
||||||
import vinyldns.core.domain.record.RecordType._
|
import vinyldns.core.domain.record.RecordType._
|
||||||
@@ -373,7 +374,7 @@ trait DnsJsonProtocol extends JsonValidation {
|
|||||||
.required[String]("Missing NS.nsdname")
|
.required[String]("Missing NS.nsdname")
|
||||||
.check(
|
.check(
|
||||||
"NS must be less than 255 characters" -> checkDomainNameLen,
|
"NS must be less than 255 characters" -> checkDomainNameLen,
|
||||||
"NS data must be absolute" -> nameContainsDots
|
NSDataError -> nameContainsDots
|
||||||
)
|
)
|
||||||
.map(Fqdn.apply)
|
.map(Fqdn.apply)
|
||||||
.map(NSData.apply)
|
.map(NSData.apply)
|
||||||
|
@@ -36,6 +36,7 @@ import vinyldns.core.TestMembershipData._
|
|||||||
import vinyldns.core.domain.Fqdn
|
import vinyldns.core.domain.Fqdn
|
||||||
import vinyldns.core.domain.membership.Group
|
import vinyldns.core.domain.membership.Group
|
||||||
import vinyldns.core.domain.record._
|
import vinyldns.core.domain.record._
|
||||||
|
import vinyldns.core.Messages._
|
||||||
|
|
||||||
import scala.util.matching.Regex
|
import scala.util.matching.Regex
|
||||||
|
|
||||||
@@ -601,7 +602,7 @@ class RecordSetValidationsSpec
|
|||||||
val invalidString = "*o*"
|
val invalidString = "*o*"
|
||||||
val error = leftValue(validRecordNameFilterLength(invalidString))
|
val error = leftValue(validRecordNameFilterLength(invalidString))
|
||||||
error shouldBe an[InvalidRequest]
|
error shouldBe an[InvalidRequest]
|
||||||
error.getMessage() shouldBe "recordNameFilter must contain at least two letters or numbers."
|
error.getMessage() shouldBe RecordNameFilterError
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -27,6 +27,7 @@ import vinyldns.core.domain.record._
|
|||||||
import vinyldns.core.domain.zone.{CreateZoneInput, UpdateZoneInput, ZoneConnection}
|
import vinyldns.core.domain.zone.{CreateZoneInput, UpdateZoneInput, ZoneConnection}
|
||||||
import vinyldns.core.TestRecordSetData._
|
import vinyldns.core.TestRecordSetData._
|
||||||
import vinyldns.core.domain.Fqdn
|
import vinyldns.core.domain.Fqdn
|
||||||
|
import vinyldns.core.Messages._
|
||||||
|
|
||||||
class VinylDNSJsonProtocolSpec
|
class VinylDNSJsonProtocolSpec
|
||||||
extends AnyWordSpec
|
extends AnyWordSpec
|
||||||
@@ -594,7 +595,7 @@ class VinylDNSJsonProtocolSpec
|
|||||||
("records" -> data)
|
("records" -> data)
|
||||||
|
|
||||||
val thrown = the[MappingException] thrownBy recordSetJValue.extract[RecordSet]
|
val thrown = the[MappingException] thrownBy recordSetJValue.extract[RecordSet]
|
||||||
thrown.msg should include("NS data must be absolute")
|
thrown.msg should include(NSDataError)
|
||||||
}
|
}
|
||||||
"round trip a DS record set" in {
|
"round trip a DS record set" in {
|
||||||
val rs = RecordSet(
|
val rs = RecordSet(
|
||||||
|
@@ -18,36 +18,65 @@ package vinyldns.core
|
|||||||
|
|
||||||
object Messages {
|
object Messages {
|
||||||
|
|
||||||
// When less than two letters or numbers is filled in Record Name Filter field in RecordSetSearch page
|
// Error displayed when less than two letters or numbers is filled in Record Name Filter field in RecordSetSearch page
|
||||||
val RecordNameFilterError = "Record Name Filter field must contain at least two letters or numbers to perform a RecordSet Search."
|
val RecordNameFilterError =
|
||||||
|
"Record Name Filter field must contain at least two letters or numbers to perform a RecordSet Search."
|
||||||
|
|
||||||
// When creating group with name that already exists
|
/*
|
||||||
// s"Group with name $name already exists. Please try a different name or contact ${existingGroup.email} to be added to the group."
|
* Error displayed when attempting to create group with name that already exists
|
||||||
val GroupAlreadyExistsError = s"Group with name {TestGroup} already exists. Please try a different name or contact {test@test.com} to be added to the group."
|
*
|
||||||
|
* Placeholders:
|
||||||
|
* 1. [string] group name
|
||||||
|
* 2. [string] group email address
|
||||||
|
*/
|
||||||
|
val GroupAlreadyExistsErrorMsg =
|
||||||
|
"Group with name %s already exists. Please try a different name or contact %s to be added to the group."
|
||||||
|
|
||||||
// When deleting a group being the admin of a zone
|
/*
|
||||||
// s"${group.name} is the admin of a zone. Cannot delete. Please transfer the ownership to another group before deleting."
|
* Error displayed when deleting a group being the admin of a zone
|
||||||
val ZoneAdminError = s"{TestGroup} is the admin of a zone. Cannot delete. Please transfer the ownership to another group before deleting."
|
*
|
||||||
|
* Placeholders:
|
||||||
|
* 1. [string] group name
|
||||||
|
*/
|
||||||
|
val ZoneAdminError =
|
||||||
|
"%s is the admin of a zone. Cannot delete. Please transfer the ownership to another group before deleting."
|
||||||
|
|
||||||
// When deleting a group being the owner for a record set
|
/*
|
||||||
// s"${group.name} is the owner for a record set including $rsId. Cannot delete. Please transfer the ownership to another group before deleting.
|
* Error displayed when deleting a group being the owner for a record set
|
||||||
val RecordSetOwnerError = s"{TestGroup} is the owner for a record set including {RS_ID}. Cannot delete. Please transfer the ownership to another group before deleting."
|
*
|
||||||
|
* Placeholders:
|
||||||
|
* 1. [string] group name
|
||||||
|
* 2. [string] record set id
|
||||||
|
*/
|
||||||
|
val RecordSetOwnerError =
|
||||||
|
"%s is the owner for a record set including %s. Cannot delete. Please transfer the ownership to another group before deleting."
|
||||||
|
|
||||||
// When deleting a group which has an ACL rule for a zone
|
/*
|
||||||
// s"${group.name} has an ACL rule for a zone including $zId. Cannot delete. Please transfer the ownership to another group before deleting."
|
* Error displayed when deleting a group which has an ACL rule for a zone
|
||||||
val ACLRuleError = s"{TestGroup} has an ACL rule for a zone including {Z_ID}. Cannot delete. Please transfer the ownership to another group before deleting."
|
*
|
||||||
|
* Placeholders:
|
||||||
|
* 1. [string] group name
|
||||||
|
* 2. [string] zone id
|
||||||
|
*/
|
||||||
|
val ACLRuleError =
|
||||||
|
"%s has an ACL rule for a zone including %s. Cannot delete. Please transfer the ownership to another group before deleting."
|
||||||
|
|
||||||
// When NSData field is not a positive integer
|
// Error displayed when NSData field is not a positive integer
|
||||||
val NSDataError = "NS data must be a positive integer"
|
val NSDataError = "NS data must be a positive integer"
|
||||||
|
|
||||||
// When importing files other than .csv
|
// Error displayed when importing files other than .csv
|
||||||
val ImportError = "Import failed. Not a valid file. File should be of ‘.csv’ type."
|
val ImportError = "Import failed. Not a valid file. File should be of ‘.csv’ type."
|
||||||
|
|
||||||
// When user is not authorized to make changes to the record
|
/*
|
||||||
// s"""User "$userName" is not authorized. Contact ${ownerType.toString.toLowerCase} owner group:
|
* Error displayed when user is not authorized to make changes to the record
|
||||||
// |${ownerGroupName.getOrElse(ownerGroupId)} at ${contactEmail.getOrElse("")} to make DNS changes.
|
*
|
||||||
// |You must be a part of the owner group to make DNS changes.""".stripMargin .replaceAll("\n", " ")
|
* Placeholders:
|
||||||
val NotAuthorizedError = s"""User {"dummy"} is not authorized. Contact {zone} owner group: {ok-group} at
|
* 1. [string] user name
|
||||||
{test@test.com} to make DNS changes. You must be a part of the owner group to make DNS changes."""
|
* 2. [string] owner type
|
||||||
|
* 3. [string] owner group name | owner group id
|
||||||
|
* 4. [string] contact email
|
||||||
|
*/
|
||||||
|
val NotAuthorizedErrorMsg =
|
||||||
|
"User '%s' is not authorized. Contact %s owner group: %s at %s to make DNS changes."
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -19,6 +19,7 @@ package vinyldns.core.domain
|
|||||||
import vinyldns.core.domain.batch.OwnerType.OwnerType
|
import vinyldns.core.domain.batch.OwnerType.OwnerType
|
||||||
import vinyldns.core.domain.record.{RecordData, RecordSet, RecordType}
|
import vinyldns.core.domain.record.{RecordData, RecordSet, RecordType}
|
||||||
import vinyldns.core.domain.record.RecordType.RecordType
|
import vinyldns.core.domain.record.RecordType.RecordType
|
||||||
|
import vinyldns.core.Messages._
|
||||||
|
|
||||||
// $COVERAGE-OFF$
|
// $COVERAGE-OFF$
|
||||||
sealed abstract class DomainValidationError(val isFatal: Boolean = true) {
|
sealed abstract class DomainValidationError(val isFatal: Boolean = true) {
|
||||||
@@ -134,9 +135,12 @@ final case class UserIsNotAuthorizedError(
|
|||||||
ownerGroupName: Option[String] = None
|
ownerGroupName: Option[String] = None
|
||||||
) extends DomainValidationError {
|
) extends DomainValidationError {
|
||||||
def message: String =
|
def message: String =
|
||||||
s"""User "$userName" is not authorized. Contact ${ownerType.toString.toLowerCase} owner group:
|
NotAuthorizedErrorMsg.format(
|
||||||
|${ownerGroupName.getOrElse(ownerGroupId)} at ${contactEmail.getOrElse("")}.""".stripMargin
|
userName,
|
||||||
.replaceAll("\n", " ")
|
ownerType.toString.toLowerCase,
|
||||||
|
ownerGroupName.getOrElse(ownerGroupId),
|
||||||
|
contactEmail.getOrElse("")
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
final case class RecordNameNotUniqueInBatch(name: String, typ: RecordType)
|
final case class RecordNameNotUniqueInBatch(name: String, typ: RecordType)
|
||||||
|
@@ -177,7 +177,7 @@
|
|||||||
$scope.$apply()
|
$scope.$apply()
|
||||||
resolve($scope.newBatch.changes.length);
|
resolve($scope.newBatch.changes.length);
|
||||||
} else {
|
} else {
|
||||||
reject("Import failed. Not a valid file.");
|
reject("Import failed. Not a valid file. File should be of ‘.csv’ type.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
reader.readAsText(file);
|
reader.readAsText(file);
|
||||||
|
Reference in New Issue
Block a user