Exemplo n.º 1
0
 def test_set_ssh_key(self):
     with self.assertRaises(SystemExit):
         ssh_key.set_ssh_key(SMALL_KEY,
             authorized_keys = self.authorized_keys)
     self.assertEqual(SMALL_KEY, open(self.authorized_keys).read())
     self.assertFalse(ssh_key.key_locked(self.authorized_keys))
     self.assertSuccess('{"comment": "my@address"}')
Exemplo n.º 2
0
 def test_set_ssh_key_invalid(self):
     with self.assertRaises(SystemExit):
         ssh_key.set_ssh_key(INVALID_KEY,
             authorized_keys = self.authorized_keys)
     self.assertFalse(os.path.exists(self.authorized_keys))
     self.assertError('SSH key did not match expected format '
         '\\"ssh-rsa <BASE64_KEY> COMMENT\\".')
Exemplo n.º 3
0
 def test_set_ssh_key_multiline(self):
     with self.assertRaises(SystemExit):
         ssh_key.set_ssh_key('multiline\nssh\nkey',
             authorized_keys = self.authorized_keys)
     self.assertFalse(os.path.exists(self.authorized_keys))
     self.assertError('Multiline key not allowed.')
Exemplo n.º 4
0
 def test_set_ssh_key_private(self):
     with self.assertRaises(SystemExit):
         ssh_key.set_ssh_key('-----BEGIN RSA PRIVATE KEY-----',
             authorized_keys = self.authorized_keys)
     self.assertFalse(os.path.exists(self.authorized_keys))
     self.assertError('That looks like a private key. Try ~/.ssh/id_rsa.pub')
Exemplo n.º 5
0
 def test_set_ssh_key_already_locked(self):
     with self.assertRaises(SystemExit):
         ssh_key.set_ssh_key(SMALL_KEY,
             authorized_keys = self.authorized_keys)
     self.assertFalse(os.path.exists(self.authorized_keys))
     self.assertError('SSH key already stored and used. Cannot modify.')