fix: validate repository URI before source kind
This commit is contained in:
@@ -1980,6 +1980,17 @@ mod tests {
|
||||
let error = validate_repository_access_source("remote", &source).unwrap_err();
|
||||
assert!(error.to_string().contains("unsupported plain HTTP"));
|
||||
assert!(error.to_string().contains("HTTPS or SSH"));
|
||||
|
||||
let mismatched = workspace_api::RepositorySource {
|
||||
kind: workspace_api::RepositorySourceKind::Https,
|
||||
uri: "http://git.example.test/team/project.git".to_string(),
|
||||
};
|
||||
let error = validate_repository_access_source("remote", &mismatched).unwrap_err();
|
||||
assert!(
|
||||
error
|
||||
.to_string()
|
||||
.contains("repository_source_plain_http_unsupported")
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -113,8 +113,7 @@ pub fn classify_legacy_repository_source(value: &str) -> RepositorySource {
|
||||
}
|
||||
|
||||
pub(crate) fn is_plain_http_repository_source(source: &RepositorySource) -> bool {
|
||||
source.kind == RepositorySourceKind::Invalid
|
||||
&& Url::parse(&source.uri).is_ok_and(|url| url.scheme() == "http")
|
||||
Url::parse(&source.uri).is_ok_and(|url| url.scheme() == "http")
|
||||
}
|
||||
|
||||
pub fn repository_source_fingerprint(source: &RepositorySource) -> String {
|
||||
|
||||
Reference in New Issue
Block a user