Imported Upstream version 3.2.0
[debian/amanda] / installcheck / amadmin.pl
1 # Copyright (c) 2009, 2010 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 use strict;
21 use warnings;
22
23 use lib "@amperldir@";
24 use Installcheck::Config;
25 use Installcheck::Run qw(run run_err run_get load_vtape vtape_dir);
26 use Amanda::Device qw( :constants );
27 use Amanda::Config qw( :init :getconf );
28 use Amanda::Paths;
29 use Amanda::Debug;
30 use Amanda::Constants;
31 use Amanda::Tapelist;
32
33 my $testconf;
34
35 Amanda::Debug::dbopen("installcheck");
36 Installcheck::log_test_output();
37
38 $testconf = Installcheck::Run::setup();
39 $testconf->add_dle("localhost \"\\\\\\\\windows\\\\share\" installcheck-test");
40 $testconf->add_dle("localhost \"\\\\\\\\windows\\\\share-a\" installcheck-test");
41 $testconf->add_dle("localhost \"\\\\\\\\windows\\\\share-b\" installcheck-test");
42 $testconf->write();
43
44 config_init($CONFIG_INIT_EXPLICIT_NAME, "TESTCONF");
45 my ($cfgerr_level, @cfgerr_errors) = config_errors();
46 if ($cfgerr_level >= $CFGERR_WARNINGS) {
47     config_print_errors();
48     BAIL_OUT("config errors");
49 }
50
51 #Check ARGV argument, extra quoting because of perl.
52 like(run_get('amadmin', 'TESTCONF', 'force', 'localhost', '\\\\\\\\\\\\\\\windows\\\\\\\\share'),
53     qr/Argument '\\\\\\\\\\\\\\\\windows\\\\\\\\share' matches neither a host nor a disk; quoting may not be correct./,
54     "argv 1");
55
56 like(run_get('amadmin', 'TESTCONF', 'force', 'localhost', '\\\\\\\\windows\\\\share'),
57     qr/amadmin: localhost:\\\\windows\\share is set to a forced level 0 at next run./,
58     "argv 2");
59
60 like(run_get('amadmin', 'TESTCONF', 'force', 'localhost', '\\\\windows\\share'),
61     qr/Argument '\\\\windows\\share' matches neither a host nor a disk; quoting may not be correct./,
62     "argv 3");
63
64 like(run_get('amadmin', 'TESTCONF', 'force', 'localhost', '\\windows\share'),
65     qr/Argument '\\windows\\share' matches neither a host nor a disk; quoting may not be correct./,
66     "argv 4");
67
68 #Check sheel quoting, extra quoting because of perl
69 like(run_get('amadmin TESTCONF force localhost \\\\\\\\\\\\\\\\windows\\\\\\\\share'),
70    qr/amadmin: localhost:\\\\windows\\share is set to a forced level 0 at next run./,
71    "shell 1");
72
73 like(run_get('amadmin TESTCONF force localhost "\\\\\\\\\\\\\\\\windows\\\\\\\\share"'),
74    qr/amadmin: localhost:\\\\windows\\share is set to a forced level 0 at next run./,
75    "shell 2");
76
77 like(run_get('amadmin TESTCONF force localhost \'\\\\\\\\\\\\\\\\windows\\\\\\\\share\''),
78    qr/\\\\\\\\\\\\\\\windows\\\\\\\\share' matches neither a host nor a disk; quoting may not be correct./,
79    "shell 3");
80
81 like(run_get('amadmin TESTCONF force localhost \\\\\\\\windows\\\\share'),
82    qr/Argument '\\\\windows\\share' matches neither a host nor a disk; quoting may not be correct./,
83    "shell 4");
84
85 like(run_get('amadmin TESTCONF force localhost "\\\\\\\\windows\\\\share"'),
86    qr/\\\\windows\\share' matches neither a host nor a disk; quoting may not be correct./,
87    "shell 5");
88
89 like(run_get('amadmin TESTCONF force localhost \'\\\\\\\\windows\\\\share\''),
90    qr/amadmin: localhost:\\\\windows\\share is set to a forced level 0 at next run./,
91    "shell 6");
92
93 like(run_get('amadmin TESTCONF force localhost \\\\windows\\share'),
94    qr/Argument '\\windowsshare' matches neither a host nor a disk; quoting may not be correct./,
95    "shell 7");
96
97 like(run_get('amadmin TESTCONF force localhost "\\\\windows\\share"'),
98    qr/Argument '\\windows\\share' matches neither a host nor a disk; quoting may not be correct./,
99    "shell 8");
100
101 like(run_get('amadmin TESTCONF force localhost \'\\\\windows\\share\''),
102    qr/Argument '\\\\windows\\share' matches neither a host nor a disk; quoting may not be correct./,
103    "shell 9");
104
105 like(run_get('amadmin TESTCONF force localhost share'),
106    qr/amadmin: localhost:\\\\windows\\share is set to a forced level 0 at next run./,
107    "shell 10");
108
109 like(run_get('amadmin TESTCONF force localhost windows'),
110    qr/amadmin: localhost:\\\\windows\\share is set to a forced level 0 at next run.
111 amadmin: localhost:\\\\windows\\share-a is set to a forced level 0 at next run.
112 amadmin: localhost:\\\\windows\\share-b is set to a forced level 0 at next run.$/,
113    "shell 11");
114
115 like(run_get('amadmin TESTCONF force localhost share-\*'),
116    qr/amadmin: localhost:\\\\windows\\share-a is set to a forced level 0 at next run.
117 amadmin: localhost:\\\\windows\\share-b is set to a forced level 0 at next run.$/,
118    "shell 12");
119