summaryrefslogtreecommitdiffstats
path: root/tests/parse_es_requests.rs
diff options
context:
space:
mode:
authorBryan Newbold <bnewbold@archive.org>2020-08-25 18:33:39 -0700
committerBryan Newbold <bnewbold@archive.org>2020-08-25 18:33:39 -0700
commit45e4cd9537f289a98579eef36a2dc3e561cc48fa (patch)
treee14c9a9f889c09b0fffb2f440341c185c963d66f /tests/parse_es_requests.rs
parent55f9b88ba1d63db75ef9cde3cf94e5c98526ad2f (diff)
downloades-public-proxy-45e4cd9537f289a98579eef36a2dc3e561cc48fa.tar.gz
es-public-proxy-45e4cd9537f289a98579eef36a2dc3e561cc48fa.zip
move tests around
Diffstat (limited to 'tests/parse_es_requests.rs')
-rw-r--r--tests/parse_es_requests.rs48
1 files changed, 36 insertions, 12 deletions
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());
+ }
+}