@@ -98,106 +98,46 @@ describe('ConfigValidator', () => {
9898 const result = ConfigValidator . validate ( config ) ;
9999
100100 expect ( result . valid ) . toBe ( false ) ;
101- expect ( result . errors ) . toContain ( 'Password must be 8-16 characters (Mopar requirement) ' ) ;
101+ expect ( result . errors ) . toContain ( 'Password must be at least 8 characters ' ) ;
102102 } ) ;
103103
104- test ( 'should fail when password is too long' , ( ) => {
104+ test ( 'should fail when password is extremely long' , ( ) => {
105105 const config = {
106106 email : 'test@example.com' ,
107- password : 'ThisPasswordIsTooLong17! ' ,
107+ password : 'ThisPasswordIsWayTooLongForAnything1234567890 ' ,
108108 } ;
109109
110110 const result = ConfigValidator . validate ( config ) ;
111111
112112 expect ( result . valid ) . toBe ( false ) ;
113- expect ( result . errors ) . toContain ( 'Password must be 8-16 characters (Mopar requirement )' ) ;
113+ expect ( result . errors ) . toContain ( 'Password seems unusually long (may not work with Mopar.com )' ) ;
114114 } ) ;
115115
116- test ( 'should fail when password missing uppercase ' , ( ) => {
116+ test ( 'should pass with 8-character password ' , ( ) => {
117117 const config = {
118118 email : 'test@example.com' ,
119- password : 'password1! ' ,
119+ password : 'password ' ,
120120 } ;
121121
122122 const result = ConfigValidator . validate ( config ) ;
123123
124- expect ( result . valid ) . toBe ( false ) ;
125- expect ( result . errors ) . toContain ( 'Password must contain at least 1 uppercase letter (A-Z)' ) ;
126- } ) ;
127-
128- test ( 'should fail when password missing lowercase' , ( ) => {
129- const config = {
130- email : 'test@example.com' ,
131- password : 'PASSWORD1!' ,
132- } ;
133-
134- const result = ConfigValidator . validate ( config ) ;
135-
136- expect ( result . valid ) . toBe ( false ) ;
137- expect ( result . errors ) . toContain ( 'Password must contain at least 1 lowercase letter (a-z)' ) ;
138- } ) ;
139-
140- test ( 'should fail when password missing number' , ( ) => {
141- const config = {
142- email : 'test@example.com' ,
143- password : 'Password!' ,
144- } ;
145-
146- const result = ConfigValidator . validate ( config ) ;
147-
148- expect ( result . valid ) . toBe ( false ) ;
149- expect ( result . errors ) . toContain ( 'Password must contain at least 1 number (0-9)' ) ;
150- } ) ;
151-
152- test ( 'should fail when password missing special character' , ( ) => {
153- const config = {
154- email : 'test@example.com' ,
155- password : 'Password1' ,
156- } ;
157-
158- const result = ConfigValidator . validate ( config ) ;
159-
160- expect ( result . valid ) . toBe ( false ) ;
161- expect ( result . errors ) . toContain ( 'Password must contain at least 1 special character (@$!%*?&_-)' ) ;
162- } ) ;
163-
164- test ( 'should fail when password has character repeated 3 times' , ( ) => {
165- const config = {
166- email : 'test@example.com' ,
167- password : 'Passsword1!' ,
168- } ;
169-
170- const result = ConfigValidator . validate ( config ) ;
171-
172- expect ( result . valid ) . toBe ( false ) ;
173- expect ( result . errors ) . toContain ( 'Password cannot have any character repeated more than twice (e.g. aaa, 111)' ) ;
174- } ) ;
175-
176- test ( 'should fail when password has sequential ascending characters' , ( ) => {
177- const config = {
178- email : 'test@example.com' ,
179- password : 'XYZword5!' ,
180- } ;
181-
182- const result = ConfigValidator . validate ( config ) ;
183-
184- expect ( result . valid ) . toBe ( false ) ;
185- expect ( result . errors ) . toContain ( 'Password cannot have more than two sequential characters (e.g. ABC, xyz, 123)' ) ;
124+ expect ( result . valid ) . toBe ( true ) ;
125+ expect ( result . errors ) . toEqual ( [ ] ) ;
186126 } ) ;
187127
188- test ( 'should fail when password has sequential numbers ' , ( ) => {
128+ test ( 'should pass with password without special characters ' , ( ) => {
189129 const config = {
190130 email : 'test@example.com' ,
191- password : 'Password123! ' ,
131+ password : 'MyPassword15 ' ,
192132 } ;
193133
194134 const result = ConfigValidator . validate ( config ) ;
195135
196- expect ( result . valid ) . toBe ( false ) ;
197- expect ( result . errors ) . toContain ( 'Password cannot have more than two sequential characters (e.g. ABC, xyz, 123)' ) ;
136+ expect ( result . valid ) . toBe ( true ) ;
137+ expect ( result . errors ) . toEqual ( [ ] ) ;
198138 } ) ;
199139
200- test ( 'should pass with valid Mopar-compliant password ' , ( ) => {
140+ test ( 'should pass with password containing special characters ' , ( ) => {
201141 const config = {
202142 email : 'test@example.com' ,
203143 password : 'MyPass42!' ,
@@ -209,16 +149,20 @@ describe('ConfigValidator', () => {
209149 expect ( result . errors ) . toEqual ( [ ] ) ;
210150 } ) ;
211151
212- test ( 'should pass with another valid password' , ( ) => {
213- const config = {
214- email : 'test@example.com' ,
215- password : 'Secure$2024' ,
216- } ;
217-
218- const result = ConfigValidator . validate ( config ) ;
219-
220- expect ( result . valid ) . toBe ( true ) ;
221- expect ( result . errors ) . toEqual ( [ ] ) ;
152+ test ( 'should pass with various valid passwords' , ( ) => {
153+ const validPasswords = [
154+ 'password123' , // no special char, no uppercase
155+ 'PASSWORD123' , // no special char, no lowercase
156+ 'Password' , // no number, no special char
157+ 'MyPass42!' , // all requirements (if they existed)
158+ 'Secure$2024' , // all requirements
159+ ] ;
160+
161+ validPasswords . forEach ( ( password ) => {
162+ const config = { email : 'test@example.com' , password } ;
163+ const result = ConfigValidator . validate ( config ) ;
164+ expect ( result . valid ) . toBe ( true ) ;
165+ } ) ;
222166 } ) ;
223167
224168 test ( 'should fail when PIN is not 4 digits' , ( ) => {
@@ -320,16 +264,10 @@ describe('ConfigValidator', () => {
320264 const result = ConfigValidator . validate ( config ) ;
321265
322266 expect ( result . valid ) . toBe ( false ) ;
323- // Password "short" will fail multiple requirements:
324- // 1. Email invalid
325- // 2. Length (< 8)
326- // 3. No uppercase
327- // 4. No number
328- // 5. No special char
329- // 6. PIN invalid
330- // 7. Debug not boolean
331- expect ( result . errors . length ) . toBeGreaterThanOrEqual ( 7 ) ;
267+ // Should have at least 4 errors: email, password, PIN, debug
268+ expect ( result . errors . length ) . toBe ( 4 ) ;
332269 expect ( result . errors ) . toContain ( 'Email format is invalid (must be a valid email address)' ) ;
270+ expect ( result . errors ) . toContain ( 'Password must be at least 8 characters' ) ;
333271 expect ( result . errors ) . toContain ( 'PIN must be exactly 4 digits (e.g. "1234")' ) ;
334272 expect ( result . errors ) . toContain ( 'Debug mode must be true or false' ) ;
335273 } ) ;
0 commit comments