Skip to content

Commit 88df2e7

Browse files
committed
fix(tests): update URL validation tests to match auto-upgrade behavior
- HTTP URLs are auto-upgraded to HTTPS, not rejected - Localhost is allowed for local dev server
1 parent 365f38b commit 88df2e7

1 file changed

Lines changed: 11 additions & 5 deletions

File tree

  • apps/src-tauri/src/extensions/commands

apps/src-tauri/src/extensions/commands/mod.rs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -600,10 +600,12 @@ mod tests {
600600
}
601601

602602
#[test]
603-
fn test_validate_url_rejects_http() {
603+
fn test_validate_url_auto_upgrades_http_to_https() {
604+
// Remote HTTP URLs are auto-upgraded to HTTPS (not rejected)
604605
let result = validate_url_security("http://marketplace.example.com/ext.zip");
605-
assert!(result.is_err());
606-
assert!(result.unwrap_err().contains("HTTPS"));
606+
assert!(result.is_ok());
607+
// Non-HTTP/HTTPS schemes are still rejected
608+
assert!(validate_url_security("ftp://marketplace.example.com/ext.zip").is_err());
607609
}
608610

609611
#[test]
@@ -624,8 +626,12 @@ mod tests {
624626
}
625627

626628
#[test]
627-
fn test_validate_url_rejects_localhost() {
628-
assert!(validate_url_security("https://localhost/ext.zip").is_err());
629+
fn test_validate_url_allows_localhost_rejects_internal() {
630+
// Localhost is allowed for local development
631+
assert!(validate_url_security("https://localhost/ext.zip").is_ok());
632+
assert!(validate_url_security("http://localhost/ext.zip").is_ok());
633+
assert!(validate_url_security("http://localhost:3000/ext.zip").is_ok());
634+
// Internal/private domains are still rejected
629635
assert!(validate_url_security("https://something.local/ext.zip").is_err());
630636
assert!(validate_url_security("https://service.internal/ext.zip").is_err());
631637
}

0 commit comments

Comments
 (0)