def test_default_windows(self):
     ns = TestVMDefaultAuthType._set_ns()
     ns.os_type = "WindowS"
     ns.authentication_type = None
     ns.admin_username = '******'
     ns.admin_password = '******'
     _validate_vm_vmss_create_auth(ns)
     self.assertEqual(ns.authentication_type, 'password')
 def test_default_linux(self):
     ns = TestVMDefaultAuthType._set_ns()
     ns.os_type = "LINux"
     ns.authentication_type = None
     test_user = '******'
     ns.admin_username = test_user
     ns.admin_password = None
     ns.ssh_key_value = 'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQCbIg1guRHbI0lV11wWDt1r2cUdcNd27CJsg+SfgC7miZeubtwUhbsPdhMQsfDyhOWHq1+ZL0M+nJZV63d/1dhmhtgyOqejUwrPlzKhydsbrsdUor+JmNJDdW01v7BXHyuymT8G4s09jCasNOwiufbP/qp72ruu0bIA1nySsvlf9pCQAuFkAnVnf/rFhUlOkhtRpwcq8SUNY2zRHR/EKb/4NWY1JzR4sa3q2fWIJdrrX0DvLoa5g9bIEd4Df79ba7v+yiUBOS0zT2ll+z4g9izHK3EO5d8hL4jYxcjKs+wcslSYRWrascfscLgMlMGh0CdKeNTDjHpGPncaf3Z+FwwwjWeuiNBxv7bJo13/8B/098KlVDl4GZqsoBCEjPyJfV6hO0y/LkRGkk7oHWKgeWAfKtfLItRp00eZ4fcJNK9kCaSMmEugoZWcI7NGbZXzqFWqbpRI7NcDP9+WIQ+i9U5vqWsqd/zng4kbuAJ6UuKqIzB0upYrLShfQE3SAck8oaLhJqqq56VfDuASNpJKidV+zq27HfSBmbXnkR/5AK337dc3MXKJypoK/QPMLKUAP5XLPbs+NddJQV7EZXd29DLgp+fRIg3edpKdO7ZErWhv7d+3Kws+e1Y+ypmR2WIVSwVyBEUfgv2C8Ts9gnTF4pNcEY/S2aBicz5Ew2+jdyGNQQ== [email protected]\n'
     _validate_vm_vmss_create_auth(ns)
     self.assertEqual(ns.authentication_type, 'ssh')
     self.assertEqual(ns.ssh_dest_key_path, '/home/{}/.ssh/authorized_keys'.format(test_user))
Beispiel #3
0
 def test_default_linux(self):
     ns = TestVMDefaultAuthType._set_ns()
     ns.os_type = "LINux"
     ns.authentication_type = None
     test_user = '******'
     ns.admin_username = test_user
     ns.admin_password = None
     ns.ssh_key_value = [self._get_test_ssh_key()]
     _validate_vm_vmss_create_auth(ns)
     self.assertEqual(ns.authentication_type, 'ssh')
     self.assertEqual(ns.ssh_dest_key_path,
                      '/home/{}/.ssh/authorized_keys'.format(test_user))
