Debian Codegraph @

tests/k5start/errors-t

raw
1 #!/usr/bin/perl -w
2 #
3 # Tests for error handling in k5start.
4 #
5 # Written by Russ Allbery <[email protected]>
6 # Copyright 2021 Russ Allbery <[email protected]>
7 # Copyright 2011
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 $K5START = "$ENV{C_TAP_BUILD}/../commands/k5start";
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 -Uf a a/ ], '-H option cannot be used with a command' ]
30 );
31
32 # Test plan.
33 plan tests => scalar (@OPTIONS) * 3;
34
35 # Run the invalid option tests.
36 for my $opt (@OPTIONS) {
37 my ($out, $err, $status) = command ($K5START, @{ $opt->[0] });
38 is ($status, 1, "k5start @{ $opt->[0] } fails");
39 is ($out, '', ' with no output');
40 is ($err, 'k5start: ' . $opt->[1] . "\n", ' and correct error');
41 }