@@ -72,3 +72,55 @@ test('query with ssl with root cert', async () => {
72
72
73
73
DEFAULT_POOL_CONFIG . ssl = defaultSsl
74
74
} )
75
+
76
+ test ( 'query with invalid space empty encrypted connection string' , async ( ) => {
77
+ const res = await app . inject ( {
78
+ method : 'POST' ,
79
+ path : '/query' ,
80
+ headers : {
81
+ 'x-connection-encrypted' : CryptoJS . AES . encrypt ( ` ` , CRYPTO_KEY ) . toString ( ) ,
82
+ } ,
83
+ payload : { query : 'select 1;' } ,
84
+ } )
85
+ expect ( res . json ( ) ) . toMatchInlineSnapshot ( `
86
+ {
87
+ "error": "Invalid URL",
88
+ }
89
+ ` )
90
+ } )
91
+
92
+ test ( 'query with invalid empty encrypted connection string' , async ( ) => {
93
+ const res = await app . inject ( {
94
+ method : 'POST' ,
95
+ path : '/query' ,
96
+ headers : {
97
+ 'x-connection-encrypted' : CryptoJS . AES . encrypt ( `` , CRYPTO_KEY ) . toString ( ) ,
98
+ } ,
99
+ payload : { query : 'select 1;' } ,
100
+ } )
101
+ expect ( res . json ( ) ) . toMatchInlineSnapshot ( `
102
+ {
103
+ "error": "SASL: SCRAM-SERVER-FIRST-MESSAGE: client password must be a string",
104
+ "message": "SASL: SCRAM-SERVER-FIRST-MESSAGE: client password must be a string",
105
+ }
106
+ ` )
107
+ } )
108
+
109
+ test ( 'query with missing host connection string encrypted connection string' , async ( ) => {
110
+ const res = await app . inject ( {
111
+ method : 'POST' ,
112
+ path : '/query' ,
113
+ headers : {
114
+ 'x-connection-encrypted' : CryptoJS . AES . encrypt (
115
+ `postgres://name:password@:5432/postgres?sslmode=prefer` ,
116
+ CRYPTO_KEY
117
+ ) . toString ( ) ,
118
+ } ,
119
+ payload : { query : 'select 1;' } ,
120
+ } )
121
+ expect ( res . json ( ) ) . toMatchInlineSnapshot ( `
122
+ {
123
+ "error": "Invalid URL",
124
+ }
125
+ ` )
126
+ } )
0 commit comments