Created
January 19, 2016 18:08
-
-
Save mackwic/81fc90feb849306b7a58 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#[cfg(test)] | |
mod tests { | |
use super::*; | |
use test_utils::*; | |
use test_utils::ResType::*; | |
use std::net::SocketAddr; | |
use std::str::FromStr; | |
#[test] | |
fn server_only_on_localhost() { | |
// server on remote is forbidden | |
let addrs = [ | |
// ipv4 | |
Bad("192.168.1.1"), Bad("192.168.1.2"), Bad("10.10.1.1"), Bad("1.1.1.1"), Bad("8.8.8.8"), | |
Good("127.0.0.1"), Good("0.0.0.0"), Good("127.1.1.1"), Good("127.127.127.127"), | |
// ipv4 - special case | |
Bad("127.0.0.0"), | |
// ipv6 | |
Bad("2001:db8::211:22ff:fe33:4455"), | |
Bad("2021:db8::211:22ff:fe33:4455"), | |
Bad("2001:db8::211:22ff:fe33:5555"), | |
Bad("2001:470:26:307:0503:c039:de6b:18d4"), | |
Bad("2001:470:26:307:6484:691f:1e4f:9ef6"), | |
Bad("2001:470:26:307:d90e:988a:779b:af51"), | |
Good("fd10:113c:416d::"), Good("fd60:49d3:6bb6::"), Good("fd9d:90eb:f15::"), | |
Good("fdfe:1434:20c::") | |
]; | |
let addrs = addrs.iter() | |
.map(|str| match str { | |
&Bad(addr) => Bad(SocketAddr::from_str(addr).unwrap()), | |
&Good(addr) => Good(SocketAddr::from_str(addr).unwrap()) | |
}); | |
// src/net/link/mod.rs:60:9: 60:30 error: type mismatch resolving `<[closure@src/net/link/mod.rs:56:31: 59:27] | |
// as core::ops::FnOnce<(&test_utils::ResType<&str>,)>>::Output == &test_utils::ResType<_>`: | |
// expected enum `test_utils::ResType`, | |
// found &-ptr [E0271] | |
test_loop_with_result(addrs, &Link::new_server) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment