def test_client_request_without_parameters(jedihttp): response = requests.post('http://127.0.0.1:{0}/ready'.format(PORT), auth=HmacAuth(SECRET)) assert_that(response.status_code, equal_to(httplib.OK)) hmachelper = hmaclib.JediHTTPHmacHelper(SECRET) assert_that(hmachelper.is_response_authenticated(response.headers, response.content))
def ErrorHandler(httperror): body = _JsonResponse({ 'exception': httperror.exception, 'message': str(httperror.exception), 'traceback': httperror.traceback }) if 'jedihttp.hmac_secret' in app.config: hmac_secret = app.config['jedihttp.hmac_secret'] hmachelper = hmaclib.JediHTTPHmacHelper(hmac_secret) hmachelper.SignResponseHeaders(response.headers, body) return body
def test_client_request_without_parameters(jedihttp): good_start, reason = wait_for_jedihttp_to_start(jedihttp) assert_that(good_start, reason) response = requests.post('http://127.0.0.1:{0}/ready'.format(PORT), auth=HMACAuth(SECRET)) assert_that(response.status_code, equal_to(httplib.OK)) hmachelper = hmaclib.JediHTTPHmacHelper(SECRET) assert_that( hmachelper.IsResponseAuthenticated(response.headers, response.content))
def test_client_shutdown(jedihttp): response = requests.post('http://127.0.0.1:{0}/shutdown'.format(PORT), auth=HmacAuth(SECRET)) assert_that(response.status_code, equal_to(httplib.OK)) assert_that(response.json(), equal_to(True)) hmachelper = hmaclib.JediHTTPHmacHelper(SECRET) assert_that(hmachelper.is_response_authenticated(response.headers, response.content)) wait_process_shutdown(jedihttp) assert_that(process_is_running(jedihttp), equal_to(False))
def test_client_python3_specific_syntax_completion(jedihttp): filepath = utils.fixture_filepath('py3.py') request_data = { 'source': read_file(filepath), 'line': 19, 'col': 11, 'source_path': filepath } response = requests.post('http://127.0.0.1:{0}/completions'.format(PORT), json=request_data, auth=HmacAuth(SECRET)) assert_that(response.status_code, equal_to(httplib.OK)) hmachelper = hmaclib.JediHTTPHmacHelper(SECRET) assert_that(hmachelper.is_response_authenticated(response.headers, response.content))
def test_client_bad_request_with_parameters(jedihttp): filepath = utils.fixture_filepath('goto.py') request_data = { 'source': read_file(filepath), 'line': 100, 'col': 1, 'source_path': filepath } response = requests.post( 'http://127.0.0.1:{0}/gotodefinition'.format(PORT), json=request_data, auth=HmacAuth(SECRET)) assert_that(response.status_code, equal_to(httplib.INTERNAL_SERVER_ERROR)) hmachelper = hmaclib.JediHTTPHmacHelper(SECRET) assert_that(hmachelper.is_response_authenticated(response.headers, response.content))
def test_client_request_with_parameters( jedihttp ): good_start, reason = wait_for_jedihttp_to_start( jedihttp ) assert_that( good_start, reason ) filepath = utils.fixture_filepath( 'goto.py' ) request_data = { 'source': read_file( filepath ), 'line': 10, 'col': 3, 'source_path': filepath } response = requests.post( 'http://127.0.0.1:{0}/gotodefinition'.format( PORT ), json = request_data, auth = HmacAuth( SECRET ) ) assert_that( response.status_code, equal_to( httplib.OK ) ) hmachelper = hmaclib.JediHTTPHmacHelper( SECRET ) assert_that( hmachelper.IsResponseAuthenticated( response.headers, response.content ) )
def setup(self, app): hmac_secret = app.config['jedihttp.hmac_secret'] self._hmachelper = hmaclib.JediHTTPHmacHelper(hmac_secret)
def __init__(self, secret): self._hmac_helper = hmaclib.JediHTTPHmacHelper(secret)