namib-project / nftables-rs

Safe abstraction for nftables JSON API (libnftables-json).
https://crates.io/crates/nftables
Apache License 2.0
23 stars 13 forks source link

Rootless tests #20

Open jwhb opened 5 months ago

jwhb commented 5 months ago

18 introduced running tests against nft inside network namespaces with a script that manually manages a network namespace to execute cargo test.

FYI, it should be much simpler to just use unshare -n cargo ... to create a new netns here, no need to manage any ip netns "names". You can also do unshare -rn as normal user (assuming unprivileged user namespaces are enabled, which is the default for most distros) so not even a need for sudo. Because the netns is only tied to the process once the process exits the netns will be gone so you also can skip the clean-up logic as well _Originally posted by @Luap99 in https://github.com/namib-project/nftables-rs/pull/18#discussion_r1527210554_

The helper_tests could be improved such that each test calls unshare -rn nft as program arg for apply and get ruleset functions.