@@ -139,6 +139,89 @@ for (const platform of ["macos", "linux", "windows"]) {
139139 } ) ;
140140}
141141
142+ for ( const platform of [ "macos" , "linux" , "windows" ] ) {
143+ test ( `${ platform } offers DBeaver for Dameng and launches its native driver` , async ( context ) => {
144+ const appData = await mkdtemp ( path . join ( os . tmpdir ( ) , "jms-dameng-dbeaver-" ) ) ;
145+ context . after ( ( ) => rm ( appData , { recursive : true , force : true } ) ) ;
146+ const app = { getPath : ( ) => appData , isPackaged : false } ;
147+ const service = new ApplicationConfigService ( app , projectRoot ) ;
148+ service . builtInDir = async ( ) => path . join ( projectRoot , "plugins" , platform ) ;
149+ await service . initialize ( ) ;
150+ await service . updateSelection ( {
151+ category : "databases" ,
152+ protocol : "dameng" ,
153+ name : "dbeaver" ,
154+ pluginId : undefined ,
155+ path : process . execPath
156+ } ) ;
157+ await service . updateSelection ( {
158+ category : "databases" ,
159+ protocol : "dameng" ,
160+ name : "dbeaver" ,
161+ pluginId : undefined ,
162+ path : undefined ,
163+ makeDefault : true
164+ } ) ;
165+ const application = ( await service . getConfig ( ) ) . databases . find ( ( item ) => item . name === "dbeaver" ) ;
166+ assert . ok ( application ?. protocol . includes ( "dameng" ) ) ;
167+ assert . ok ( application . match_first . includes ( "dameng" ) ) ;
168+
169+ const launcher = new LocalApplicationLauncher ( app , projectRoot , service , null ) ;
170+ let launched = false ;
171+ launcher . launchExecutable = async ( selected , argumentString ) => {
172+ assert . equal ( selected . name , "dbeaver" ) ;
173+ assert . deepEqual ( localAppLauncherInternals . splitArguments ( argumentString ) , [
174+ "-con" ,
175+ "name=Dameng|driver=dameng|user=token-id|password=secret|host=gateway.example.com|port=5525|save=false|connect=true"
176+ ] ) ;
177+ launched = true ;
178+ } ;
179+ const payload = {
180+ protocol : "dameng" ,
181+ name : "Dameng" ,
182+ endpoint : { host : "gateway.example.com" , port : 5525 } ,
183+ token : { id : "token-id" , value : "secret" } ,
184+ asset : { info : { db_name : "business" } }
185+ } ;
186+ await launcher . launch ( `jms2://${ Buffer . from ( JSON . stringify ( payload ) ) . toString ( "base64" ) } ` ) ;
187+ assert . equal ( launched , true ) ;
188+ } ) ;
189+ }
190+
191+ for ( const platform of [ "macos" , "linux" ] ) {
192+ test ( `${ platform } offers a shell-safe Dameng disql launch` , async ( context ) => {
193+ const appData = await mkdtemp ( path . join ( os . tmpdir ( ) , "jms-dameng-disql-" ) ) ;
194+ context . after ( ( ) => rm ( appData , { recursive : true , force : true } ) ) ;
195+ const app = { getPath : ( ) => appData , isPackaged : false } ;
196+ const service = new ApplicationConfigService ( app , projectRoot ) ;
197+ service . builtInDir = async ( ) => path . join ( projectRoot , "plugins" , platform ) ;
198+ await service . initialize ( ) ;
199+ await service . updateSelection ( {
200+ category : "databases" ,
201+ protocol : "dameng" ,
202+ name : "terminal" ,
203+ pluginId : undefined ,
204+ path : undefined ,
205+ makeDefault : true
206+ } ) ;
207+ const launcher = new LocalApplicationLauncher ( app , projectRoot , service , null ) ;
208+ let launched = false ;
209+ launcher . launchTerminal = async ( selected , command ) => {
210+ assert . equal ( selected . name , "terminal" ) ;
211+ assert . equal ( command , "disql 'token-id/p'\\''a&b@gateway.example.com:5525'" ) ;
212+ launched = true ;
213+ } ;
214+ const payload = {
215+ protocol : "dameng" ,
216+ name : "Dameng" ,
217+ endpoint : { host : "gateway.example.com" , port : 5525 } ,
218+ token : { id : "token-id" , value : "p'a&b" }
219+ } ;
220+ await launcher . launch ( `jms2://${ Buffer . from ( JSON . stringify ( payload ) ) . toString ( "base64" ) } ` ) ;
221+ assert . equal ( launched , true ) ;
222+ } ) ;
223+ }
224+
142225for ( const [ platform , protocol , expectedClient ] of [
143226 [ "macos" , "ssh" , "terminal" ] ,
144227 [ "linux" , "ssh" , "terminal" ] ,
0 commit comments