def test_943478(url): #https://bugzilla.mozilla.org/show_bug.cgi?id=943478 response = request("POST", url + "/" + NOT_WHITELISTED + "/_search", data=""" { "query":{"filtered":{ "query":{"match_all":{}} }}, "from":0, "size":0, "sort":[], "facets":{"default":{"terms":{"field":"info.OS","size":200000}}} }""") if response.status_code != 400: Log.error("should not allow") # VERIFY ALLOWED INDEX GETS THROUGH response = request("POST", url + "/" + WHITELISTED + "/_search", data=""" { "query":{"filtered":{ "query":{"match_all":{}}, "filter":{"range":{"bug_id":{"lt":700000}}} }}, "from":0, "size":0, "sort":[], "facets":{"default":{"terms":{"field":"product","size":200000}}} }""") if response.status_code != 200: Log.error("query should work")
def test_allow_3path_mapping(url): #WE SHOULD ALLOW -mapping WITH INDEX AND TYPE IN PATH #http://klahnakoski-es.corp.tor1.mozilla.com:9204/bugs/bug_version/_mapping response = request("GET", url + "/" + WHITELISTED + "/bug_version/_mapping") if response.status_code != 200: Log.error("should be allowed")
def test_943465(url): #https://bugzilla.mozilla.org/show_bug.cgi?id=943465 response = request("GET", url + "/_cluster/nodes/_local") if response.status_code != 400: Log.error("should not allow") response = request("GET", url + "/_cluster/nodes/stats") if response.status_code != 400: Log.error("should not allow")
def test_slow_streaming(): """ TEST THAT THE app ACTUALLY STREAMS. WE SHOULD GET A RESPONSE BEFORE THE SERVER FINISHES DELIVERING """ slow_server_thread = Thread.run("run slow server", run_slow_server) proxy_thread = Thread.run("run proxy", run_proxy) try: proxy_is_ready.wait_for_go() server_is_ready.wait_for_go() start = time.clock() response = requests.get("http://localhost:" + str(PROXY_PORT) + PATH, stream=True) for i, data in enumerate(stream(response.raw)): Log.note("CLIENT GOT RESPONSE:\n{{data|indent}}", {"data": data}) end = time.clock() if i == 0 and end - start > 10: # IF WE GET DATA BEFORE 10sec, THEN WE KNOW WE ARE STREAMING Log.error("should have something by now") if response.status_code != 200: Log.error("Expecting a positive response") except Exception, e: Log.error("Not expected", e)
def test_allow_head_request(url): #WE SHOULD ALLOW HEAD REQUESTS TO / response = request("HEAD", url + "/") if response.status_code != 200: Log.error("should be allowed") response = request("HEAD", url) if response.status_code != 200: Log.error("should be allowed") # ENVEN HEAD REQUESTS TO WHITELISTED INDEXES WILL BE DENIED response = request("HEAD", url + "/" + WHITELISTED + "/bug_version/_mapping") if response.status_code == 200: Log.error("should NOT be allowed")
def test_943472(url): #https://bugzilla.mozilla.org/show_bug.cgi?id=943472 response = request("GET", url + "/" + WHITELISTED + "/_stats/") if response.status_code != 400: Log.error("should not allow")