def test_post_with_bad_host_key(self):
        hostname = 'example.com'
        key = key1
        expected_key = key2

        @classmethod
        def _check_repository(cls, *args, **kwargs):
            raise BadHostKeyError(hostname, key, expected_key)

        TestTool.check_repository = _check_repository

        self._login_user(admin=True)
        rsp = self._post_repository(False, expected_status=403)
        self.assertEqual(rsp['stat'], 'fail')
        self.assertEqual(rsp['err']['code'], BAD_HOST_KEY.code)
        self.assertIn('hostname', rsp)
        self.assertIn('expected_key', rsp)
        self.assertIn('key', rsp)
        self.assertEqual(rsp['hostname'], hostname)
        self.assertEqual(rsp['expected_key'], expected_key.get_base64())
        self.assertEqual(rsp['key'], key.get_base64())
Creates an approval with raw access.
dataset/ETHPy150Open reviewboard/reviewboard/reviewboard/webapi/tests/test_repository.py/ResourceListTests.test_post_with_bad_host_key--crossover with--dataset/ETHPy150Open google/grr/grr/lib/console_utils.py/ApprovalCreateRaw