-
-
Notifications
You must be signed in to change notification settings - Fork 344
Refine and strengthen diagnostics for problematic URLs #1342
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
Merged
Merged
Changes from all commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
6cbe65d
Reorder tests and add username assertion placeholders
EliahKagan 1bdfdd9
Prepare for adding Url::user_argument_safe
EliahKagan db40382
feat: Add `Url::user_argument_safe()`
EliahKagan 169a698
Expand and introduce tests of more combinations
EliahKagan e8e2463
Clarify circumstances when *_argument_safe should be used
EliahKagan 0356345
Fix ambiguous host journey test snapshot names
EliahKagan 8c94fd4
Add ambiguous path journey tests
EliahKagan a38f646
Add expected snapshot for ambiguous path `receive`
EliahKagan d639b3b
Add ambiguous username journey tests
EliahKagan a51003d
Add expected snapshots for ambiguous username journey tests
EliahKagan 5428609
Add ambiguous user unit tests, and more for hostname
EliahKagan f56ad39
fix: Prevent usernames with leading `-` from being passed to SSH
EliahKagan 2e7517e
Comment gix_transport::client::blocking_io::ssh::connect
EliahKagan beef8d2
Give `looks_like_argument` a more accurate name
EliahKagan 29941e6
Sketch *_as_argument methods and supporting enum
EliahKagan 5457998
feat: Add `ArgumentSafety` and `Url::*_as_argument()` methods
EliahKagan 1b0af07
Give `ArgumentSafety` traits; test `*_as_argument` methods
EliahKagan 4dda375
Start on using {user,host}_as_argument in prepare_invocation
EliahKagan 2911623
Reallow `user@-arg...` in prepare_invocation
EliahKagan 524739b
Try, so far unsuccessfully, to add missing `-G` test
EliahKagan 902367f
Test that leading-`-` host names aren't used in `-G` check
EliahKagan cf59f57
Use `Url::host_as_argument()` in `ssh::connect()`
EliahKagan 03fb64a
(Re)add a short, more specific comment about user@
EliahKagan 09311b0
refactor `gix-url`
Byron 996310b
refactor `gix-transport` with minor edits to comments
Byron 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -291,7 +291,7 @@ pub fn connect( | |
mod tests { | ||
mod ssh { | ||
mod connect { | ||
use crate::{client::blocking_io::ssh::connect, Protocol}; | ||
use crate::{client::blocking_io::ssh, Protocol}; | ||
|
||
#[test] | ||
fn path() { | ||
|
@@ -304,10 +304,29 @@ mod tests { | |
("[email protected]:~/repo", "~/repo"), | ||
] { | ||
let url = gix_url::parse((*url).into()).expect("valid url"); | ||
let cmd = connect(url, Protocol::V1, Default::default(), false).expect("parse success"); | ||
let cmd = ssh::connect(url, Protocol::V1, Default::default(), false).expect("parse success"); | ||
assert_eq!(cmd.path, expected, "the path will be substituted by the remote shell"); | ||
} | ||
} | ||
|
||
#[test] | ||
fn ambiguous_host_disallowed() { | ||
for url in [ | ||
"ssh://-oProxyCommand=open$IFS-aCalculator/foo", | ||
"user@-oProxyCommand=open$IFS-aCalculator:username/repo", | ||
] { | ||
let url = gix_url::parse((*url).into()).expect("valid url"); | ||
let options = ssh::connect::Options { | ||
command: Some("unrecognized".into()), | ||
disallow_shell: false, | ||
kind: None, | ||
}; | ||
assert!(matches!( | ||
ssh::connect(url, Protocol::V1, options, false), | ||
Err(ssh::Error::AmbiguousHostName { host }) if host == "-oProxyCommand=open$IFS-aCalculator", | ||
)); | ||
} | ||
} | ||
} | ||
} | ||
} |
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
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.
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.
This is a great use of
match
and one of the main reasons Rust is so powerful! Never again can one miss handling a possible program state, as long as one remembers to match on them that is :).