-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
33 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#[cfg(target_os = "linux")] | ||
use wireguard_uapi::set; | ||
#[cfg(target_os = "linux")] | ||
use wireguard_uapi::WgSocket; | ||
|
||
#[cfg(target_os = "linux")] | ||
#[test] | ||
// WireGuard returns an ENODEV (no device error) when you attempt to update a | ||
// WireGuard device that hasn't been created yet. | ||
// | ||
// Instead of properly reporting this error, the library currently swallows it | ||
// and reports "No ack received". Adding this test now to record what currently | ||
// happens and comment on the ideal future state. | ||
// | ||
// See https://github.com/gluxon/wireguard-uapi-rs/issues/28 | ||
fn missing_device_returns_sensible_error() -> anyhow::Result<()> { | ||
let mut wg = WgSocket::connect()?; | ||
let ifname = "wg404"; | ||
|
||
let set_device_args = set::Device::from_ifname(ifname) | ||
.flags(vec![set::WgDeviceF::ReplacePeers]) | ||
.peers(vec![]); | ||
let set_device_result = wg.set_device(set_device_args); | ||
|
||
let existing_err_message = set_device_result.unwrap_err().to_string(); | ||
|
||
// TODO: Ensure this library returns more sensible errors. Update the "No | ||
// ack received" string below to "No device found by interface name or | ||
// public key". | ||
assert_eq!(existing_err_message, "No ack received"); | ||
|
||
Ok(()) | ||
} |