aboutsummaryrefslogtreecommitdiff
path: root/perl/t/general/config.t
diff options
context:
space:
mode:
authorRuss Allbery <eagle@eyrie.org>2014-07-16 13:43:17 -0700
committerRuss Allbery <eagle@eyrie.org>2014-07-16 13:43:17 -0700
commit6409733ee3b7b1910dc1c166a392cc628834146c (patch)
treee9460f8f2ca0f3676afeed2a9dcf549acfc39b53 /perl/t/general/config.t
parent334ed844cbb5c8f7ea82a94c701a3016dd6950b9 (diff)
parentf8963ceb19cd2b503b981f43a3f8c0f45649989f (diff)
Imported Upstream version 1.1
Diffstat (limited to 'perl/t/general/config.t')
-rwxr-xr-xperl/t/general/config.t47
1 files changed, 47 insertions, 0 deletions
diff --git a/perl/t/general/config.t b/perl/t/general/config.t
new file mode 100755
index 0000000..bc200de
--- /dev/null
+++ b/perl/t/general/config.t
@@ -0,0 +1,47 @@
+#!/usr/bin/perl
+#
+# Tests for the wallet server configuration.
+#
+# Written by Russ Allbery <eagle@eyrie.org>
+# Copyright 2008, 2010, 2014
+# The Board of Trustees of the Leland Stanford Junior University
+#
+# See LICENSE for licensing terms.
+
+use strict;
+use warnings;
+
+use Test::More tests => 6;
+
+# Silence warnings since we're not using use.
+package Wallet::Config;
+our $DB_DRIVER;
+our $KEYTAB_AFS_KASETKEY;
+our $KEYTAB_FLAGS;
+our $KEYTAB_KADMIN;
+package main;
+
+# Load with a nonexistent file.
+$ENV{WALLET_CONFIG} = '/path/to/nonexistent/file';
+eval { require Wallet::Config };
+is ($@, '', 'Loading Wallet::Config with nonexistent config file works');
+is ($Wallet::Config::KEYTAB_FLAGS, '-clearpolicy',
+ ' and KEYTAB_FLAGS is correct');
+is ($Wallet::Config::KEYTAB_KADMIN, 'kadmin',
+ ' and KEYTAB_KADMIN is correct');
+is ($Wallet::Config::DB_DRIVER, undef, ' and DB_DRIVER is unset');
+
+# Create a configuration file with a single setting.
+open (CONFIG, '>', 'test-wallet.conf')
+ or die "$0: cannot create test-wallet.conf: $!\n";
+print CONFIG '$DB_DRIVER = "mysql";', "\n";
+print CONFIG "1;\n";
+close CONFIG;
+$ENV{WALLET_CONFIG} = './test-wallet.conf';
+
+# Reload the module and be sure it picks up that configuration file.
+delete $INC{'Wallet/Config.pm'};
+eval { require Wallet::Config };
+is ($@, '', 'Loading Wallet::Config with new config file works');
+is ($Wallet::Config::DB_DRIVER, 'mysql', ' and now DB_DRIVER is set');
+unlink 'test-wallet.conf';