From 96d7a9fbc8fb9648a592bad4cf43f29dc6ccf6d0 Mon Sep 17 00:00:00 2001 From: Russ Allbery Date: Fri, 8 Feb 2008 23:42:40 +0000 Subject: Wallet::Config and hence the wallet server now checks for the environment variable WALLET_CONFIG and loads configuration from the file specified there instead of /etc/wallet/wallet.conf if it is set. --- perl/t/config.t | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100755 perl/t/config.t (limited to 'perl/t') diff --git a/perl/t/config.t b/perl/t/config.t new file mode 100755 index 0000000..0d159dc --- /dev/null +++ b/perl/t/config.t @@ -0,0 +1,46 @@ +#!/usr/bin/perl -w +# $Id$ +# +# t/config.t -- Tests for the wallet server configuration. +# +# Written by Russ Allbery +# Copyright 2008 Board of Trustees, Leland Stanford Jr. University +# +# See LICENSE for licensing terms. + +use Test::More tests => 7; + +# 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::KEYTAB_AFS_KASETKEY, 'kasetkey', + ' and KEYTAB_AFS_KASETKEY 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'; -- cgit v1.2.3