From c848647acf7aa967da4f2b9ec89843f208fb4e24 Mon Sep 17 00:00:00 2001 From: Bryan Newbold Date: Wed, 26 Aug 2020 17:51:42 -0700 Subject: more tests --- tests/files/other/GET_bare.txt | 1 + tests/files/other/GET_doc.txt | 1 + tests/files/other/GET_index_bare.txt | 1 + tests/files/other/GET_mapping.txt | 1 + tests/files/other/GET_source.txt | 1 + tests/files/other/HEAD_index_bare.txt | 1 + tests/files/other/OPTIONS_index_bare.txt | 1 + tests/files/other_fail/DELETE_index.txt | 1 + tests/files/search_fail/GET_bad_json.txt | 7 +++++++ tests/files/search_fail/PUT_search.txt | 8 ++++++++ tests/parse_es_requests.rs | 31 +++++++++++++++++++++++++++++++ 11 files changed, 54 insertions(+) create mode 100644 tests/files/other/GET_bare.txt create mode 100644 tests/files/other/GET_doc.txt create mode 100644 tests/files/other/GET_index_bare.txt create mode 100644 tests/files/other/GET_mapping.txt create mode 100644 tests/files/other/GET_source.txt create mode 100644 tests/files/other/HEAD_index_bare.txt create mode 100644 tests/files/other/OPTIONS_index_bare.txt create mode 100644 tests/files/other_fail/DELETE_index.txt create mode 100644 tests/files/search_fail/GET_bad_json.txt create mode 100644 tests/files/search_fail/PUT_search.txt diff --git a/tests/files/other/GET_bare.txt b/tests/files/other/GET_bare.txt new file mode 100644 index 0000000..c6ee450 --- /dev/null +++ b/tests/files/other/GET_bare.txt @@ -0,0 +1 @@ +GET / diff --git a/tests/files/other/GET_doc.txt b/tests/files/other/GET_doc.txt new file mode 100644 index 0000000..504d5a6 --- /dev/null +++ b/tests/files/other/GET_doc.txt @@ -0,0 +1 @@ +GET /some-index/_doc/some-key-1234 diff --git a/tests/files/other/GET_index_bare.txt b/tests/files/other/GET_index_bare.txt new file mode 100644 index 0000000..aa0bd68 --- /dev/null +++ b/tests/files/other/GET_index_bare.txt @@ -0,0 +1 @@ +GET /some-index/ diff --git a/tests/files/other/GET_mapping.txt b/tests/files/other/GET_mapping.txt new file mode 100644 index 0000000..bda02c2 --- /dev/null +++ b/tests/files/other/GET_mapping.txt @@ -0,0 +1 @@ +GET /some-index/_mapping diff --git a/tests/files/other/GET_source.txt b/tests/files/other/GET_source.txt new file mode 100644 index 0000000..f30b6c1 --- /dev/null +++ b/tests/files/other/GET_source.txt @@ -0,0 +1 @@ +GET /some-index/_source/some-key-1234 diff --git a/tests/files/other/HEAD_index_bare.txt b/tests/files/other/HEAD_index_bare.txt new file mode 100644 index 0000000..6d31c38 --- /dev/null +++ b/tests/files/other/HEAD_index_bare.txt @@ -0,0 +1 @@ +HEAD /some-index/ diff --git a/tests/files/other/OPTIONS_index_bare.txt b/tests/files/other/OPTIONS_index_bare.txt new file mode 100644 index 0000000..4d33a69 --- /dev/null +++ b/tests/files/other/OPTIONS_index_bare.txt @@ -0,0 +1 @@ +OPTIONS /some-index/ diff --git a/tests/files/other_fail/DELETE_index.txt b/tests/files/other_fail/DELETE_index.txt new file mode 100644 index 0000000..d2ff2cd --- /dev/null +++ b/tests/files/other_fail/DELETE_index.txt @@ -0,0 +1 @@ +DELETE /some-index/ diff --git a/tests/files/search_fail/GET_bad_json.txt b/tests/files/search_fail/GET_bad_json.txt new file mode 100644 index 0000000..4961988 --- /dev/null +++ b/tests/files/search_fail/GET_bad_json.txt @@ -0,0 +1,7 @@ +GET /some-index/_search +{ + "query": { + "exists": { + "field": "user" + } + } diff --git a/tests/files/search_fail/PUT_search.txt b/tests/files/search_fail/PUT_search.txt new file mode 100644 index 0000000..f512a95 --- /dev/null +++ b/tests/files/search_fail/PUT_search.txt @@ -0,0 +1,8 @@ +PUT /some-index/_search +{ + "query": { + "exists": { + "field": "user" + } + } +} diff --git a/tests/parse_es_requests.rs b/tests/parse_es_requests.rs index e6f747f..e00b12f 100644 --- a/tests/parse_es_requests.rs +++ b/tests/parse_es_requests.rs @@ -86,6 +86,24 @@ fn filter_scroll_requests() { } } +#[test] +fn filter_other_requests() { + let file_paths = fs::read_dir("tests/files/other").unwrap(); + let mut config = ProxyConfig::default(); + config.unsafe_all_indices = Some(true); + let mut rt = tokio::runtime::Runtime::new().unwrap(); + + for path in file_paths { + let path = path.unwrap().path(); + if path.extension() != Some(OsStr::new("txt")) { + continue; + } + println!(" filtering: {}", path.display()); + let req = common::load_request(&path); + rt.block_on(filter_request(req, &config)).unwrap(); + } +} + #[test] fn filter_failures() { let file_paths = fs::read_dir("tests/files/search_fail").unwrap(); @@ -116,4 +134,17 @@ fn filter_failures() { let result = rt.block_on(filter_request(req, &config)); assert!(result.is_err()); } + + let file_paths = fs::read_dir("tests/files/other_fail").unwrap(); + + for path in file_paths { + let path = path.unwrap().path(); + if path.extension() != Some(OsStr::new("txt")) { + continue; + } + println!(" filtering: {}", path.display()); + let req = common::load_request(&path); + let result = rt.block_on(filter_request(req, &config)); + assert!(result.is_err()); + } } -- cgit v1.2.3