diff --git a/modules/api/src/test/scala/vinyldns/api/domain/zone/ZoneConnectionValidatorSpec.scala b/modules/api/src/test/scala/vinyldns/api/domain/zone/ZoneConnectionValidatorSpec.scala index 10e3e53ac..d47b2e2d3 100644 --- a/modules/api/src/test/scala/vinyldns/api/domain/zone/ZoneConnectionValidatorSpec.scala +++ b/modules/api/src/test/scala/vinyldns/api/domain/zone/ZoneConnectionValidatorSpec.scala @@ -241,5 +241,15 @@ class ZoneConnectionValidatorSpec underTest.isValidBackendId(Some("bad")) shouldBe left } } + + "Zone Connection toString" should { + "not display key and algorithm" in { + zc.toString shouldBe "ZoneConnection: [name=\"zc.\"; keyName=\"zc.\"; primaryServer=\"10.1.1.1\"; ]" + } + "not display key and algorithm while displaying connection and transferConnection of a Zone" in { + val zoneString = s"""Zone: [id="${testZone.id}"; name="vinyldns."; account="system"; adminGroupId="system"; status="Active"; shared="false"; connection="Some(ZoneConnection: [name="vinyldns."; keyName="vinyldns."; primaryServer="10.1.1.1"; ])"; transferConnection="Some(ZoneConnection: [name="vinyldns."; keyName="vinyldns."; primaryServer="10.1.1.1"; ])"; reverse="false"; isTest="false"; created="${testZone.created}"; ]""" + testZone.toString shouldBe zoneString + } + } } } diff --git a/modules/core/src/main/scala/vinyldns/core/domain/zone/Zone.scala b/modules/core/src/main/scala/vinyldns/core/domain/zone/Zone.scala index 398bf6131..d5b658315 100644 --- a/modules/core/src/main/scala/vinyldns/core/domain/zone/Zone.scala +++ b/modules/core/src/main/scala/vinyldns/core/domain/zone/Zone.scala @@ -188,6 +188,16 @@ case class ZoneConnection( def decrypted(crypto: CryptoAlgebra): ZoneConnection = copy(key = crypto.decrypt(key)) + + override def toString: String = { + val sb = new StringBuilder + sb.append("ZoneConnection: [") + sb.append("name=\"").append(name).append("\"; ") + sb.append("keyName=\"").append(keyName).append("\"; ") + sb.append("primaryServer=\"").append(primaryServer).append("\"; ") + sb.append("]") + sb.toString + } } final case class LegacyDnsBackend(