@@ -20,6 +20,12 @@ const defaultConfig = Object.freeze({
2020 dbtablespace : '' ,
2121 dbhost : '' ,
2222 dbtype : '' ,
23+ dbsslmode : '' ,
24+ dbsslca : '' ,
25+ dbsslcert : '' ,
26+ dbsslkey : '' ,
27+ dbsslcrl : '' ,
28+ dbsslnoverify : false ,
2329 databases : {
2430 sqlite : 'SQLite' ,
2531 mysql : 'MySQL/MariaDB' ,
@@ -155,6 +161,67 @@ describe('Default setup page', () => {
155161 } )
156162} )
157163
164+ describe ( 'Encrypted database connection' , ( ) => {
165+ beforeEach ( cleanup )
166+ beforeEach ( ( ) => {
167+ removeInitialState ( )
168+ mockInitialState ( 'core' , 'links' , links )
169+ } )
170+
171+ it . each ( [ 'sqlite' , 'oci' ] ) ( 'Is not offered for %s' , async ( dbtype ) => {
172+ mockInitialState ( 'core' , 'config' , {
173+ ...defaultConfig ,
174+ dbtype,
175+ databases : { sqlite : 'SQLite' , mysql : 'MySQL/MariaDB' , pgsql : 'PostgreSQL' , oci : 'Oracle' } ,
176+ } as SetupConfig )
177+ const component = render ( SetupView )
178+
179+ await expect ( component . findByText ( 'Encrypted database connection' ) ) . rejects . toThrow ( )
180+ } )
181+
182+ it ( 'Offers the PDO options for mysql' , async ( ) => {
183+ mockInitialState ( 'core' , 'config' , { ...defaultConfig , dbtype : 'mysql' } as SetupConfig )
184+ const component = render ( SetupView )
185+
186+ await expect ( component . findByText ( 'Encrypted database connection' ) ) . resolves . not . toThrow ( )
187+ await expect ( component . findByRole ( 'textbox' , { name : / C A c e r t i f i c a t e p a t h / } ) ) . resolves . not . toThrow ( )
188+ await expect ( component . findByRole ( 'textbox' , { name : / C l i e n t c e r t i f i c a t e p a t h / } ) ) . resolves . not . toThrow ( )
189+ await expect ( component . findByRole ( 'textbox' , { name : / C l i e n t c e r t i f i c a t e k e y p a t h / } ) ) . resolves . not . toThrow ( )
190+ await expect ( component . findByRole ( 'checkbox' , { name : / D o n o t v e r i f y t h a t t h e s e r v e r c e r t i f i c a t e / } ) ) . resolves . not . toThrow ( )
191+
192+ // Both are PostgreSQL specific
193+ await expect ( component . findByRole ( 'textbox' , { name : / E n c r y p t i o n m o d e / } ) ) . rejects . toThrow ( )
194+ await expect ( component . findByRole ( 'textbox' , { name : / C e r t i f i c a t e r e v o c a t i o n l i s t p a t h / } ) ) . rejects . toThrow ( )
195+ } )
196+
197+ it ( 'Offers the libpq parameters for pgsql' , async ( ) => {
198+ mockInitialState ( 'core' , 'config' , { ...defaultConfig , dbtype : 'pgsql' } as SetupConfig )
199+ const component = render ( SetupView )
200+
201+ await expect ( component . findByRole ( 'textbox' , { name : / E n c r y p t i o n m o d e / } ) ) . resolves . not . toThrow ( )
202+ await expect ( component . findByRole ( 'textbox' , { name : / C A c e r t i f i c a t e p a t h / } ) ) . resolves . not . toThrow ( )
203+ await expect ( component . findByRole ( 'textbox' , { name : / C l i e n t c e r t i f i c a t e p a t h / } ) ) . resolves . not . toThrow ( )
204+ await expect ( component . findByRole ( 'textbox' , { name : / C l i e n t c e r t i f i c a t e k e y p a t h / } ) ) . resolves . not . toThrow ( )
205+ await expect ( component . findByRole ( 'textbox' , { name : / C e r t i f i c a t e r e v o c a t i o n l i s t p a t h / } ) ) . resolves . not . toThrow ( )
206+
207+ // MySQL specific
208+ await expect ( component . findByRole ( 'checkbox' , { name : / D o n o t v e r i f y t h a t t h e s e r v e r c e r t i f i c a t e / } ) ) . rejects . toThrow ( )
209+ } )
210+
211+ it ( 'Renders the submitted values on error' , async ( ) => {
212+ mockInitialState ( 'core' , 'config' , {
213+ ...defaultConfig ,
214+ dbtype : 'pgsql' ,
215+ dbsslmode : 'verify-full' ,
216+ dbsslca : '/ca.pem' ,
217+ } as SetupConfig )
218+ const component = render ( SetupView )
219+
220+ expect ( ( await component . findByRole ( 'textbox' , { name : / E n c r y p t i o n m o d e / } ) as HTMLInputElement ) . value ) . toBe ( 'verify-full' )
221+ expect ( ( await component . findByRole ( 'textbox' , { name : / C A c e r t i f i c a t e p a t h / } ) as HTMLInputElement ) . value ) . toBe ( '/ca.pem' )
222+ } )
223+ } )
224+
158225describe ( 'Setup page with errors and warning' , ( ) => {
159226 beforeEach ( cleanup )
160227 beforeEach ( ( ) => {
0 commit comments