From ec50c48c013758ac7d26aa7e65d4640e593254ee Mon Sep 17 00:00:00 2001 From: hongwei Date: Fri, 6 Jun 2025 12:45:29 +0200 Subject: [PATCH] refactor/update password validation tests for consistency and clarity --- .../test/scala/code/util/APIUtilTest.scala | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/obp-api/src/test/scala/code/util/APIUtilTest.scala b/obp-api/src/test/scala/code/util/APIUtilTest.scala index 0c6918d7e..1453f3418 100644 --- a/obp-api/src/test/scala/code/util/APIUtilTest.scala +++ b/obp-api/src/test/scala/code/util/APIUtilTest.scala @@ -848,28 +848,28 @@ class APIUtilTest extends FeatureSpec with Matchers with GivenWhenThen with Prop scenario(s"Test the ${nameOf(APIUtil.basicPasswordValidation _)} method") { val firefoxStrongPasswordProposal = "9YF]gZnXzAENM+]" - basicPasswordValidation(firefoxStrongPasswordProposal) shouldBe (SILENCE_IS_GOLDEN) // ✅ SILENCE_IS_GOLDEN - basicPasswordValidation("Abc!123 xyz") shouldBe (SILENCE_IS_GOLDEN) // ✅ SILENCE_IS_GOLDEN - basicPasswordValidation("SuperStrong#123") shouldBe (SILENCE_IS_GOLDEN) // ✅ SILENCE_IS_GOLDEN - basicPasswordValidation("Hello World!") shouldBe (SILENCE_IS_GOLDEN) // ✅ SILENCE_IS_GOLDEN - basicPasswordValidation(" ") shouldBe (SILENCE_IS_GOLDEN) // ✅ SILENCE_IS_GOLDEN allow space so far + basicPasswordValidation(firefoxStrongPasswordProposal) shouldBe (SILENCE_IS_GOLDEN) // SILENCE_IS_GOLDEN + basicPasswordValidation("Abc!123 xyz") shouldBe (SILENCE_IS_GOLDEN) // SILENCE_IS_GOLDEN + basicPasswordValidation("SuperStrong#123") shouldBe (SILENCE_IS_GOLDEN) // SILENCE_IS_GOLDEN + basicPasswordValidation("Hello World!") shouldBe (SILENCE_IS_GOLDEN) // SILENCE_IS_GOLDEN + basicPasswordValidation(" ") shouldBe (SILENCE_IS_GOLDEN) // SILENCE_IS_GOLDEN allow space so far - basicPasswordValidation("short💥") shouldBe (InvalidValueCharacters) // ❌ ErrorMessages.InvalidValueCharacters - basicPasswordValidation("a" * 513) shouldBe (InvalidValueLength) // ❌ ErrorMessages.InvalidValueLength + basicPasswordValidation("short") shouldBe (InvalidValueCharacters) // ErrorMessages.InvalidValueCharacters + basicPasswordValidation("a" * 513) shouldBe (InvalidValueLength) // ErrorMessages.InvalidValueLength } scenario(s"Test the ${nameOf(APIUtil.fullPasswordValidation _)} method") { val firefoxStrongPasswordProposal = "9YF]gZnXzAENM+]" - fullPasswordValidation(firefoxStrongPasswordProposal) shouldBe true// ✅ true - fullPasswordValidation("Abcd!123xyz") shouldBe true // ✅ true - fullPasswordValidation("SuperStrong#123") shouldBe true // ✅ true - fullPasswordValidation("Abcdefgh!1") shouldBe true // ✅ true - fullPasswordValidation("short1!") shouldBe false // ❌ false(too short) - fullPasswordValidation("alllowercase123!") shouldBe false // ❌ false(no capital letter) - fullPasswordValidation("ALLUPPERCASE123!") shouldBe false// ❌ false(no smaller case letter) - fullPasswordValidation("NoSpecialChar123") shouldBe false// ❌ false(not special character) + fullPasswordValidation(firefoxStrongPasswordProposal) shouldBe true// true + fullPasswordValidation("Abcd!123xyz") shouldBe true // true + fullPasswordValidation("SuperStrong#123") shouldBe true // true + fullPasswordValidation("Abcdefgh!1") shouldBe true // true + fullPasswordValidation("short1!") shouldBe false // false(too short) + fullPasswordValidation("alllowercase123!") shouldBe false // false(no capital letter) + fullPasswordValidation("ALLUPPERCASE123!") shouldBe false// false(no smaller case letter) + fullPasswordValidation("NoSpecialChar123") shouldBe false// false(not special character) } }