From 33a239b748f6a3a6e93a6b6b3a0c7c57d66e3f21 Mon Sep 17 00:00:00 2001 From: Daniel K Date: Fri, 21 Apr 2023 14:44:36 +0200 Subject: [PATCH] #21 formatting, usersConfig unitTest update (email is now optional) --- .../za/co/absa/logingw/rest/config/JwtConfig.scala | 6 +++--- .../absa/logingw/rest/config/UsersConfigTest.scala | 14 +++++++------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/service/src/main/scala/za/co/absa/logingw/rest/config/JwtConfig.scala b/service/src/main/scala/za/co/absa/logingw/rest/config/JwtConfig.scala index 9310d443..1e63bd1a 100644 --- a/service/src/main/scala/za/co/absa/logingw/rest/config/JwtConfig.scala +++ b/service/src/main/scala/za/co/absa/logingw/rest/config/JwtConfig.scala @@ -25,9 +25,9 @@ import scala.util.{Failure, Try, Success} @ConstructorBinding @ConfigurationProperties(prefix = "logingw.rest.jwt") case class JwtConfig( - algName: String, - expTime: Int - ) extends ConfigValidatable { + algName: String, + expTime: Int +) extends ConfigValidatable { @PostConstruct def init() { diff --git a/service/src/test/scala/za/co/absa/logingw/rest/config/UsersConfigTest.scala b/service/src/test/scala/za/co/absa/logingw/rest/config/UsersConfigTest.scala index 2cddac30..c41075fc 100644 --- a/service/src/test/scala/za/co/absa/logingw/rest/config/UsersConfigTest.scala +++ b/service/src/test/scala/za/co/absa/logingw/rest/config/UsersConfigTest.scala @@ -27,7 +27,7 @@ class UsersConfigTest extends AnyFlatSpec with Matchers { userCfg.validate() } - it should "fail on missing user/pwd/mail/groups" in { + it should "fail on missing user/pwd/groups" in { intercept[ConfigValidationException] { userCfg.copy(username = null).validate() }.msg should include("username is empty") @@ -36,19 +36,19 @@ class UsersConfigTest extends AnyFlatSpec with Matchers { userCfg.copy(password = null).validate() }.msg should include("password is empty") - intercept[ConfigValidationException] { - userCfg.copy(email = null).validate() - }.msg should include("email is empty") - intercept[ConfigValidationException] { userCfg.copy(groups = null).validate() }.msg should include("groups are missing") } - it should "validate ok empty groups" in { + it should "succeed empty groups" in { userCfg.copy(groups = Array.empty).validate() } + it should "succeed missing email (it is optional)" in { + userCfg.copy(email = null).validate() + } + val usersCfg = UsersConfig(knownUsers = Array(userCfg)) "UsersConfig" should "validate ok expected filled content" in { usersCfg.validate() @@ -72,7 +72,7 @@ class UsersConfigTest extends AnyFlatSpec with Matchers { UserConfig("sameUser", "password2", "anotherMail@here.tld", Array()), UserConfig("sameUser2", "passwordX", "abc@def", Array()), - UserConfig("sameUser2", "passwordA", "jkl@mno", Array()), + UserConfig("sameUser2", "passwordA", null, Array()), UserConfig("okUser", "passwordO", "ooo@", Array()) )).validate()