Skip to content

Commit

Permalink
test: add cors test
Browse files Browse the repository at this point in the history
  • Loading branch information
sunng87 committed Jan 24, 2025
1 parent dd800d8 commit cf504f3
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 1 deletion.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion src/servers/src/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -747,7 +747,6 @@ impl HttpServer {
Method::PUT,
Method::DELETE,
Method::HEAD,
Method::OPTIONS,
])
.allow_origin(Any)
.allow_headers(Any),
Expand Down
1 change: 1 addition & 0 deletions tests-integration/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ zstd.workspace = true
datafusion.workspace = true
datafusion-expr.workspace = true
hex.workspace = true
http.workspace = true
itertools.workspace = true
opentelemetry-proto.workspace = true
partition.workspace = true
Expand Down
18 changes: 18 additions & 0 deletions tests-integration/tests/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,24 @@ pub async fn test_http_auth(store_type: StorageType) {
guard.remove_all().await;
}

#[tokio::test]
pub async fn test_cors() {
let (app, mut guard) = setup_test_http_app_with_frontend(StorageType::File, "test_cors").await;
let client = TestClient::new(app).await;

let res = client.get("/health").send().await;

assert_eq!(res.status(), StatusCode::OK);
assert_eq!(
res.headers()
.get(http::header::ACCESS_CONTROL_ALLOW_ORIGIN)
.expect("expect cors header origin"),
"*"
);

guard.remove_all().await;
}

pub async fn test_sql_api(store_type: StorageType) {
let (app, mut guard) = setup_test_http_app_with_frontend(store_type, "sql_api").await;
let client = TestClient::new(app).await;
Expand Down

0 comments on commit cf504f3

Please sign in to comment.