@@ -100,6 +100,36 @@ describe('SSLConfigSchema', () => {
100100 const result = SSLConfigSchema . parse ( sslConfig ) ;
101101 expect ( result . rejectUnauthorized ) . toBe ( true ) ;
102102 } ) ;
103+
104+ it ( 'should reject SSL config with cert but no key' , ( ) => {
105+ const sslConfig = {
106+ cert : '/path/to/cert.pem' ,
107+ // missing key
108+ } ;
109+
110+ const result = SSLConfigSchema . safeParse ( sslConfig ) ;
111+ expect ( result . success ) . toBe ( false ) ;
112+ } ) ;
113+
114+ it ( 'should reject SSL config with key but no cert' , ( ) => {
115+ const sslConfig = {
116+ key : '/path/to/key.pem' ,
117+ // missing cert
118+ } ;
119+
120+ const result = SSLConfigSchema . safeParse ( sslConfig ) ;
121+ expect ( result . success ) . toBe ( false ) ;
122+ } ) ;
123+
124+ it ( 'should accept SSL config with both cert and key' , ( ) => {
125+ const sslConfig = {
126+ cert : '/path/to/cert.pem' ,
127+ key : '/path/to/key.pem' ,
128+ } ;
129+
130+ const result = SSLConfigSchema . safeParse ( sslConfig ) ;
131+ expect ( result . success ) . toBe ( true ) ;
132+ } ) ;
103133} ) ;
104134
105135describe ( 'SQLDriverConfigSchema' , ( ) => {
@@ -312,4 +342,51 @@ describe('SQLDriverConfigSchema', () => {
312342
313343 expect ( ( ) => SQLDriverConfigSchema . parse ( config ) ) . not . toThrow ( ) ;
314344 } ) ;
345+
346+ it ( 'should reject SQL driver config with ssl=true but no sslConfig' , ( ) => {
347+ const config = {
348+ name : 'test-db' ,
349+ type : 'sql' ,
350+ dialect : 'postgresql' ,
351+ connectionString : 'postgresql://localhost/test' ,
352+ dataTypeMapping : {
353+ text : 'VARCHAR(255)' ,
354+ number : 'NUMERIC' ,
355+ boolean : 'BOOLEAN' ,
356+ date : 'DATE' ,
357+ datetime : 'TIMESTAMP' ,
358+ } ,
359+ ssl : true ,
360+ // missing sslConfig
361+ capabilities : { } ,
362+ } ;
363+
364+ const result = SQLDriverConfigSchema . safeParse ( config ) ;
365+ expect ( result . success ) . toBe ( false ) ;
366+ } ) ;
367+
368+ it ( 'should accept SQL driver config with ssl=true and sslConfig provided' , ( ) => {
369+ const config = {
370+ name : 'test-db' ,
371+ type : 'sql' ,
372+ dialect : 'postgresql' ,
373+ connectionString : 'postgresql://localhost/test' ,
374+ dataTypeMapping : {
375+ text : 'VARCHAR(255)' ,
376+ number : 'NUMERIC' ,
377+ boolean : 'BOOLEAN' ,
378+ date : 'DATE' ,
379+ datetime : 'TIMESTAMP' ,
380+ } ,
381+ ssl : true ,
382+ sslConfig : {
383+ rejectUnauthorized : true ,
384+ ca : '/path/to/ca.pem' ,
385+ } ,
386+ capabilities : { } ,
387+ } ;
388+
389+ const result = SQLDriverConfigSchema . safeParse ( config ) ;
390+ expect ( result . success ) . toBe ( true ) ;
391+ } ) ;
315392} ) ;
0 commit comments