Skip to content

Commit

Permalink
#21 formatting, usersConfig unitTest update (email is now optional)
Browse files Browse the repository at this point in the history
  • Loading branch information
dk1844 committed Apr 21, 2023
1 parent ec6d665 commit 33a239b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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()
Expand All @@ -72,7 +72,7 @@ class UsersConfigTest extends AnyFlatSpec with Matchers {
UserConfig("sameUser", "password2", "[email protected]", Array()),

UserConfig("sameUser2", "passwordX", "abc@def", Array()),
UserConfig("sameUser2", "passwordA", "jkl@mno", Array()),
UserConfig("sameUser2", "passwordA", null, Array()),

UserConfig("okUser", "passwordO", "ooo@", Array())
)).validate()
Expand Down

0 comments on commit 33a239b

Please sign in to comment.