aboutsummaryrefslogtreecommitdiff
path: root/perl/t/general/config.t
diff options
context:
space:
mode:
authorRuss Allbery <eagle@eyrie.org>2014-07-11 21:39:23 -0700
committerRuss Allbery <rra@stanford.edu>2014-07-11 22:39:05 -0700
commit1575d5c34a2c6235bbf6a5010f8a8c142fe47079 (patch)
tree29e51ed64f28a37530ec0b21fc24b6d20de1d6ca /perl/t/general/config.t
parentda0aba21779529d98436e42323fc12f702390969 (diff)
Switch to Module::Build for the Perl module
The wallet server now requires Perl 5.8 or later (instead of 5.006 in previous versions) and is now built with Module::Build instead of ExtUtils::MakeMaker. This should be transparent to anyone not working with the source code, since Perl 5.8 was released in 2002, but Module::Build is now required to build the wallet server. It is included in some versions of Perl, or can be installed separately from CPAN, distribution packages, or other sources. Also reorganize the test suite to use subdirectories. Change-Id: Id06120ba2bad1ebbfee3d8a48ca2f25869463165 Reviewed-on: https://gerrit.stanford.edu/1530 Reviewed-by: Russ Allbery <rra@stanford.edu> Tested-by: Russ Allbery <rra@stanford.edu>
Diffstat (limited to 'perl/t/general/config.t')
-rwxr-xr-xperl/t/general/config.t44
1 files changed, 44 insertions, 0 deletions
diff --git a/perl/t/general/config.t b/perl/t/general/config.t
new file mode 100755
index 0000000..881f2bd
--- /dev/null
+++ b/perl/t/general/config.t
@@ -0,0 +1,44 @@
+#!/usr/bin/perl -w
+#
+# Tests for the wallet server configuration.
+#
+# Written by Russ Allbery <eagle@eyrie.org>
+# Copyright 2008, 2010
+# The Board of Trustees of the Leland Stanford Junior University
+#
+# See LICENSE for licensing terms.
+
+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';