From c3d89b5da74b7f9eadd89242150b4d7c3b758212 Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Tue, 3 Nov 2015 11:39:16 -0500 Subject: [PATCH] Rename mail_root to dovecot_mail_root for consistency. --- lib/common/configuration.rb | 45 +++++++++++++++++------------------ lib/common/dovecot_plugin.rb | 2 +- mailshears.example.conf.yml | 3 +-- test/mailshears.test.conf.yml | 3 +-- test/mailshears_test.rb | 15 +++++------- test/test_rm.rb | 6 ++--- 6 files changed, 33 insertions(+), 41 deletions(-) diff --git a/lib/common/configuration.rb b/lib/common/configuration.rb index c9bf9ea..caeab92 100644 --- a/lib/common/configuration.rb +++ b/lib/common/configuration.rb @@ -40,30 +40,11 @@ class Configuration d = {} d['i_mean_business'] = false - - d['postfixadmin_dbhost'] = 'localhost' - d['postfixadmin_dbport'] = 5432 - d['postfixadmin_dbopts'] = '' - d['postfixadmin_dbtty'] = '' - d['postfixadmin_dbuser'] = 'postgres' - d['postfixadmin_dbpass'] = '' - d['postfixadmin_dbname'] = 'postfixadmin' - - d['plugins'] = ['postfixadmin', + d['plugins'] = ['agendav', + 'davical', 'dovecot', - 'roundcube', - 'agendav', - 'davical'] - - d['mail_root'] = '/var/spool/mail/vhosts' - - d['roundcube_dbhost'] = 'localhost' - d['roundcube_dbport'] = 5432 - d['roundcube_dbopts'] = '' - d['roundcube_dbtty'] = '' - d['roundcube_dbuser'] = 'postgres' - d['roundcube_dbpass'] = '' - d['roundcube_dbname'] = 'roundcube' + 'postfixadmin', + 'roundcube'] d['agendav_dbhost'] = 'localhost' d['agendav_dbport'] = 5432 @@ -81,6 +62,24 @@ class Configuration d['davical_dbpass'] = '' d['davical_dbname'] = 'davical' + d['dovecot_mail_root'] = '/var/spool/mail/vhosts' + + d['postfixadmin_dbhost'] = 'localhost' + d['postfixadmin_dbport'] = 5432 + d['postfixadmin_dbopts'] = '' + d['postfixadmin_dbtty'] = '' + d['postfixadmin_dbuser'] = 'postgres' + d['postfixadmin_dbpass'] = '' + d['postfixadmin_dbname'] = 'postfixadmin' + + d['roundcube_dbhost'] = 'localhost' + d['roundcube_dbport'] = 5432 + d['roundcube_dbopts'] = '' + d['roundcube_dbtty'] = '' + d['roundcube_dbuser'] = 'postgres' + d['roundcube_dbpass'] = '' + d['roundcube_dbname'] = 'roundcube' + return d end diff --git a/lib/common/dovecot_plugin.rb b/lib/common/dovecot_plugin.rb index bc6166d..fa61d53 100644 --- a/lib/common/dovecot_plugin.rb +++ b/lib/common/dovecot_plugin.rb @@ -10,7 +10,7 @@ module DovecotPlugin include Plugin def initialize(cfg) - @domain_root = cfg.mail_root + @domain_root = cfg.dovecot_mail_root end def describe_domain(domain) diff --git a/mailshears.example.conf.yml b/mailshears.example.conf.yml index 03c3440..0764153 100644 --- a/mailshears.example.conf.yml +++ b/mailshears.example.conf.yml @@ -17,8 +17,7 @@ davical_dbuser: postgres davical_dbpass: davical_dbname: davical -# dovecot -mail_root: /var/spool/mail/vhosts +dovecot_mail_root: /var/spool/mail/vhosts postfixadmin_dbhost: localhost postfixadmin_dbport: 5432 diff --git a/test/mailshears.test.conf.yml b/test/mailshears.test.conf.yml index e254da5..0bfbd7f 100644 --- a/test/mailshears.test.conf.yml +++ b/test/mailshears.test.conf.yml @@ -17,8 +17,7 @@ davical_dbuser: postgres davical_dbpass: davical_dbname: davical_test -# dovecot -mail_root: /tmp/mailshears-test +dovecot_mail_root: /tmp/mailshears-test postfixadmin_dbhost: localhost postfixadmin_dbport: 5432 diff --git a/test/mailshears_test.rb b/test/mailshears_test.rb index 483c587..aea8dfc 100644 --- a/test/mailshears_test.rb +++ b/test/mailshears_test.rb @@ -17,8 +17,7 @@ class MailshearsTest < MiniTest::Unit::TestCase # Check if the given mail directory of the form "example.com/user" # exists. cfg = configuration() - mail_root = cfg.send('mail_root') - return File.directory?("#{mail_root}/#{dir}") + return File.directory?("#{cfg.dovecot_mail_root()}/#{dir}") end def connect_superuser() @@ -177,11 +176,10 @@ class MailshearsTest < MiniTest::Unit::TestCase cfg = configuration() # First create the "mail directories". - mail_root = cfg.send('mail_root') - FileUtils.mkdir_p("#{mail_root}/example.com/alice") - FileUtils.mkdir_p("#{mail_root}/example.com/booger") - FileUtils.mkdir_p("#{mail_root}/example.com/jeremy") - FileUtils.mkdir_p("#{mail_root}/example.net/adam") + FileUtils.mkdir_p("#{cfg.dovecot_mail_root()}/example.com/alice") + FileUtils.mkdir_p("#{cfg.dovecot_mail_root()}/example.com/booger") + FileUtils.mkdir_p("#{cfg.dovecot_mail_root()}/example.com/jeremy") + FileUtils.mkdir_p("#{cfg.dovecot_mail_root()}/example.net/adam") # Now the databases and their content. connection = connect_superuser() @@ -233,8 +231,7 @@ class MailshearsTest < MiniTest::Unit::TestCase connection.close() # Get rid of the maildirs. - mail_root = cfg.send('mail_root') - FileUtils.rm_r(mail_root) + FileUtils.rm_r(cfg.dovecot_mail_root()) end end diff --git a/test/test_rm.rb b/test/test_rm.rb index 09ebe2e..fbb14f9 100644 --- a/test/test_rm.rb +++ b/test/test_rm.rb @@ -26,12 +26,11 @@ class TestRm < MailshearsTest actual = output_buffer.string() - mail_root = cfg.send('mail_root') expected = "AgendavRm - Removed user adam@example.net.\n" + "DavicalRm - User adam@example.net not found.\n" + "DovecotRm - Removed user adam@example.net " + - "(#{mail_root}/example.net/adam).\n" + + "(#{cfg.dovecot_mail_root}/example.net/adam).\n" + "PostfixadminRm - Removed user adam@example.net.\n" + "RoundcubeRm - Removed user adam@example.net (User ID: 2).\n" @@ -97,12 +96,11 @@ class TestRm < MailshearsTest actual = output_buffer.string() - mail_root = cfg.send('mail_root') expected = "AgendavRm - Removed domain example.net.\n" + "DavicalRm - Domain example.net not found.\n" + "DovecotRm - Removed domain example.net " + - "(#{mail_root}/example.net).\n" + + "(#{cfg.dovecot_mail_root}/example.net).\n" + "PostfixadminRm - Removed domain example.net.\n" + "RoundcubeRm - Removed domain example.net.\n" -- 2.44.2