def test_http_auth_disable_with_none(): client = EnterpriseSearch(bearer_auth="api-token", node_class=DummyNode) client.perform_request("GET", "/") calls = client.transport.node_pool.get().calls assert len(calls) == 1 assert calls[-1][1]["headers"]["Authorization"] == "Bearer api-token" client.options(bearer_auth=None).get_version() assert len(calls) == 2 assert "Authorization" not in calls[-1][1]["headers"] client.options(basic_auth=None).get_version() assert len(calls) == 3 assert "Authorization" not in calls[-1][1]["headers"]
def test_httpbin(): client = EnterpriseSearch("https://httpbin.org:443") resp = client.perform_request("GET", "/anything") assert resp.meta.status == 200 assert re.match( r"^ent=8[.0-9]+p?,py=[.0-9]+p?,t=[.0-9]+p?,ur=[.0-9]+p?$", resp.body["headers"]["X-Elastic-Client-Meta"], ) assert resp.body["headers"]["User-Agent"].startswith( "enterprise-search-python/")