-
Notifications
You must be signed in to change notification settings - Fork 296
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This change restores the serving of CORS headers in HTTP responses by pd. During the refactor of auto-https logic in #3652, we overlooked that the tower [CorsLayer](https://docs.rs/tower-http/0.4.4/tower_http/cors/struct.CorsLayer.html#) was no longer being carried through after type conversions between tower, tonic, and axum. Simply moving the layer attachment to the already-built axum router, rather than the previously constructed tonic router, resolves the problem. We now include an integration test to check for the headers, so we don't inadvertently drop them again. Closes #3865.
- Loading branch information
Showing
4 changed files
with
37 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
//! Basic integration testing for pd. | ||
//! | ||
//! Validates behavior of the pd binary itself, such as serving specific HTTP | ||
//! headers in all contexts. Does NOT evaluate application logic; see the | ||
//! integration tests for pcli/pclientd for that. | ||
|
||
#[ignore] | ||
#[tokio::test] | ||
/// Confirm that permissive CORS headers are returned in HTTP responses | ||
/// by pd. We want these headers to be served directly by pd, so that | ||
/// an intermediate reverse-proxy is not required. | ||
async fn check_cors_headers() -> anyhow::Result<()> { | ||
let client = reqwest::Client::new(); | ||
let pd_url = | ||
std::env::var("PENUMBRA_NODE_PD_URL").unwrap_or("http://localhost:8080".to_string()); | ||
let r = client.get(pd_url).send().await?; | ||
assert_eq!(r.headers().get("access-control-allow-origin").unwrap(), "*"); | ||
assert_eq!( | ||
r.headers().get("access-control-expose-headers").unwrap(), | ||
"*" | ||
); | ||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters