diff options
author | Bryan Newbold <bnewbold@archive.org> | 2020-08-25 18:33:39 -0700 |
---|---|---|
committer | Bryan Newbold <bnewbold@archive.org> | 2020-08-25 18:33:39 -0700 |
commit | 45e4cd9537f289a98579eef36a2dc3e561cc48fa (patch) | |
tree | e14c9a9f889c09b0fffb2f440341c185c963d66f /tests | |
parent | 55f9b88ba1d63db75ef9cde3cf94e5c98526ad2f (diff) | |
download | es-public-proxy-45e4cd9537f289a98579eef36a2dc3e561cc48fa.tar.gz es-public-proxy-45e4cd9537f289a98579eef36a2dc3e561cc48fa.zip |
move tests around
Diffstat (limited to 'tests')
-rw-r--r-- | tests/common/mod.rs | 6 | ||||
-rw-r--r-- | tests/files/scroll_fail/DELETE_scroll_all.txt | 4 | ||||
-rw-r--r-- | tests/files/search/GET_collapse_expand.txt (renamed from tests/files/GET_collapse_expand.txt) | 0 | ||||
-rw-r--r-- | tests/files/search/GET_collapse_nested.txt (renamed from tests/files/GET_collapse_nested.txt) | 0 | ||||
-rw-r--r-- | tests/files/search/GET_highlight.txt (renamed from tests/files/GET_highlight.txt) | 0 | ||||
-rw-r--r-- | tests/files/search/GET_highlight_complex.txt (renamed from tests/files/GET_highlight_complex.txt) | 0 | ||||
-rw-r--r-- | tests/files/search/GET_highlight_fields.txt (renamed from tests/files/GET_highlight_fields.txt) | 0 | ||||
-rw-r--r-- | tests/files/search/GET_highlight_query.txt (renamed from tests/files/GET_highlight_query.txt) | 0 | ||||
-rw-r--r-- | tests/files/search/GET_range.txt (renamed from tests/files/GET_range.txt) | 0 | ||||
-rw-r--r-- | tests/files/search/GET_search.txt (renamed from tests/files/GET_search.txt) | 0 | ||||
-rw-r--r-- | tests/files/search/GET_search_agg_filter.txt (renamed from tests/files/GET_search_agg_filter.txt) | 0 | ||||
-rw-r--r-- | tests/files/search/GET_search_agg_filter_simple.txt (renamed from tests/files/GET_search_agg_filter_simple.txt) | 0 | ||||
-rw-r--r-- | tests/files/search/GET_search_agg_histogram.txt (renamed from tests/files/GET_search_agg_histogram.txt) | 0 | ||||
-rw-r--r-- | tests/files/search/GET_search_agg_max.txt (renamed from tests/files/GET_search_agg_max.txt) | 0 | ||||
-rw-r--r-- | tests/files/search/GET_search_agg_nested.txt (renamed from tests/files/GET_search_agg_nested.txt) | 0 | ||||
-rw-r--r-- | tests/files/search/GET_search_bool.txt (renamed from tests/files/GET_search_bool.txt) | 0 | ||||
-rw-r--r-- | tests/files/search/GET_search_boosting.txt (renamed from tests/files/GET_search_boosting.txt) | 0 | ||||
-rw-r--r-- | tests/files/search/GET_search_docvalues.txt (renamed from tests/files/GET_search_docvalues.txt) | 0 | ||||
-rw-r--r-- | tests/files/search/GET_search_exists.txt (renamed from tests/files/GET_search_exists.txt) | 0 | ||||
-rw-r--r-- | tests/files/search/GET_search_fatcat_preservation_year.txt (renamed from tests/files/GET_search_fatcat_preservation_year.txt) | 0 | ||||
-rw-r--r-- | tests/files/search/GET_search_fatcat_scholar_basic.txt (renamed from tests/files/GET_search_fatcat_scholar_basic.txt) | 0 | ||||
-rw-r--r-- | tests/files/search/GET_search_ids.txt (renamed from tests/files/GET_search_ids.txt) | 0 | ||||
-rw-r--r-- | tests/files/search/GET_search_match_all.txt (renamed from tests/files/GET_search_match_all.txt) | 0 | ||||
-rw-r--r-- | tests/files/search/GET_search_match_none.txt (renamed from tests/files/GET_search_match_none.txt) | 0 | ||||
-rw-r--r-- | tests/files/search/GET_search_multi_match.txt (renamed from tests/files/GET_search_multi_match.txt) | 0 | ||||
-rw-r--r-- | tests/files/search/GET_search_multi_match_tie.txt (renamed from tests/files/GET_search_multi_match_tie.txt) | 0 | ||||
-rw-r--r-- | tests/files/search/GET_search_prefix.txt (renamed from tests/files/GET_search_prefix.txt) | 0 | ||||
-rw-r--r-- | tests/files/search/GET_search_querystring.txt (renamed from tests/files/GET_search_querystring.txt) | 0 | ||||
-rw-r--r-- | tests/files/search/GET_search_simplequerystring.txt (renamed from tests/files/GET_search_simplequerystring.txt) | 0 | ||||
-rw-r--r-- | tests/files/search/GET_search_sort.txt (renamed from tests/files/GET_search_sort.txt) | 0 | ||||
-rw-r--r-- | tests/files/search/GET_search_term.txt (renamed from tests/files/GET_search_term.txt) | 0 | ||||
-rw-r--r-- | tests/files/search/GET_search_term_short.txt (renamed from tests/files/GET_search_term_short.txt) | 0 | ||||
-rw-r--r-- | tests/files/search/GET_search_wildcard.txt (renamed from tests/files/GET_search_wildcard.txt) | 0 | ||||
-rw-r--r-- | tests/files/search/GET_uri_search.txt (renamed from tests/files/GET_uri_search.txt) | 0 | ||||
-rw-r--r-- | tests/files/search/POST_search_rescore.txt (renamed from tests/files/POST_search_rescore.txt) | 0 | ||||
-rw-r--r-- | tests/files/search/POST_search_sort_mode.txt (renamed from tests/files/POST_search_sort_mode.txt) | 0 | ||||
-rw-r--r-- | tests/files/search/POST_search_start_scroll.txt (renamed from tests/files/POST_search_start_scroll.txt) | 0 | ||||
-rw-r--r-- | tests/files/search_fail/POST_search_inner.txt (renamed from tests/files/POST_search_inner.txt.disabled) | 0 | ||||
-rw-r--r-- | tests/parse_es_requests.rs | 48 |
39 files changed, 40 insertions, 18 deletions
diff --git a/tests/common/mod.rs b/tests/common/mod.rs index 890dead..811b4b9 100644 --- a/tests/common/mod.rs +++ b/tests/common/mod.rs @@ -9,12 +9,6 @@ pub struct ExampleParts { pub body: Option<String>, } -pub fn load_parts_by_name(name: &str) -> ExampleParts { - let path = format!("tests/files/{}.txt", name); - let path = Path::new(&path); - load_parts(&path) -} - pub fn load_parts(path: &Path) -> ExampleParts { let file = std::fs::File::open(path).unwrap(); diff --git a/tests/files/scroll_fail/DELETE_scroll_all.txt b/tests/files/scroll_fail/DELETE_scroll_all.txt new file mode 100644 index 0000000..5501c17 --- /dev/null +++ b/tests/files/scroll_fail/DELETE_scroll_all.txt @@ -0,0 +1,4 @@ +DELETE /_search/scroll +{ + "scroll_id" : "_all" +} diff --git a/tests/files/GET_collapse_expand.txt b/tests/files/search/GET_collapse_expand.txt index dc6b1a8..dc6b1a8 100644 --- a/tests/files/GET_collapse_expand.txt +++ b/tests/files/search/GET_collapse_expand.txt diff --git a/tests/files/GET_collapse_nested.txt b/tests/files/search/GET_collapse_nested.txt index a31c8e4..a31c8e4 100644 --- a/tests/files/GET_collapse_nested.txt +++ b/tests/files/search/GET_collapse_nested.txt diff --git a/tests/files/GET_highlight.txt b/tests/files/search/GET_highlight.txt index 8dc23ea..8dc23ea 100644 --- a/tests/files/GET_highlight.txt +++ b/tests/files/search/GET_highlight.txt diff --git a/tests/files/GET_highlight_complex.txt b/tests/files/search/GET_highlight_complex.txt index 288aa9f..288aa9f 100644 --- a/tests/files/GET_highlight_complex.txt +++ b/tests/files/search/GET_highlight_complex.txt diff --git a/tests/files/GET_highlight_fields.txt b/tests/files/search/GET_highlight_fields.txt index 85b55cb..85b55cb 100644 --- a/tests/files/GET_highlight_fields.txt +++ b/tests/files/search/GET_highlight_fields.txt diff --git a/tests/files/GET_highlight_query.txt b/tests/files/search/GET_highlight_query.txt index 7c7f0ea..7c7f0ea 100644 --- a/tests/files/GET_highlight_query.txt +++ b/tests/files/search/GET_highlight_query.txt diff --git a/tests/files/GET_range.txt b/tests/files/search/GET_range.txt index a5321c3..a5321c3 100644 --- a/tests/files/GET_range.txt +++ b/tests/files/search/GET_range.txt diff --git a/tests/files/GET_search.txt b/tests/files/search/GET_search.txt index 7ff7ca6..7ff7ca6 100644 --- a/tests/files/GET_search.txt +++ b/tests/files/search/GET_search.txt diff --git a/tests/files/GET_search_agg_filter.txt b/tests/files/search/GET_search_agg_filter.txt index 538380a..538380a 100644 --- a/tests/files/GET_search_agg_filter.txt +++ b/tests/files/search/GET_search_agg_filter.txt diff --git a/tests/files/GET_search_agg_filter_simple.txt b/tests/files/search/GET_search_agg_filter_simple.txt index 71a9777..71a9777 100644 --- a/tests/files/GET_search_agg_filter_simple.txt +++ b/tests/files/search/GET_search_agg_filter_simple.txt diff --git a/tests/files/GET_search_agg_histogram.txt b/tests/files/search/GET_search_agg_histogram.txt index 4689ad1..4689ad1 100644 --- a/tests/files/GET_search_agg_histogram.txt +++ b/tests/files/search/GET_search_agg_histogram.txt diff --git a/tests/files/GET_search_agg_max.txt b/tests/files/search/GET_search_agg_max.txt index 1377afc..1377afc 100644 --- a/tests/files/GET_search_agg_max.txt +++ b/tests/files/search/GET_search_agg_max.txt diff --git a/tests/files/GET_search_agg_nested.txt b/tests/files/search/GET_search_agg_nested.txt index 8e5d1c1..8e5d1c1 100644 --- a/tests/files/GET_search_agg_nested.txt +++ b/tests/files/search/GET_search_agg_nested.txt diff --git a/tests/files/GET_search_bool.txt b/tests/files/search/GET_search_bool.txt index 3f402f9..3f402f9 100644 --- a/tests/files/GET_search_bool.txt +++ b/tests/files/search/GET_search_bool.txt diff --git a/tests/files/GET_search_boosting.txt b/tests/files/search/GET_search_boosting.txt index 9045a54..9045a54 100644 --- a/tests/files/GET_search_boosting.txt +++ b/tests/files/search/GET_search_boosting.txt diff --git a/tests/files/GET_search_docvalues.txt b/tests/files/search/GET_search_docvalues.txt index 2fd57b1..2fd57b1 100644 --- a/tests/files/GET_search_docvalues.txt +++ b/tests/files/search/GET_search_docvalues.txt diff --git a/tests/files/GET_search_exists.txt b/tests/files/search/GET_search_exists.txt index fe7d722..fe7d722 100644 --- a/tests/files/GET_search_exists.txt +++ b/tests/files/search/GET_search_exists.txt diff --git a/tests/files/GET_search_fatcat_preservation_year.txt b/tests/files/search/GET_search_fatcat_preservation_year.txt index 539677b..539677b 100644 --- a/tests/files/GET_search_fatcat_preservation_year.txt +++ b/tests/files/search/GET_search_fatcat_preservation_year.txt diff --git a/tests/files/GET_search_fatcat_scholar_basic.txt b/tests/files/search/GET_search_fatcat_scholar_basic.txt index c60e62f..c60e62f 100644 --- a/tests/files/GET_search_fatcat_scholar_basic.txt +++ b/tests/files/search/GET_search_fatcat_scholar_basic.txt diff --git a/tests/files/GET_search_ids.txt b/tests/files/search/GET_search_ids.txt index f22c8b1..f22c8b1 100644 --- a/tests/files/GET_search_ids.txt +++ b/tests/files/search/GET_search_ids.txt diff --git a/tests/files/GET_search_match_all.txt b/tests/files/search/GET_search_match_all.txt index 1d9622c..1d9622c 100644 --- a/tests/files/GET_search_match_all.txt +++ b/tests/files/search/GET_search_match_all.txt diff --git a/tests/files/GET_search_match_none.txt b/tests/files/search/GET_search_match_none.txt index 12f50fc..12f50fc 100644 --- a/tests/files/GET_search_match_none.txt +++ b/tests/files/search/GET_search_match_none.txt diff --git a/tests/files/GET_search_multi_match.txt b/tests/files/search/GET_search_multi_match.txt index cf07050..cf07050 100644 --- a/tests/files/GET_search_multi_match.txt +++ b/tests/files/search/GET_search_multi_match.txt diff --git a/tests/files/GET_search_multi_match_tie.txt b/tests/files/search/GET_search_multi_match_tie.txt index 54f71db..54f71db 100644 --- a/tests/files/GET_search_multi_match_tie.txt +++ b/tests/files/search/GET_search_multi_match_tie.txt diff --git a/tests/files/GET_search_prefix.txt b/tests/files/search/GET_search_prefix.txt index 3e35556..3e35556 100644 --- a/tests/files/GET_search_prefix.txt +++ b/tests/files/search/GET_search_prefix.txt diff --git a/tests/files/GET_search_querystring.txt b/tests/files/search/GET_search_querystring.txt index 1c6e31e..1c6e31e 100644 --- a/tests/files/GET_search_querystring.txt +++ b/tests/files/search/GET_search_querystring.txt diff --git a/tests/files/GET_search_simplequerystring.txt b/tests/files/search/GET_search_simplequerystring.txt index 2ae5507..2ae5507 100644 --- a/tests/files/GET_search_simplequerystring.txt +++ b/tests/files/search/GET_search_simplequerystring.txt diff --git a/tests/files/GET_search_sort.txt b/tests/files/search/GET_search_sort.txt index 9a0567c..9a0567c 100644 --- a/tests/files/GET_search_sort.txt +++ b/tests/files/search/GET_search_sort.txt diff --git a/tests/files/GET_search_term.txt b/tests/files/search/GET_search_term.txt index 149587f..149587f 100644 --- a/tests/files/GET_search_term.txt +++ b/tests/files/search/GET_search_term.txt diff --git a/tests/files/GET_search_term_short.txt b/tests/files/search/GET_search_term_short.txt index 937a7b5..937a7b5 100644 --- a/tests/files/GET_search_term_short.txt +++ b/tests/files/search/GET_search_term_short.txt diff --git a/tests/files/GET_search_wildcard.txt b/tests/files/search/GET_search_wildcard.txt index 6eb199d..6eb199d 100644 --- a/tests/files/GET_search_wildcard.txt +++ b/tests/files/search/GET_search_wildcard.txt diff --git a/tests/files/GET_uri_search.txt b/tests/files/search/GET_uri_search.txt index e5e0567..e5e0567 100644 --- a/tests/files/GET_uri_search.txt +++ b/tests/files/search/GET_uri_search.txt diff --git a/tests/files/POST_search_rescore.txt b/tests/files/search/POST_search_rescore.txt index 071cf5f..071cf5f 100644 --- a/tests/files/POST_search_rescore.txt +++ b/tests/files/search/POST_search_rescore.txt diff --git a/tests/files/POST_search_sort_mode.txt b/tests/files/search/POST_search_sort_mode.txt index 54155ca..54155ca 100644 --- a/tests/files/POST_search_sort_mode.txt +++ b/tests/files/search/POST_search_sort_mode.txt diff --git a/tests/files/POST_search_start_scroll.txt b/tests/files/search/POST_search_start_scroll.txt index 8c8fd00..8c8fd00 100644 --- a/tests/files/POST_search_start_scroll.txt +++ b/tests/files/search/POST_search_start_scroll.txt diff --git a/tests/files/POST_search_inner.txt.disabled b/tests/files/search_fail/POST_search_inner.txt index 56c5acc..56c5acc 100644 --- a/tests/files/POST_search_inner.txt.disabled +++ b/tests/files/search_fail/POST_search_inner.txt diff --git a/tests/parse_es_requests.rs b/tests/parse_es_requests.rs index 8e84148..a55e461 100644 --- a/tests/parse_es_requests.rs +++ b/tests/parse_es_requests.rs @@ -8,24 +8,15 @@ mod common; #[test] fn basic_load() { - let parts = common::load_parts_by_name("GET_search"); + let parts = common::load_parts(std::path::Path::new("tests/files/search/GET_search.txt")); assert_eq!(parts.method, "GET"); assert_eq!(parts.path_and_query, "/some-index/_search"); } #[test] -fn basic_parse() { - let parts = common::load_parts_by_name("GET_search"); - assert_eq!(parts.method, "GET"); - assert_eq!(parts.path_and_query, "/some-index/_search"); - - let _parsed: SearchBody = serde_json::from_str(&parts.body.unwrap()).unwrap(); -} - -#[test] fn parse_search_bodies() { - let file_paths = fs::read_dir("tests/files").unwrap(); + let file_paths = fs::read_dir("tests/files/search").unwrap(); for path in file_paths { let path = path.unwrap().path(); @@ -65,7 +56,7 @@ fn parse_scroll_bodies() { #[test] fn filter_search_requests() { - let file_paths = fs::read_dir("tests/files").unwrap(); + let file_paths = fs::read_dir("tests/files/search").unwrap(); let mut config = ProxyConfig::default(); config.allow_all_indices = Some(true); let mut rt = tokio::runtime::Runtime::new().unwrap(); @@ -99,3 +90,36 @@ fn filter_scroll_requests() { rt.block_on(filter_request(req, &config)).unwrap(); } } + +#[test] +fn filter_failures() { + + let file_paths = fs::read_dir("tests/files/search_fail").unwrap(); + let mut config = ProxyConfig::default(); + config.allow_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); + let result = rt.block_on(filter_request(req, &config)); + assert!(result.is_err()); + } + + let file_paths = fs::read_dir("tests/files/scroll_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()); + } +} |