#!/bin/sh
#
# Copyright (C) 2000-2021 Kern Sibbald
# Copyright (C) 2021-2026 Bacula Systems SA
# License: BSD 2-Clause; see file LICENSE-FOSS
#
# Run a couple of tests with bconsole and console ACL with Tenant
#
TestName="tenant-test"
JobName=backup
. scripts/functions

scripts/cleanup
scripts/copy-test-confs

#
# Zap out any schedule in default conf file so that
#  it doesn't start during our test
#
outf="$tmp/sed_tmp"
echo "s%  Schedule =%# Schedule =%g" >${outf}
cp $scripts/bacula-dir.conf $tmp/1
sed -f ${outf} $tmp/1 >$scripts/bacula-dir.conf

echo "$cwd/build/po" > $tmp/file-list

export JobName HOST tmp conf
change_jobname NightlySave $JobName

$bperl -e 'add_attribute("$conf/bacula-dir.conf", "Autoprune", "no", "Director")'

FORCE_TENANT=1 $rscripts/setup_rconsole

start_test

cat <<EOF > $tmp/bconcmds
@output /dev/null
messages
@$out $tmp/log1.out
label volume=T1:VOL1 pool=T1:P1 storage=T1:S1 slot=0 index=0 yes
run job=T1:J1 yes
wait
messages
status tenant=T1
status tenant
1
status
6
1
.api 2 api_opts=j
status tenant=T1
quit
EOF

# start the director
run_bacula

stop_bacula
end_test
