70f2f7d63d
- Introduce config.rs with all magic numbers and resource limits defined as constants - Add comprehensive test suite covering metrics rendering, rate limiting, and cache operations - Include tests for configuration constant validation and sanitization functions - Add pack protocol tests for index_pack and pack_objects functionality - Implement remote repository discovery tests with security validations - Support runtime overrides via environment variables for all configurable values
57 lines
1.5 KiB
Rust
57 lines
1.5 KiB
Rust
use gitks::pb::*;
|
|
use gitks::remote::find_remote::{find_remote_repository, find_remote_root_ref};
|
|
|
|
#[test]
|
|
fn test_find_remote_repository_empty_url() {
|
|
let resp = find_remote_repository(FindRemoteRepositoryRequest {
|
|
remote_url: String::new(),
|
|
})
|
|
.unwrap();
|
|
assert!(!resp.exists);
|
|
assert!(resp.refs.is_empty());
|
|
}
|
|
|
|
#[test]
|
|
fn test_find_remote_repository_invalid_scheme() {
|
|
let resp = find_remote_repository(FindRemoteRepositoryRequest {
|
|
remote_url: "ftp://bad".into(),
|
|
});
|
|
assert!(resp.is_err());
|
|
}
|
|
|
|
#[test]
|
|
fn test_find_remote_repository_file_scheme_blocked() {
|
|
let resp = find_remote_repository(FindRemoteRepositoryRequest {
|
|
remote_url: "file:///tmp/test.git".into(),
|
|
});
|
|
assert!(resp.is_err());
|
|
}
|
|
|
|
#[test]
|
|
fn test_find_remote_root_ref_empty_url() {
|
|
let resp = find_remote_root_ref(FindRemoteRootRefRequest {
|
|
remote_url: String::new(),
|
|
})
|
|
.unwrap();
|
|
assert!(resp.ref_name.is_empty());
|
|
assert!(resp.target_oid.is_empty());
|
|
}
|
|
|
|
#[test]
|
|
fn test_find_remote_root_ref_invalid_scheme() {
|
|
let resp = find_remote_root_ref(FindRemoteRootRefRequest {
|
|
remote_url: "ftp://bad".into(),
|
|
});
|
|
assert!(resp.is_err());
|
|
}
|
|
|
|
#[test]
|
|
fn test_find_remote_root_ref_unreachable() {
|
|
// A valid scheme but unreachable host should return empty, not error
|
|
let resp = find_remote_root_ref(FindRemoteRootRefRequest {
|
|
remote_url: "https://0.0.0.0:1/nonexistent.git".into(),
|
|
})
|
|
.unwrap();
|
|
assert!(resp.ref_name.is_empty() || resp.target_oid.is_empty());
|
|
}
|