diff options
| author | mo khan <mo@mokhan.ca> | 2025-07-04 12:40:38 -0600 |
|---|---|---|
| committer | mo khan <mo@mokhan.ca> | 2025-07-04 12:40:38 -0600 |
| commit | f8549af8d64b551449957c3004b74ed0bf69c593 (patch) | |
| tree | 62ca253b16da2e8239f9409a3159e19699301c66 /tests | |
| parent | 7c2b698c5723e43fa4eb73a3fdb2bee829841ddb (diff) | |
feat: allow access to sparkle homepage
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/authorization/check_service_test.rs | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/tests/authorization/check_service_test.rs b/tests/authorization/check_service_test.rs index 3a225974..3f8adec2 100644 --- a/tests/authorization/check_service_test.rs +++ b/tests/authorization/check_service_test.rs @@ -115,4 +115,69 @@ mod tests { } } } + + #[tokio::test] + async fn test_public_sparkle_endpoints() { + // {status: tonic::Code::Ok, http: &HTTPRequest{Method: "GET", Path: "/"}}, + // {status: tonic::Code::Ok, http: &HTTPRequest{Method: "GET", Path: "/application.js"}}, + // {status: tonic::Code::Ok, http: &HTTPRequest{Method: "GET", Path: "/callback"}}, + // {status: tonic::Code::Ok, http: &HTTPRequest{Method: "GET", Path: "/dashboard", Headers: loggedInHeaders}}, + // {status: tonic::Code::Ok, http: &HTTPRequest{Method: "GET", Path: "/dashboard/nav"}}, + // {status: tonic::Code::Ok, http: &HTTPRequest{Method: "GET", Path: "/favicon.ico"}}, + // {status: tonic::Code::Ok, http: &HTTPRequest{Method: "GET", Path: "/favicon.png"}}, + // {status: tonic::Code::Ok, http: &HTTPRequest{Method: "GET", Path: "/favicon.png"}}, + // {status: tonic::Code::Ok, http: &HTTPRequest{Method: "GET", Path: "/health"}}, + // {status: tonic::Code::Ok, http: &HTTPRequest{Method: "GET", Path: "/htmx.js"}}, + // {status: tonic::Code::Ok, http: &HTTPRequest{Method: "GET", Path: "/index.html"}}, + // {status: tonic::Code::Ok, http: &HTTPRequest{Method: "GET", Path: "/logo.png"}}, + // {status: tonic::Code::Ok, http: &HTTPRequest{Method: "GET", Path: "/pico.min.css"}}, + // {status: tonic::Code::Ok, http: &HTTPRequest{Method: "GET", Path: "/signout"}}, + // {status: tonic::Code::Ok, http: &HTTPRequest{Method: "GET", Path: "/sparkles"}}, + // {status: tonic::Code::Ok, http: &HTTPRequest{Method: "GET", Path: "/vue.global.js"}}, + // {status: tonic::Code::Ok, http: &HTTPRequest{Method: "POST", Path: "/sparkles", Headers: loggedInHeaders}}, + // {status: tonic::Code::Ok, http: &HTTPRequest{Method: "POST", Path: "/sparkles/restore"}}, + // {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: Some(HttpRequest { + // id: \"13810813926834082307\", + // method: \"GET\", + // headers: { + // \"accept\": \"*/*\", + // \":method\": \"GET\", + // \"accept-encoding\": \"gzip, deflate, br, zstd\", + // \"user-agent\": \"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36\", + // \"x-request-id\": \"b191fe87-e9b8-458e-b9ec-46d477a62803\", + // \":authority\": \"localhost:10000\", + // \":path\": \"/sparkles\", + // \"x-forwarded-proto\": \"http\", + // \":scheme\": \"http\", + // }, + // header_map: None, + // path: \"/sparkles\", + // host: \"localhost:10000\", + // scheme: \"http\", + // query: \"\", + // fragment: \"\", + // size: 0, + // protocol: \"HTTP/1.1\", + // body: \"\", + // raw_body: [] + + let request = tonic::Request::new(build_request(|item: &mut HttpRequest| { + let path = String::from("/"); + item.path = path.clone(); + item.headers = build_headers(vec![(String::from(":path"), path)]); + })); + + let response = subject().check(request).await; + assert!(response.is_ok()); + + let check_response = response.unwrap().into_inner(); + assert!(check_response.status.is_some()); + + let status = check_response.status.unwrap(); + assert_eq!(status.code, tonic::Code::Ok as i32); + } } |
