44#
55#
66
7+ set -o pipefail
8+
9+ PWQCHECK_BIN=" $( dirname " $0 " ) /../pwqcheck"
10+
711if [ -t 1 ]; then
812# Colors for better visibility
913 GREEN=' \033[0;32m'
@@ -22,59 +26,53 @@ test_password() {
2226 local expected=" $3 "
2327 local test_name=" $4 "
2428
25- printf " Testing %-40s" " $test_name :"
26-
27- PWQCHECK_BIN=" $( dirname " $0 " ) /../pwqcheck"
29+ printf " %-40s" " $test_name "
2830
2931 output=$( echo " $password " | " $PWQCHECK_BIN " -1 " min=$min_params " 2>&1 )
3032 status=$?
3133
3234 if [ " $expected " = " pass" -a $status -eq 0 ] || \
3335 [ " $expected " = " fail" -a $status -ne 0 ]; then
3436 echo -e " ${GREEN} PASS${NC} "
35- echo " Password tested: '$password '"
36- echo " Result: $output "
37- echo
37+ # echo " Password tested: '$password'"
38+ # echo " Result: $output"
39+ # echo
3840 else
3941 echo -e " ${RED} FAIL${NC} "
4042 echo " Password tested: '$password '"
4143 echo " Expected: $expected "
4244 echo " Got: $output "
4345 echo " Exit status: $status "
4446 echo
45- return 1
47+ exit 1
4648 fi
4749}
4850
49- # Main test suite
50- main () {
51- echo " === Password Length Tests ==="
52- echo
51+ echo " Password Length Tests"
52+ echo
5353
54- # Test 1: Default minimum lengths
55- test_password " short" " 24,12,8,7,6" " fail" " Short password"
56- test_password " ThisIsAVeryLongPasswordThatShouldPass123!" " 24,12,8,7,6" " pass" " Long complex password"
54+ # Test 1: Default minimum lengths
55+ test_password " short" " 24,12,8,7,6" " fail" " Short password"
56+ test_password " ThisIsAVeryLongPasswordThatShouldPass123!" " 24,12,8,7,6" " pass" " Long complex password"
5757
58- # Test 2: Custom minimum lengths
59- test_password " pass123" " 6,6,6,6,6" " pass" " Password with relaxed mins"
60- test_password " a" " 6,6,6,6,6" " fail" " Single character password"
58+ # Test 2: Custom minimum lengths
59+ test_password " pass123" " 6,6,6,6,6" " pass" " Password with relaxed mins"
60+ test_password " a" " 6,6,6,6,6" " fail" " Single character password"
6161
62- # Test 3: Different complexity levels
63- test_password " BearD&Tach" " 8,8,8,8,8" " pass" " Simple but long password"
64- test_password " P@ssw0rd!" " 8,8,8,8,8" " pass" " Complex password"
62+ # Test 3: Different complexity levels
63+ test_password " BearD&Tach" " 8,8,8,8,8" " pass" " Simple but long password"
64+ test_password " P@ssw0rd!" " 8,8,8,8,8" " pass" " Complex password"
6565
66- # Test 4: Edge cases
67- test_password " YakMeas1" " 8,8,8,8,8" " pass" " Exactly minimum length"
68- test_password " 7chars" " 8,8,8,8,8" " fail" " Below minimum length"
66+ # Test 4: Edge cases
67+ test_password " YakMeas1" " 8,8,8,8,8" " pass" " Exactly minimum length"
68+ test_password " 7chars" " 8,8,8,8,8" " fail" " Below minimum length"
6969
70- # Test 5: Different complexity classes
71- echo " Testing complexity classes..."
72- test_password " FigRatMatBatSatWatPatCat" " 24,12,8,7,6" " pass" " N0: 24-char basic password"
73- test_password " Complex12Pass" " 24,12,8,7,6" " pass" " N1: 12-char mixed password"
74- test_password " P@ss8chr" " 24,12,8,7,6" " pass" " N2: 8-char complex password"
75- test_password " P@s7chr" " 24,12,8,7,6" " pass" " N3: 7-char complex password"
76- test_password " B!rd5#K" " 24,12,8,7,6" " pass" " N4: 6-char highly complex password"
77- }
70+ # Test 5: Different complexity classes
71+ echo " Testing complexity classes..."
72+ test_password " FigRatMatBatSatWatPatCat" " 24,12,8,7,6" " pass" " N0: 24-char basic password"
73+ test_password " Complex12Pass" " 24,12,8,7,6" " pass" " N1: 12-char mixed password"
74+ test_password " P@ss8chr" " 24,12,8,7,6" " pass" " N2: 8-char complex password"
75+ test_password " P@s7chr" " 24,12,8,7,6" " pass" " N3: 7-char complex password"
76+ test_password " B!rd5#K" " 24,12,8,7,6" " pass" " N4: 6-char highly complex password"
7877
79- # Run the tests
80- main
78+ echo -e " \nPassword length tests completed\n"
0 commit comments