Skip to content

Commit 47eb1ca

Browse files
authored
Bug in v-delete-sys-ip 192.1.168.1 deletes 192.1.168.1* in netplan config (hestiacp#3894)
* Test if v-delete-sys-ip is really broken * Use correct file * Fix test * Fix the bug causing the error
1 parent 4375549 commit 47eb1ca

File tree

2 files changed

+37
-25
lines changed

2 files changed

+37
-25
lines changed

bin/v-delete-sys-ip

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ fi
7777

7878
# Deleting startup conf on Debian/Ubuntu
7979
if [ -f "/etc/netplan/60-hestia.yaml" ]; then
80-
sed -i "/$ip/d" /etc/netplan/60-hestia.yaml
80+
sed -i "/$ip\//d" /etc/netplan/60-hestia.yaml
8181
if ! grep -q '-' /etc/netplan/60-hestia.yaml; then
8282
rm /etc/netplan/60-hestia.yaml
8383
fi

test/test.bats

Lines changed: 36 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -664,9 +664,9 @@ function check_ip_not_banned(){
664664

665665
@test "Ip: [Debian] Netplan file updated" {
666666
# Skip with netplan
667-
if [ -f /etc/netplan/60-hestia.yaml ]; then
668-
skip
669-
fi
667+
if [ $(lsb_release -s -i) = "Ubuntu" ]; then
668+
skip
669+
fi
670670

671671
assert_file_exist /etc/network/interfaces
672672
assert_file_contains /etc/network/interfaces "$ip"
@@ -698,39 +698,51 @@ function check_ip_not_banned(){
698698
fi
699699
}
700700

701-
@test "Ip: Delete ips" {
701+
@test "Ip: Delete ip 198.18.0.12" {
702702
local ip="198.18.0.12"
703703
run v-delete-sys-ip $ip
704704
assert_success
705705
refute_output
706706

707707
assert_file_not_exist /etc/$WEB_SYSTEM/conf.d/$ip.conf
708708
assert_file_not_exist $HESTIA/data/ips/$ip
709+
}
709710

711+
@test "Ip: [Ubuntu] Netplan file changed" {
712+
# Skip if Debian
713+
if [ $(lsb_release -s -i) != "Ubuntu" ]; then
714+
skip
715+
fi
710716

711-
ip="198.18.0.121"
712-
run v-delete-sys-ip $ip
713-
assert_success
714-
refute_output
717+
ip="198.18.0.121"
718+
assert_file_exist /etc/netplan/60-hestia.yaml
719+
assert_file_contains /etc/netplan/60-hestia.yaml "$ip"
720+
}
715721

716-
assert_file_not_exist /etc/$WEB_SYSTEM/conf.d/$ip.conf
717-
assert_file_not_exist $HESTIA/data/ips/$ip
722+
@test "Ip: Delete ip 198.18.0.121" {
723+
ip="198.18.0.121"
724+
run v-delete-sys-ip $ip
725+
assert_success
726+
refute_output
718727

719-
if [ -n "$PROXY_SYSTEM" ]; then
720-
assert_file_not_exist /etc/$PROXY_SYSTEM/conf.d/$ip.conf
721-
fi
728+
assert_file_not_exist /etc/$WEB_SYSTEM/conf.d/$ip.conf
729+
assert_file_not_exist $HESTIA/data/ips/$ip
722730

723-
# remoteip and rpaf config hashes must match the initial one
724-
if [ ! -z "$a2_rpaf_hash" ]; then
725-
local a2_rpaf="/etc/$WEB_SYSTEM/mods-enabled/rpaf.conf"
726-
file_hash=$(cat $a2_rpaf |md5sum |cut -d" " -f1)
727-
assert_equal "$file_hash" "$a2_rpaf_hash"
728-
fi
729-
if [ ! -z "$a2_remoteip_hash" ]; then
730-
local a2_remoteip="/etc/$WEB_SYSTEM/mods-enabled/remoteip.conf"
731-
file_hash=$(cat $a2_remoteip |md5sum |cut -d" " -f1)
732-
assert_equal "$file_hash" "$a2_remoteip_hash"
733-
fi
731+
if [ -n "$PROXY_SYSTEM" ]; then
732+
assert_file_not_exist /etc/$PROXY_SYSTEM/conf.d/$ip.conf
733+
fi
734+
735+
# remoteip and rpaf config hashes must match the initial one
736+
if [ ! -z "$a2_rpaf_hash" ]; then
737+
local a2_rpaf="/etc/$WEB_SYSTEM/mods-enabled/rpaf.conf"
738+
file_hash=$(cat $a2_rpaf |md5sum |cut -d" " -f1)
739+
assert_equal "$file_hash" "$a2_rpaf_hash"
740+
fi
741+
if [ ! -z "$a2_remoteip_hash" ]; then
742+
local a2_remoteip="/etc/$WEB_SYSTEM/mods-enabled/remoteip.conf"
743+
file_hash=$(cat $a2_remoteip |md5sum |cut -d" " -f1)
744+
assert_equal "$file_hash" "$a2_remoteip_hash"
745+
fi
734746
}
735747

736748
@test "Ip: Add IP for rest of the test" {

0 commit comments

Comments
 (0)