diff options
| author | mo khan <mo@mokhan.ca> | 2025-07-04 17:03:20 -0600 |
|---|---|---|
| committer | mo khan <mo@mokhan.ca> | 2025-07-04 17:03:20 -0600 |
| commit | c27093125aed8434c16655af7e7f415d84859dc7 (patch) | |
| tree | 0a7b9858b8c40f377eac2f4345cff677f00d027b /tests | |
| parent | 784e0740a6ca7684feba3fb4f26d68e098b5c826 (diff) | |
test: start to build table tests
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/authorization/check_service_test.rs | 55 |
1 files changed, 25 insertions, 30 deletions
diff --git a/tests/authorization/check_service_test.rs b/tests/authorization/check_service_test.rs index fe45712d..4ff7a89b 100644 --- a/tests/authorization/check_service_test.rs +++ b/tests/authorization/check_service_test.rs @@ -146,39 +146,34 @@ mod tests { // {status: tonic::Code::PermissionDenied, http: &HTTPRequest{Method: "GET", Path: "/dashboard"}}, // {status: tonic::Code::PermissionDenied, http: &HTTPRequest{Method: "GET", Path: "/dashboard", Headers: invalidHeaders}}, // {status: tonic::Code::PermissionDenied, http: &HTTPRequest{Method: "POST", Path: "/sparkles"}}, - // - // http: - // method: \"GET\", - // headers: { - // \":method\": \"GET\", - // \":authority\": \"localhost:10000\", - // \":path\": \"/sparkles\", - // }, - // path: \"/sparkles\", - // host: \"localhost:10000\", - let request = tonic::Request::new(build_request(|item: &mut HttpRequest| { - let path = String::from("/"); - let method = String::from("GET"); - let host = String::from("sparkle.staging.runway.gitlab.net"); - - item.method = method.clone(); - item.path = path.clone(); - item.host = host.clone(); - item.headers = build_headers(vec![ - (String::from(":path"), path), - (String::from(":method"), method), - (String::from(":authority"), host), - ]); - })); + let test_cases = vec![( + "GET", + "/", + "sparkle.staging.runway.gitlab.net", + tonic::Code::Ok, + )]; - let response = subject().check(request).await; - assert!(response.is_ok()); + for (method, path, host, expected_status_code) in test_cases { + let request = tonic::Request::new(build_request(|item: &mut HttpRequest| { + item.method = method.to_string(); + item.path = path.to_string(); + item.host = host.to_string(); + item.headers = build_headers(vec![ + (String::from(":path"), path.to_string()), + (String::from(":method"), method.to_string()), + (String::from(":authority"), host.to_string()), + ]); + })); - let check_response = response.unwrap().into_inner(); - assert!(check_response.status.is_some()); + let response = subject().check(request).await; + assert!(response.is_ok()); - let status = check_response.status.unwrap(); - assert_eq!(status.code, tonic::Code::Ok as i32); + let check_response = response.unwrap().into_inner(); + assert!(check_response.status.is_some()); + + let status = check_response.status.unwrap(); + assert_eq!(status.code, expected_status_code as i32); + } } } |
