From 376e7b62de815c81b1c3dbb1f61eda3fb4f88380 Mon Sep 17 00:00:00 2001 From: Aravindh-Raju Date: Mon, 29 Aug 2022 12:47:03 +0530 Subject: [PATCH 1/3] Override User toString --- .../vinyldns/core/domain/membership/User.scala | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/modules/core/src/main/scala/vinyldns/core/domain/membership/User.scala b/modules/core/src/main/scala/vinyldns/core/domain/membership/User.scala index 9172dc9a3..1ade5ca57 100644 --- a/modules/core/src/main/scala/vinyldns/core/domain/membership/User.scala +++ b/modules/core/src/main/scala/vinyldns/core/domain/membership/User.scala @@ -51,6 +51,23 @@ final case class User( def withEncryptedSecretKey(cryptoAlgebra: CryptoAlgebra): User = copy(secretKey = cryptoAlgebra.encrypt(secretKey)) + + override def toString: String = { + val sb = new StringBuilder + sb.append("User: [") + sb.append("id=\"").append(id).append("\"; ") + sb.append("userName=\"").append(userName).append("\"; ") + sb.append("firstName=\"").append(firstName.toString).append("\"; ") + sb.append("lastName=\"").append(lastName.toString).append("\"; ") + sb.append("email=\"").append(email.toString).append("\"; ") + sb.append("created=\"").append(created).append("\"; ") + sb.append("isSuper=\"").append(isSuper).append("\"; ") + sb.append("isSupport=\"").append(isSupport).append("\"; ") + sb.append("isTest=\"").append(isTest).append("\"; ") + sb.append("lockStatus=\"").append(lockStatus.toString).append("\"; ") + sb.append("]") + sb.toString + } } object User { From ddd4b355578ebaed33fcd212cd8cffda5ef34a7f Mon Sep 17 00:00:00 2001 From: Aravindh-Raju Date: Tue, 30 Aug 2022 12:27:00 +0530 Subject: [PATCH 2/3] Add test --- .../api/domain/membership/MembershipValidationsSpec.scala | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/modules/api/src/test/scala/vinyldns/api/domain/membership/MembershipValidationsSpec.scala b/modules/api/src/test/scala/vinyldns/api/domain/membership/MembershipValidationsSpec.scala index 84e7e842c..6919a8fba 100644 --- a/modules/api/src/test/scala/vinyldns/api/domain/membership/MembershipValidationsSpec.scala +++ b/modules/api/src/test/scala/vinyldns/api/domain/membership/MembershipValidationsSpec.scala @@ -94,7 +94,13 @@ class MembershipValidationsSpec val nonSuperAuth = AuthPrincipal(user, Seq()) canSeeGroup(okGroup.id, nonSuperAuth) should be(right) } + } + "User toString" should { + "not display access and secret keys" in { + val userString = s"""User: [id="ok"; userName="ok"; firstName="Some(ok)"; lastName="Some(ok)"; email="Some(test@test.com)"; created="${okUser.created}"; isSuper="false"; isSupport="false"; isTest="false"; lockStatus="Unlocked"; ]""" + okUser.toString shouldBe userString + } } } } From 00980970279f4419b322ec6419a56c516e991431 Mon Sep 17 00:00:00 2001 From: Aravindh-Raju Date: Tue, 8 Nov 2022 12:50:56 +0530 Subject: [PATCH 3/3] Resolve tests --- modules/portal/test/controllers/TestApplicationData.scala | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/portal/test/controllers/TestApplicationData.scala b/modules/portal/test/controllers/TestApplicationData.scala index 4ae89221b..0066fd4d0 100644 --- a/modules/portal/test/controllers/TestApplicationData.scala +++ b/modules/portal/test/controllers/TestApplicationData.scala @@ -160,7 +160,7 @@ trait TestApplicationData { this: Mockito => | "oldGroup": {}, | "id": "b6018a9b-c893-40e9-aa25-4ccfee460c18", | "created": "2022-07-22T08:19:22Z", - | "userName": "$frodoUser", + | "userName": "${frodoUser.userName}", | "groupChangeMessage": "" | } """.stripMargin) @@ -180,7 +180,7 @@ trait TestApplicationData { this: Mockito => | "oldGroup": {}, | "id": "b6018a9b-c893-40e9-aa25-4ccfee460c18", | "created": "2022-07-22T08:19:22Z", - | "userName": "$frodoUser", + | "userName": "${frodoUser.userName}", | "groupChangeMessage": "" | }], | "maxItems": 100