@@ -272,6 +272,12 @@ def test_search(self):
272272 self .assertTrue (out .startswith (b'Listing results for aws:' ))
273273 self .assertIn (b'aws.apache' , out )
274274
275+ def test_backup (self ):
276+ out , err , rc = self .run_cmd ("backup /tmp/ssh_backup {0}" .format (
277+ self .config_arg ))
278+
279+ self .assertEqual (True , os .path .exists ("/tmp/ssh_backup" ))
280+
275281 def test_invalid_search (self ):
276282
277283 out , err , rc = self .run_cmd ("search THEREISNOTHINGRELATEDWITHME {0}" .format (self .config_arg ))
@@ -283,7 +289,6 @@ def test_delete_all(self):
283289
284290 self .assertIn (b'all entries deleted' , out )
285291
286-
287292 def tearDown (self ):
288293 os .unlink ('/tmp/ssh_config_cli_tests' )
289294
@@ -344,6 +349,35 @@ def test_clone_host(self):
344349 self .assertEqual (item .get ("options" ).get ("identityfile" ), '/tmp/tmp.pub' )
345350 self .assertEqual (item .get ("options" ).get ("user" ), 'ops' )
346351
352+ def test_move_host (self ):
353+ self .storm .add_entry ('google' , 'google.com' , 'ops' , '24' , '/tmp/tmp.pub' )
354+ self .storm .clone_entry ('google' , 'yahoo' , keep_original = False )
355+
356+ has_yahoo = False
357+ for item in self .storm .ssh_config .config_data :
358+ if item .get ("host" ) == 'yahoo' :
359+ has_yahoo = True
360+ break
361+
362+ has_google = False
363+ for item in self .storm .ssh_config .config_data :
364+ if item .get ("host" ) == 'google' :
365+ has_google = True
366+ break
367+
368+ self .assertEqual (True , has_yahoo )
369+ self .assertEqual (False , has_google )
370+ self .assertEqual (item .get ("options" ).get ("port" ), '24' )
371+ self .assertEqual (item .get ("options" ).get ("identityfile" ), '/tmp/tmp.pub' )
372+ self .assertEqual (item .get ("options" ).get ("user" ), 'ops' )
373+
374+ def test_backup (self ):
375+ self .storm .backup ("/tmp/storm_ssh_config_backup_file" )
376+ self .assertEqual (
377+ True ,
378+ os .path .exists ("/tmp/storm_ssh_config_backup_file" )
379+ )
380+
347381 def test_double_clone_exception (self ):
348382 self .storm .add_entry ('google' , 'google.com' , 'ops' , '24' , '/tmp/tmp.pub' )
349383 self .storm .clone_entry ('google' , 'yahoo' )
0 commit comments