From 774d23d19c93f7ab3fe487c218c55d65af4f4d81 Mon Sep 17 00:00:00 2001 From: Aravindh-Raju Date: Tue, 30 Aug 2022 11:40:19 +0530 Subject: [PATCH 1/3] Override ZoneConnection toString --- .../main/scala/vinyldns/core/domain/zone/Zone.scala | 10 ++++++++++ 1 file changed, 10 insertions(+) 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( From 0e804618603df0beb4042067fe231f40270cb09f Mon Sep 17 00:00:00 2001 From: Aravindh-Raju Date: Tue, 30 Aug 2022 12:11:02 +0530 Subject: [PATCH 2/3] Add test --- .../api/domain/zone/ZoneConnectionValidatorSpec.scala | 10 ++++++++++ 1 file changed, 10 insertions(+) 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..a5d0bf393 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\"; ]" + + // verify the same while displaying connection and transferConnection in Zone + 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 + } + } } } From e04500656a52e46dc52bc779296c9515a1396c90 Mon Sep 17 00:00:00 2001 From: Aravindh-Raju Date: Mon, 5 Sep 2022 15:15:16 +0530 Subject: [PATCH 3/3] Update as separate test --- .../api/domain/zone/ZoneConnectionValidatorSpec.scala | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 a5d0bf393..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 @@ -245,8 +245,8 @@ class ZoneConnectionValidatorSpec "Zone Connection toString" should { "not display key and algorithm" in { zc.toString shouldBe "ZoneConnection: [name=\"zc.\"; keyName=\"zc.\"; primaryServer=\"10.1.1.1\"; ]" - - // verify the same while displaying connection and transferConnection in Zone + } + "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 }