aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe/tests
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2026-06-28 05:36:37 +0900
committernsfisis <nsfisis@gmail.com>2026-06-28 05:36:37 +0900
commitd645028a10915f792ec015b33ebd3af4efcb8c37 (patch)
tree9da51c2890756dd00a8a902c83ce235bd23dace4 /crates/shirabe/tests
parent586cfd83f5c5b8e0ff439a9b21348a5c9163a29d (diff)
downloadphp-shirabe-d645028a10915f792ec015b33ebd3af4efcb8c37.tar.gz
php-shirabe-d645028a10915f792ec015b33ebd3af4efcb8c37.tar.zst
php-shirabe-d645028a10915f792ec015b33ebd3af4efcb8c37.zip
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 <noreply@anthropic.com>
Diffstat (limited to 'crates/shirabe/tests')
-rw-r--r--crates/shirabe/tests/config_test.rs36
1 files 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<String, PhpMixed> {
let mut m: IndexMap<String, PhpMixed> = 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>Warning: Accessing example.org with verify_peer and verify_peer_name disabled.</warning>",
+ )],
+ true,
+ )
+ .unwrap();
+
+ let mut config = Config::new(false, None);
+ let io: Rc<RefCell<dyn IOInterface>> = io_mock.clone();
+ let mut repo_options: IndexMap<String, PhpMixed> = 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]