From d645028a10915f792ec015b33ebd3af4efcb8c37 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Sun, 28 Jun 2026 05:36:37 +0900 Subject: test(config): port testProhibitedUrlsWarningVerifyPeer The IOMock helper is now available, so the verify_peer/verify_peer_name SSL warning case can be exercised instead of left as todo!(). Co-Authored-By: Claude Opus 4.8 --- crates/shirabe/tests/config_test.rs | 36 ++++++++++++++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) diff --git a/crates/shirabe/tests/config_test.rs b/crates/shirabe/tests/config_test.rs index 1821f24..b7eb5a5 100644 --- a/crates/shirabe/tests/config_test.rs +++ b/crates/shirabe/tests/config_test.rs @@ -1,12 +1,22 @@ //! ref: composer/tests/Composer/Test/ConfigTest.php +use std::cell::RefCell; +use std::rc::Rc; + use indexmap::IndexMap; use serial_test::serial; use shirabe::advisory::Auditor; use shirabe::config::Config; +use shirabe::io::IOInterface; +use shirabe::io::io_interface; use shirabe::util::Platform; use shirabe_php_shim::PhpMixed; +#[path = "common/io_mock.rs"] +#[allow(dead_code)] // io_mock exposes more helpers than this binary uses +mod io_mock; +use io_mock::{Expectation, get_io_mock}; + /// Builds a `['config' => {...}]` map for `Config::merge`. fn config_section(pairs: Vec<(&str, PhpMixed)>) -> IndexMap { let mut m: IndexMap = IndexMap::new(); @@ -487,9 +497,31 @@ fn test_prohibited_urls_throw_exception() { } #[test] -#[ignore = "getIOMock() is not ported yet"] fn test_prohibited_urls_warning_verify_peer() { - todo!() + let (io_mock, _io_guard) = get_io_mock(io_interface::DEBUG).unwrap(); + io_mock + .borrow_mut() + .expects( + vec![Expectation::text( + "Warning: Accessing example.org with verify_peer and verify_peer_name disabled.", + )], + true, + ) + .unwrap(); + + let mut config = Config::new(false, None); + let io: Rc> = io_mock.clone(); + let mut repo_options: IndexMap = IndexMap::new(); + repo_options.insert( + "ssl".to_string(), + PhpMixed::Array(map(vec![ + ("verify_peer", PhpMixed::Bool(false)), + ("verify_peer_name", PhpMixed::Bool(false)), + ])), + ); + config + .prohibit_url_by_config("https://example.org", Some(io), &repo_options) + .unwrap(); } #[ignore] -- cgit v1.3.1