Repository navigation
Review received-head and CI fixture follow-ups to PR 275 #499
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
ChristianPavilonis
wants to merge
15
commits into
docs/outbound-http-spec
from
review/pr275-cutover-followup-20261112
Open
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
410a162
Capture authenticated head facts before transport sanitation
ChristianPavilonis b97efec
fix: close outbound review validation gaps
aram356 658f89d
Read complete byte-bounded CI wire evidence and preserve atomic receipts
ChristianPavilonis 14a6ca8
Make retained callback-scope fixture independent of IO timing
ChristianPavilonis 9c7c2f0
Revert our three cutover additions to PR 275
ChristianPavilonis eb95665
Capture authenticated head facts before transport sanitation
ChristianPavilonis 1ea46af
Read complete byte-bounded CI wire evidence and preserve atomic receipts
ChristianPavilonis e0f01bc
Make retained callback-scope fixture independent of IO timing
ChristianPavilonis cf8003f
Merge PR #275 into PR #499 for outbound compatibility stack
aram356 c6039a3
Merge PR #275 into PR #499 for outbound compatibility stack
aram356 c5c6b8e
Merge PR #275 into PR #499 for outbound compatibility stack
aram356 f60bae4
Merge PR #275 into PR #499 for outbound compatibility stack
aram356 599f329
Merge PR #275 into PR #499 for outbound compatibility stack
aram356 f775105
Merge PR #275 into PR #499 for outbound compatibility stack
aram356 2790199
Merge PR #275 into PR #499 for outbound compatibility stack
aram356 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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,80 @@ | ||
| #[cfg(test)] | ||
| mod tests { | ||
| use edgezero_core::app::App; | ||
| use edgezero_core::http::{Extensions, HeaderMap, HeaderValue}; | ||
| use edgezero_core::router::RouterService; | ||
|
|
||
| #[derive(Clone, Debug, Eq, PartialEq)] | ||
| struct AuthenticatedAuthority(String); | ||
|
|
||
| #[test] | ||
| fn absent_preparation_callback_leaves_extensions_unchanged() { | ||
| let app = App::new(RouterService::builder().build()); | ||
| let mut extensions = Extensions::new(); | ||
| extensions.insert(AuthenticatedAuthority("retained.example.com".to_owned())); | ||
|
|
||
| app.prepare_received_head(&HeaderMap::new(), &mut extensions); | ||
|
|
||
| assert_eq!( | ||
| extensions.get::<AuthenticatedAuthority>(), | ||
| Some(&AuthenticatedAuthority("retained.example.com".to_owned())), | ||
| "the default should preserve existing extensions" | ||
| ); | ||
| } | ||
|
|
||
| #[test] | ||
| fn received_head_preparation_retains_only_authenticated_fact_without_mutating_headers() { | ||
| let app = App::new( | ||
| RouterService::builder() | ||
| .received_head_preparer(|headers, extensions| { | ||
| if headers.get("x-fixture-auth") | ||
| == Some(&HeaderValue::from_static("fictional-secret")) | ||
| && let Some(authority) = headers | ||
| .get("x-forwarded-host") | ||
| .and_then(|value| value.to_str().ok()) | ||
| { | ||
| extensions.insert(AuthenticatedAuthority(authority.to_owned())); | ||
| } | ||
| }) | ||
| .build(), | ||
| ); | ||
| let mut headers = HeaderMap::new(); | ||
| headers.insert( | ||
| "x-fixture-auth", | ||
| HeaderValue::from_static("fictional-secret"), | ||
| ); | ||
| headers.insert( | ||
| "x-forwarded-host", | ||
| HeaderValue::from_static("publisher.example.com:8443"), | ||
| ); | ||
| let original = headers.clone(); | ||
| let mut extensions = Extensions::new(); | ||
|
|
||
| app.prepare_received_head(&headers, &mut extensions); | ||
|
|
||
| assert_eq!( | ||
| headers, original, | ||
| "preparation should not mutate received headers" | ||
| ); | ||
| assert_eq!( | ||
| extensions.get::<AuthenticatedAuthority>(), | ||
| Some(&AuthenticatedAuthority( | ||
| "publisher.example.com:8443".to_owned() | ||
| )), | ||
| "preparation should retain the authenticated public authority" | ||
| ); | ||
| assert_eq!( | ||
| extensions.len(), | ||
| 1, | ||
| "preparation should retain only the public fact" | ||
| ); | ||
|
|
||
| headers.remove("x-fixture-auth"); | ||
| let mut rejected = Extensions::new(); | ||
| app.prepare_received_head(&headers, &mut rejected); | ||
| assert!( | ||
| rejected.is_empty(), | ||
| "missing authentication should retain no fact" | ||
| ); | ||
| } | ||
| } |
This file contains hidden or 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 hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Non-blocking: no adapter calls
prepare_received_headat this head, so a preparer registered here never runs on Fastly, Cloudflare, Spin or Axum. Further up the stack, only the Axum service wires it in (#409). Consider naming the host that invokes it, e.g. "The Axum managed host calls it…", or saying that adapters which don't sanitize forwarding fields never invoke it. That way an app on another adapter won't count on authenticated facts that never get filled in.