Beispiel #4
0
 def test_default_linux(self):
     ns = TestVMDefaultAuthType._set_ns()
     ns.os_type = "LINux"
     ns.authentication_type = None
     test_user = '******'
     ns.admin_username = test_user
     ns.admin_password = None
     ns.ssh_key_value = 'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQCbIg1guRHbI0lV11wWDt1r2cUdcNd27CJsg+SfgC7miZeubtwUhbsPdhMQsfDyhOWHq1+ZL0M+nJZV63d/1dhmhtgyOqejUwrPlzKhydsbrsdUor+JmNJDdW01v7BXHyuymT8G4s09jCasNOwiufbP/qp72ruu0bIA1nySsvlf9pCQAuFkAnVnf/rFhUlOkhtRpwcq8SUNY2zRHR/EKb/4NWY1JzR4sa3q2fWIJdrrX0DvLoa5g9bIEd4Df79ba7v+yiUBOS0zT2ll+z4g9izHK3EO5d8hL4jYxcjKs+wcslSYRWrascfscLgMlMGh0CdKeNTDjHpGPncaf3Z+FwwwjWeuiNBxv7bJo13/8B/098KlVDl4GZqsoBCEjPyJfV6hO0y/LkRGkk7oHWKgeWAfKtfLItRp00eZ4fcJNK9kCaSMmEugoZWcI7NGbZXzqFWqbpRI7NcDP9+WIQ+i9U5vqWsqd/zng4kbuAJ6UuKqIzB0upYrLShfQE3SAck8oaLhJqqq56VfDuASNpJKidV+zq27HfSBmbXnkR/5AK337dc3MXKJypoK/QPMLKUAP5XLPbs+NddJQV7EZXd29DLgp+fRIg3edpKdO7ZErWhv7d+3Kws+e1Y+ypmR2WIVSwVyBEUfgv2C8Ts9gnTF4pNcEY/S2aBicz5Ew2+jdyGNQQ== [email protected]\n'
     _validate_vm_vmss_create_auth(ns)
     self.assertEqual(ns.authentication_type, 'ssh')
     self.assertEqual(ns.ssh_dest_key_path,
                      '/home/{}/.ssh/authorized_keys'.format(test_user))
Beispiel #5
0
    def test_linux_with_password(self):
        ns = TestVMDefaultAuthType._set_ns()
        ns.os_type = "LINux"
        ns.authentication_type = 'password'
        ns.admin_username = '******'
        ns.admin_password = '******'
        _validate_vm_vmss_create_auth(ns)
        # still has 'password'
        self.assertEqual(ns.authentication_type, 'password')

        # throw when conflict with ssh key value
        ns.ssh_key_value = ['junk but does not matter']
        with self.assertRaises(CLIError) as context:
            _validate_vm_vmss_create_auth(ns)
            self.assertTrue("SSH key cannot be used with password authentication type." in str(context.exception))
    def test_linux_with_password(self):
        ns = TestVMDefaultAuthType._set_ns()
        ns.os_type = "LINux"
        ns.authentication_type = 'password'
        ns.admin_username = '******'
        ns.admin_password = '******'
        _validate_vm_vmss_create_auth(ns)
        # still has 'password'
        self.assertEqual(ns.authentication_type, 'password')

        # throw when conflict with ssh key value
        ns.ssh_key_value = 'junk but does not matter'
        with self.assertRaises(ValueError) as context:
            _validate_vm_vmss_create_auth(ns)
        self.assertTrue("incorrect usage for authentication-type 'password':" in str(context.exception))
Beispiel #7
0
    def test_windows_password_and_ssh_fails(self):
        ns = TestVMDefaultAuthType._set_ns()
        ns.os_type = "WindowS"
        ns.authentication_type = None
        ns.admin_username = '******'
        ns.admin_password = '******'
        ns.ssh_key_value = [self._get_test_ssh_key()]

        # test fails if authentication_type implicit
        with self.assertRaises(CLIError) as context:
            _validate_vm_vmss_create_auth(ns)
            self.assertTrue("SSH not supported for Windows VMs. Use password authentication." in str(context.exception))

        # test fails if authentication type explicit
        ns.authentication_type = 'all'
        with self.assertRaises(CLIError) as context:
            _validate_vm_vmss_create_auth(ns)
            self.assertTrue("SSH not supported for Windows VMs. Use password authentication." in str(context.exception))
Beispiel #8
0
 def test_linux_with_password_and_ssh_implicit(self):
     ns = TestVMDefaultAuthType._new_linux_ns(authentication_type="all")
     ns.authentication_type = None
     _validate_vm_vmss_create_auth(ns)
     self.assertEqual(ns.authentication_type, 'all')
     self.assertEqual(ns.ssh_dest_key_path, '/home/{}/.ssh/authorized_keys'.format(ns.admin_username))