diff options
| author | nsfisis <nsfisis@gmail.com> | 2026-07-12 01:28:17 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2026-07-16 01:02:47 +0900 |
| commit | 4d9e3dd6176a0cd2cc5e158b044beeb7b3de21be (patch) | |
| tree | ed19d9660f40a1bc93c5629c7a6c7bf41cf884e8 /crates/shirabe/tests/util/remote_filesystem_test.rs | |
| parent | 4e1170c2328dd8007a5d737a759cd18030b1200b (diff) | |
| download | php-shirabe-4d9e3dd6176a0cd2cc5e158b044beeb7b3de21be.tar.gz php-shirabe-4d9e3dd6176a0cd2cc5e158b044beeb7b3de21be.tar.zst php-shirabe-4d9e3dd6176a0cd2cc5e158b044beeb7b3de21be.zip | |
test(util): port remaining todo!() tests in util test suite
Implement previously-todo!() tests in auth_helper_test.rs,
process_executor_test.rs, remote_filesystem_test.rs, and
stream_context_factory_test.rs by porting the corresponding PHPUnit
test methods. Extend IOStub with writeRaw/setAuthentication call
tracking and askAndValidate/getAuthentication overrides to model the
PHPUnit mocks these tests rely on, deduping the resulting
call-recording fields into a small generic CallRecorder<T> helper
instead of repeating the same RefCell<Vec<T>> push/borrow().clone()
boilerplate five times.
testStoreAuthWithPromptInvalidAnswer and
testPromptAuthIfNeededMultipleBitbucketDownloads had initially lost
the ported PHPUnit mock's argument/call-count assertions
(askAndValidate's exact prompt string, and
hasAuthentication/getAuthentication's exactly(2) call counts),
silently narrowing what the tests verify; IOStub now records these
calls and the tests assert on them, matching upstream.
Tests left unportable (PHP set_error_handler machinery, closures in
data providers, network/subclass-mock dependencies, etc.) keep
#[ignore] with a single // TODO(phase-d) reason recorded in the
function body.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Diffstat (limited to 'crates/shirabe/tests/util/remote_filesystem_test.rs')
| -rw-r--r-- | crates/shirabe/tests/util/remote_filesystem_test.rs | 56 |
1 files changed, 54 insertions, 2 deletions
diff --git a/crates/shirabe/tests/util/remote_filesystem_test.rs b/crates/shirabe/tests/util/remote_filesystem_test.rs index 9c1fe0bd..0fdc81b3 100644 --- a/crates/shirabe/tests/util/remote_filesystem_test.rs +++ b/crates/shirabe/tests/util/remote_filesystem_test.rs @@ -273,19 +273,71 @@ fn test_copy() { #[test] #[ignore = "requires a MockObject subclass of RemoteFilesystem overriding private get_remote_contents; no subclass-mocking infrastructure exists"] fn test_copy_with_no_retry_on_failure() { + // TODO(phase-d): requires a MockObject subclass of RemoteFilesystem overriding the + // private get_remote_contents method. There is no subclass-mocking infrastructure in + // Rust for this, and get_remote_contents's http(s) branch is itself still a + // TODO(phase-c) stub (always returns Ok(None)), so there is nothing yet to intercept + // even with a seam. todo!() } #[test] #[ignore = "requires MockObject subclasses overriding RemoteFilesystem::get_remote_contents and AuthHelper::prompt_auth_if_needed; no subclass-mocking infrastructure exists"] fn test_copy_with_success_on_retry() { + // TODO(phase-d): requires MockObject subclasses overriding + // RemoteFilesystem::get_remote_contents and AuthHelper::prompt_auth_if_needed to + // simulate a first failure and a retried success; same missing-subclass-mocking- + // infrastructure and TODO(phase-c) http(s)-stub blockers as + // test_copy_with_no_retry_on_failure above. todo!() } #[test] -#[ignore = "get_tls_defaults validates the (nonexistent) cafile and errors; constructor swallows it, so no ssl defaults are produced. Faithful porting needs CaBundle::validate_ca_file semantics for a missing file"] fn test_get_options_for_url_creates_secure_tls_defaults() { - todo!() + let io: std::rc::Rc<std::cell::RefCell<dyn IOInterface>> = + std::rc::Rc::new(std::cell::RefCell::new(IOStub::new())); + + let mut ssl: IndexMap<String, PhpMixed> = IndexMap::new(); + ssl.insert( + "cafile".to_string(), + PhpMixed::String("/some/path/file.crt".to_string()), + ); + let mut additional_options: IndexMap<String, PhpMixed> = IndexMap::new(); + additional_options.insert("ssl".to_string(), PhpMixed::Array(ssl)); + + let res = call_get_options_for_url( + io, + "example.org", + additional_options, + IndexMap::new(), + "http://www.example.org", + ); + + let ssl_res = res.get("ssl").and_then(|v| v.as_array()).unwrap(); + let ciphers = ssl_res.get("ciphers").and_then(|v| v.as_string()).unwrap(); + assert!(ciphers.contains( + "!aNULL:!eNULL:!EXPORT:!DES:!3DES:!RC4:!MD5:!PSK:!aECDH:!EDH-DSS-DES-CBC3-SHA:!EDH-RSA-DES-CBC3-SHA:!KRB5-DES-CBC3-SHA" + )); + assert_eq!( + Some(true), + ssl_res.get("verify_peer").and_then(|v| v.as_bool()) + ); + assert_eq!( + Some(true), + ssl_res.get("SNI_enabled").and_then(|v| v.as_bool()) + ); + assert_eq!( + Some(7), + ssl_res.get("verify_depth").and_then(|v| v.as_int()) + ); + assert_eq!( + Some("/some/path/file.crt"), + ssl_res.get("cafile").and_then(|v| v.as_string()) + ); + assert_eq!( + Some(true), + ssl_res.get("disable_compression").and_then(|v| v.as_bool()) + ); } // Mirrors RemoteFilesystemTest::provideBitbucketPublicDownloadUrls. |
