feat(config): add centralized configuration constants and infrastructure tests
- 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
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
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());
|
||||
}
|
||||
Reference in New Issue
Block a user