Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Antonio Ojea authored and aojea committed Jun 4, 2021
1 parent fe40c06 commit 51fd64a
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions tests/tests.bats
Original file line number Diff line number Diff line change
Expand Up @@ -167,14 +167,16 @@ teardown() {

@test "TCP listen without iptables" {
sudo ip netns exec SouthNS bash -c '../bin/netkat --listen 1.1.1.2 9090 > /tmp/test_output.log' 3>&- &
sleep 1
sudo ip netns exec NorthNS bash -c "cat ./test_short.log | nc 1.1.1.2 9090"
run diff ./test_short.log /tmp/test_output.log
[ "$status" -eq 0 ]
}

@test "TCP listen without iptables long file" {
sudo ip netns exec SouthNS bash -c '../bin/netkat --listen 1.1.1.2 9090 > /tmp/test_output.log' 3>&- &
sudo ip netns exec NorthNS bash -c "cat ./test_long.log | nc 9090"
sleep 1
sudo ip netns exec NorthNS bash -c "cat ./test_long.log | nc 1.1.1.2 9090"
run diff ./test_long.log /tmp/test_output.log
[ "$status" -eq 0 ]
}
Expand Down Expand Up @@ -206,7 +208,7 @@ teardown() {

@test "TCP listen with iptables in input" {
# add iptables rule to block traffic
sudo ip netns exec NorthNS bash -c "iptables -A INPUT -d 1.1.1.2 -j DROP"
sudo ip netns exec SouthNS bash -c "iptables -A INPUT -d 1.1.1.2 -j DROP"
# verify it actually drops traffic
run sudo ip netns exec NorthNS ping -c 1 1.1.1.2
[ "$status" -eq 1 ]
Expand All @@ -219,7 +221,7 @@ teardown() {

@test "TCP listen with iptables in input long file" {
# add iptables rule to block traffic
sudo ip netns exec NorthNS bash -c "iptables -A INPUT -d 1.1.1.2 -j DROP"
sudo ip netns exec SouthNS bash -c "iptables -A INPUT -d 1.1.1.2 -j DROP"
# verify it actually drops traffic
run sudo ip netns exec NorthNS ping -c 1 1.1.1.2
[ "$status" -eq 1 ]
Expand Down

0 comments on commit 51fd64a

Please sign in to comment.