Imported Upstream version 3.1.0
[debian/amanda] / installcheck / amadmin.pl
1 # Copyright (c) 2009 Zmanda, Inc.  All Rights Reserved.
2 #
3 # This program is free software; you can redistribute it and/or modify it
4 # under the terms of the GNU General Public License version 2 as published
5 # by the Free Software Foundation.
6 #
7 # This program is distributed in the hope that it will be useful, but
8 # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
9 # or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
10 # for more details.
11 #
12 # You should have received a copy of the GNU General Public License along
13 # with this program; if not, write to the Free Software Foundation, Inc.,
14 # 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
15 #
16 # Contact information: Zmanda Inc, 465 S Mathilda Ave, Suite 300
17 # Sunnyvale, CA 94086, USA, or: http://www.zmanda.com
18
19 use Test::More tests => 16;
20
21 use lib "@amperldir@";
22 use Installcheck::Config;
23 use Installcheck::Run qw(run run_err run_get load_vtape vtape_dir);
24 use Amanda::Device qw( :constants );
25 use Amanda::Config qw( :init :getconf );
26 use Amanda::Paths;
27 use Amanda::Debug;
28 use Amanda::Constants;
29 use Amanda::Tapelist;
30
31 my $testconf;
32
33 Amanda::Debug::dbopen("installcheck");
34 Installcheck::log_test_output();
35
36 $testconf = Installcheck::Run::setup();
37 $testconf->add_dle("localhost \"\\\\\\\\windows\\\\share\" installcheck-test");
38 $testconf->add_dle("localhost \"\\\\\\\\windows\\\\share-a\" installcheck-test");
39 $testconf->add_dle("localhost \"\\\\\\\\windows\\\\share-b\" installcheck-test");
40 $testconf->write();
41
42 config_init($CONFIG_INIT_EXPLICIT_NAME, "TESTCONF");
43 my ($cfgerr_level, @cfgerr_errors) = config_errors();
44 if ($cfgerr_level >= $CFGERR_WARNINGS) {
45     config_print_errors();
46     BAIL_OUT("config errors");
47 }
48
49 #Check ARGV argument, extra quoting because of perl.
50 like(run_get('amadmin', 'TESTCONF', 'force', 'localhost', '\\\\\\\\\\\\\\\windows\\\\\\\\share'),
51     qr/Argument '\\\\\\\\\\\\\\\\windows\\\\\\\\share' matches neither a host nor a disk; quoting may not be correct./,
52     "argv 1");
53
54 like(run_get('amadmin', 'TESTCONF', 'force', 'localhost', '\\\\\\\\windows\\\\share'),
55     qr/amadmin: localhost:\\\\windows\\share is set to a forced level 0 at next run./,
56     "argv 2");
57
58 like(run_get('amadmin', 'TESTCONF', 'force', 'localhost', '\\\\windows\\share'),
59     qr/Argument '\\\\windows\\share' matches neither a host nor a disk; quoting may not be correct./,
60     "argv 3");
61
62 like(run_get('amadmin', 'TESTCONF', 'force', 'localhost', '\\windows\share'),
63     qr/Argument '\\windows\\share' matches neither a host nor a disk; quoting may not be correct./,
64     "argv 4");
65
66 #Check sheel quoting, extra quoting because of perl
67 like(run_get('amadmin TESTCONF force localhost \\\\\\\\\\\\\\\\windows\\\\\\\\share'),
68    qr/amadmin: localhost:\\\\windows\\share is set to a forced level 0 at next run./,
69    "shell 1");
70
71 like(run_get('amadmin TESTCONF force localhost "\\\\\\\\\\\\\\\\windows\\\\\\\\share"'),
72    qr/amadmin: localhost:\\\\windows\\share is set to a forced level 0 at next run./,
73    "shell 2");
74
75 like(run_get('amadmin TESTCONF force localhost \'\\\\\\\\\\\\\\\\windows\\\\\\\\share\''),
76    qr/\\\\\\\\\\\\\\\windows\\\\\\\\share' matches neither a host nor a disk; quoting may not be correct./,
77    "shell 3");
78
79 like(run_get('amadmin TESTCONF force localhost \\\\\\\\windows\\\\share'),
80    qr/Argument '\\\\windows\\share' matches neither a host nor a disk; quoting may not be correct./,
81    "shell 4");
82
83 like(run_get('amadmin TESTCONF force localhost "\\\\\\\\windows\\\\share"'),
84    qr/\\\\windows\\share' matches neither a host nor a disk; quoting may not be correct./,
85    "shell 5");
86
87 like(run_get('amadmin TESTCONF force localhost \'\\\\\\\\windows\\\\share\''),
88    qr/amadmin: localhost:\\\\windows\\share is set to a forced level 0 at next run./,
89    "shell 6");
90
91 like(run_get('amadmin TESTCONF force localhost \\\\windows\\share'),
92    qr/Argument '\\windowsshare' matches neither a host nor a disk; quoting may not be correct./,
93    "shell 7");
94
95 like(run_get('amadmin TESTCONF force localhost "\\\\windows\\share"'),
96    qr/Argument '\\windows\\share' matches neither a host nor a disk; quoting may not be correct./,
97    "shell 8");
98
99 like(run_get('amadmin TESTCONF force localhost \'\\\\windows\\share\''),
100    qr/Argument '\\\\windows\\share' matches neither a host nor a disk; quoting may not be correct./,
101    "shell 9");
102
103 like(run_get('amadmin TESTCONF force localhost share'),
104    qr/amadmin: localhost:\\\\windows\\share is set to a forced level 0 at next run./,
105    "shell 10");
106
107 like(run_get('amadmin TESTCONF force localhost windows'),
108    qr/amadmin: localhost:\\\\windows\\share is set to a forced level 0 at next run.
109 amadmin: localhost:\\\\windows\\share-a is set to a forced level 0 at next run.
110 amadmin: localhost:\\\\windows\\share-b is set to a forced level 0 at next run.$/,
111    "shell 11");
112
113 like(run_get('amadmin TESTCONF force localhost share-\*'),
114    qr/amadmin: localhost:\\\\windows\\share-a is set to a forced level 0 at next run.
115 amadmin: localhost:\\\\windows\\share-b is set to a forced level 0 at next run.$/,
116    "shell 12");
117