~louis/+junk/nova-cloud-controller-lp1313602

« back to all changes in this revision

Viewing changes to unit_tests/test_nova_cc_utils.py

  • Committer: Louis Bouchard
  • Date: 2014-09-03 13:33:13 UTC
  • Revision ID: louis.bouchard@canonical.com-20140903133313-cvylj7hrqphpuw1r
Second part of multiline SSH key and authorized host passing to nova-compute

Show diffs side-by-side

added added

removed removed

Lines of Context:
324
324
        check_output.return_value = 'fookey'
325
325
        host_key.return_value = 'fookey_old'
326
326
        with patch_open() as (_open, _file):
327
 
            utils.add_known_host('foohost')
328
 
            rm.assert_called_with('foohost', None)
 
327
            utils.add_known_host('foohost', None, None)
 
328
            rm.assert_called_with('foohost', None, None)
329
329
 
330
330
    @patch.object(utils, 'known_hosts')
331
331
    @patch.object(utils, 'remove_known_host')
358
358
    def test_known_hosts(self, ssh_dir):
359
359
        ssh_dir.return_value = '/tmp/foo'
360
360
        self.assertEquals(utils.known_hosts(), '/tmp/foo/known_hosts')
361
 
        ssh_dir.assert_called_with(None)
 
361
        ssh_dir.assert_called_with(None, None)
362
362
        self.assertEquals(utils.known_hosts('bar'), '/tmp/foo/known_hosts')
363
 
        ssh_dir.assert_called_with('bar')
 
363
        ssh_dir.assert_called_with('bar', None)
364
364
 
365
365
    @patch.object(utils, 'ssh_directory_for_unit')
366
366
    def test_authorized_keys(self, ssh_dir):
367
367
        ssh_dir.return_value = '/tmp/foo'
368
368
        self.assertEquals(utils.authorized_keys(), '/tmp/foo/authorized_keys')
369
 
        ssh_dir.assert_called_with(None)
 
369
        ssh_dir.assert_called_with(None, None)
370
370
        self.assertEquals(
371
371
            utils.authorized_keys('bar'),
372
372
            '/tmp/foo/authorized_keys')
373
 
        ssh_dir.assert_called_with('bar')
 
373
        ssh_dir.assert_called_with('bar', None)
374
374
 
375
375
    @patch.object(utils, 'known_hosts')
376
376
    @patch('subprocess.check_call')
464
464
        _check_output.assert_called_with(
465
465
            ['ssh-keygen', '-f', '/foo/known_hosts',
466
466
             '-H', '-F', 'test'])
467
 
        _known_hosts.assert_called_with(None)
 
467
        _known_hosts.assert_called_with(None, None)
468
468
        utils.ssh_known_host_key('test', 'bar')
469
 
        _known_hosts.assert_called_with('bar')
 
469
        _known_hosts.assert_called_with('bar', None)
470
470
 
471
471
    @patch.object(utils, 'known_hosts')
472
472
    @patch('subprocess.check_call')
476
476
        _check_call.assert_called_with(
477
477
            ['ssh-keygen', '-f', '/foo/known_hosts',
478
478
             '-R', 'test'])
479
 
        _known_hosts.assert_called_with(None)
 
479
        _known_hosts.assert_called_with(None, None)
480
480
        utils.remove_known_host('test', 'bar')
481
 
        _known_hosts.assert_called_with('bar')
 
481
        _known_hosts.assert_called_with('bar', None)
482
482
 
483
483
    @patch('subprocess.check_output')
484
484
    def test_migrate_database(self, check_output):