Skip to content

Commit 719a38c

Browse files
committed
fixed test scripts
1 parent 4b44937 commit 719a38c

File tree

6 files changed

+78
-19
lines changed

6 files changed

+78
-19
lines changed

bin/v_add_cron_job

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ is_object_free 'cron' 'JOB' "$job"
4646

4747
# Concatenating cron string
4848
command=$(echo $command | sed -e "s/'/%quote%/g" -e "s/:/%dots%/g")
49-
str="JOB='$job' MIN='$min' HOUR='$hour' DAY='$day' MONTH='$month WDAY='$wday'"
50-
str="$v_str' CMD='$command' SUSPENDED='no' TIME='$TIME' DATE='$DATE'"
49+
str="JOB='$job' MIN='$min' HOUR='$hour' DAY='$day' MONTH='$month' WDAY='$wday'"
50+
str="$str CMD='$command' SUSPENDED='no' TIME='$TIME' DATE='$DATE'"
5151

5252
# Adding to crontab
5353
echo "$str" >> $VESTA/data/users/$user/cron.conf

bin/v_list_web_domain

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ json_list_domain() {
3131
echo -e "\t\"$value\": {"
3232
else
3333
if [ "$fileds_count" -eq "$i" ]; then
34-
echo -e "\t\t\"${field//$/}\": \"$value\","
35-
else
3634
echo -e "\t\t\"${field//$/}\": \"$value\""
35+
else
36+
echo -e "\t\t\"${field//$/}\": \"$value\","
3737
fi
3838
fi
3939
(( ++i))

bin/v_unsuspend_cron_job

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
# Argument defenition
1313
user=$1
1414
job=$2
15-
restart="$3"
15+
restart="${3-yes}"
1616

1717
# Includes
1818
source $VESTA/conf/vesta.conf

func/shared.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -426,9 +426,9 @@ sync_cron_jobs() {
426426
if [ "$CRON_REPORTS" = 'yes' ]; then
427427
echo "MAILTO=$CONTACT" > /var/spool/cron/$user
428428
fi
429-
while read line ; do
429+
while read line; do
430430
eval $line
431-
if [ "$SUSPENDED" = 'no' ] ; then
431+
if [ "$SUSPENDED" = 'no' ]; then
432432
echo "$MIN $HOUR $DAY $MONTH $WDAY $CMD" |\
433433
sed -e "s/%quote%/'/g" -e "s/%dots%/:/g" |\
434434
>> /var/spool/cron/$user

test/test_actions.sh

Lines changed: 64 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ echo_result() {
3636
}
3737

3838
# Create random username
39-
user="tmp_$(random 4)"
39+
user="testu_$(random 4)"
4040
while [ ! -z "$(grep "^$user:" /etc/passwd)" ]; do
4141
user="tmp_$(random 4)"
4242
done
@@ -45,18 +45,21 @@ done
4545
tmpfile=$(mktemp -p /tmp )
4646

4747

48-
# Add new user
48+
# Add user
4949
cmd="v_add_user $user $user $user@vestacp.com default Super Test"
5050
$cmd > $tmpfile 2>> $tmpfile
5151
echo_result "Adding new user $user" "$?" "$tmpfile" "$cmd"
5252

53+
# Change user password
54+
cmd="v_change_user_password $user t3st_p4ssw0rd"
55+
$cmd > $tmpfile 2>> $tmpfile
56+
echo_result "Changing password" "$?" "$tmpfile" "$cmd"
5357

5458
# Change system shell
5559
cmd="v_change_user_shell $user bash"
5660
$cmd > $tmpfile 2>> $tmpfile
5761
echo_result "Changing system shell to /bin/bash" "$?" "$tmpfile" "$cmd"
5862

59-
6063
# Change name servers
6164
cmd="v_change_user_ns $user ns0.com ns1.com ns2.com ns3.com"
6265
$cmd > $tmpfile 2>> $tmpfile
@@ -103,6 +106,15 @@ else
103106
fi
104107
echo_result "Dublicate cron job check" "$retval" "$tmpfile" "$cmd"
105108

109+
# Add second cron job
110+
cmd="v_add_cron_job $user 2 2 2 2 2 echo 2"
111+
$cmd > $tmpfile 2>> $tmpfile
112+
echo_result "Adding second cron job" "$?" "$tmpfile" "$cmd"
113+
114+
# Rebuild cron jobs
115+
cmd="v_rebuild_cron_jobs $user"
116+
$cmd > $tmpfile 2>> $tmpfile
117+
echo_result "Rebuilding cron jobs" "$?" "$tmpfile" "$cmd"
106118

107119
# List network interfaces
108120
cmd="v_list_sys_interfaces plain"
@@ -113,21 +125,66 @@ else
113125
echo_result "Listing network interfaces" "0" "$tmpfile" "$cmd"
114126
fi
115127

116-
117-
# Add new ip address
128+
# Add ip address
118129
cmd="v_add_sys_ip 198.18.0.123 255.255.255.255 $interface $user"
119130
$cmd > $tmpfile 2>> $tmpfile
120131
echo_result "Adding ip 198.18.0.123" "$?" "$tmpfile" "$cmd"
121132

122-
123133
# Delete ip address
124134
cmd="v_delete_sys_ip 198.18.0.123"
125135
$cmd > $tmpfile 2>> $tmpfile
126136
echo_result "Deleting ip 198.18.0.123" "$?" "$tmpfile" "$cmd"
127137

138+
# Add ip address
139+
cmd="v_add_sys_ip 198.18.0.125 255.255.255.255 $interface $user"
140+
$cmd > $tmpfile 2>> $tmpfile
141+
echo_result "Adding ip 198.18.0.125" "$?" "$tmpfile" "$cmd"
142+
143+
# Add web domain
144+
domain="test-$(random 4).vestacp.com"
145+
cmd="v_add_web_domain $user $domain 198.18.0.125"
146+
$cmd > $tmpfile 2>> $tmpfile
147+
echo_result "Adding web domain $domain on 198.18.0.125" "$?" "$tmpfile" "$cmd"
128148

129-
# Delete new user
149+
# Add web domain alias
150+
cmd="v_add_web_domain_alias $user $domain v3.$domain"
151+
$cmd > $tmpfile 2>> $tmpfile
152+
echo_result "Adding alias v3.$domain" "$?" "$tmpfile" "$cmd"
153+
154+
# Add dns domain
155+
cmd="v_add_dns_domain $user $domain 198.18.0.125"
156+
$cmd > $tmpfile 2>> $tmpfile
157+
echo_result "Adding dns domain $domain" "$?" "$tmpfile" "$cmd"
158+
159+
# Add mail domain
160+
cmd="v_add_mail_domain $user $domain"
161+
$cmd > $tmpfile 2>> $tmpfile
162+
echo_result "Adding mail domain $domain" "$?" "$tmpfile" "$cmd"
163+
164+
# Add mysql database
165+
database=d$(random 4)
166+
cmd="v_add_database $user $database $database dbp4ssw0rd mysql"
167+
$cmd > $tmpfile 2>> $tmpfile
168+
echo_result "Adding mysql database $database" "$?" "$tmpfile" "$cmd"
169+
170+
# Add pgsql database
171+
database=d$(random 4)
172+
cmd="v_add_database $user $database $database dbp4ssw0rd pgsql"
173+
$cmd > $tmpfile 2>> $tmpfile
174+
echo_result "Adding pgsql database $database" "$?" "$tmpfile" "$cmd"
175+
176+
# Rebuild user configs
177+
cmd="v_rebuild_user $user yes"
178+
$cmd > $tmpfile 2>> $tmpfile
179+
echo_result "Rebuilding user config" "$?" "$tmpfile" "$cmd"
180+
181+
# Delete user
130182
cmd="v_delete_user $user"
131183
$cmd > $tmpfile 2>> $tmpfile
132184
echo_result "Deleting user $user" "$?" "$tmpfile" "$cmd"
133185

186+
# Delete ip address
187+
cmd="v_delete_sys_ip 198.18.0.125"
188+
$cmd > $tmpfile 2>> $tmpfile
189+
echo_result "Deleting ip 198.18.0.125" "$?" "$tmpfile" "$cmd"
190+

test/test_json_listing.sh

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,20 @@ V_BIN="$VESTA/bin"
66
V_TEST="$VESTA/test"
77

88
commands='v_list_cron_jobs admin json
9-
v_list_db_bases admin json
10-
v_list_db_base admin admin_read json
11-
v_list_db_host mysql localhost json
12-
v_list_db_hosts mysql json
9+
v_list_databases admin json
10+
v_list_database admin admin_vesta json
11+
v_list_database_server mysql localhost json
12+
v_list_database_servers mysql json
1313
v_list_dns_domains admin json
14+
v_list_mail_domains admin json
1415
v_list_dns_templates json
16+
v_list_mail_domains admin json
1517
v_list_sys_config json
1618
v_list_sys_interfaces json
1719
v_list_sys_ips json
1820
v_list_sys_rrd json
1921
v_list_user admin json
20-
v_list_user_backups vesta json
22+
v_list_user_backups admin json
2123
v_list_user_ips admin json
2224
v_list_user_ns admin json
2325
v_list_user_packages json

0 commit comments

Comments
 (0)