예제 #1
0
 def test_import_keys_raises_HandlerError(self):
     user = factory.make_User()
     handler = SSHKeyHandler(user, {}, None)
     protocol = factory.make_name("protocol")
     auth_id = factory.make_name("auth")
     mock_save_keys = self.patch(KeySource.objects, "save_keys_for_user")
     mock_save_keys.side_effect = ImportSSHKeysError()
     self.assertRaises(HandlerError, handler.import_keys, {
         "protocol": protocol,
         "auth_id": auth_id,
     })
예제 #2
0
 def test_import_ssh_keys_crashes_for_ImportSSHKeysERROR(self):
     protocol = random.choice(
         [KEYS_PROTOCOL_TYPE.LP, KEYS_PROTOCOL_TYPE.GH])
     auth_id = factory.make_name('auth_id')
     ks = "%s:%s" % (protocol, auth_id)
     mock_get_protocol_keys = self.patch(keysource_module,
                                         'get_protocol_keys')
     mock_get_protocol_keys.side_effect = ImportSSHKeysError('error')
     response = self.client.post(reverse('sshkeys_handler'),
                                 data=dict(op='import', keysource=ks))
     self.assertEqual(http.client.BAD_REQUEST, response.status_code,
                      response.content)