Debian Codegraph @

tests/krenew/errors-t

raw
1 #!/usr/bin/perl -w
2 #
3 # Tests for error handling in krenew.
4 #
5 # Written by Russ Allbery <[email protected]>
6 # Copyright 2021 Russ Allbery <[email protected]>
7 # Copyright 2011-2012
8 # The Board of Trustees of the Leland Stanford Junior University
9 #
10 # SPDX-License-Identifier: MIT
11
12 use Test::More;
13
14 # The full path to the newly-built k5start client.
15 our $KRENEW = "$ENV{C_TAP_BUILD}/../commands/krenew";
16
17 # Load our test utility programs.
18 require "$ENV{C_TAP_SOURCE}/libtest.pl";
19
20 # Don't overwrite the user's ticket cache.
21 $ENV{KRB5CCNAME} = 'krb5cc_test';
22
23 # Test invalid options.
24 our @OPTIONS = (
25 [ [ qw/-H 0/ ], '-H limit argument 0 invalid' ],
26 [ [ qw/-H -1/ ], '-H limit argument -1 invalid' ],
27 [ [ qw/-H 4foo/ ], '-H limit argument 4foo invalid' ],
28 [ [ qw/-K 4foo/ ], '-K interval argument 4foo invalid' ],
29 [ [ qw/-H4 a/ ], '-H option cannot be used with a command' ],
30 [ [ qw/-s/ ], '-s option only makes sense with a command to run' ]
31 );
32
33 # Test plan.
34 plan tests => scalar (@OPTIONS) * 3;
35
36 # Run the invalid option tests.
37 for my $opt (@OPTIONS) {
38 my ($out, $err, $status) = command ($KRENEW, @{ $opt->[0] });
39 is ($status, 1, "krenew @{ $opt->[0] } fails");
40 is ($out, '', ' with no output');
41 is ($err, 'krenew: ' . $opt->[1] . "\n", ' and correct error');
42 }