Rename mail_root to dovecot_mail_root for consistency.
authorMichael Orlitzky <michael@orlitzky.com>
Tue, 3 Nov 2015 16:39:16 +0000 (11:39 -0500)
committerMichael Orlitzky <michael@orlitzky.com>
Tue, 3 Nov 2015 16:39:16 +0000 (11:39 -0500)
lib/common/configuration.rb
lib/common/dovecot_plugin.rb
mailshears.example.conf.yml
test/mailshears.test.conf.yml
test/mailshears_test.rb
test/test_rm.rb

index c9bf9ea3e04fbd5959fee48b3ad361adaf93b02e..caeab92a655a8dd92aa9b4dfa8784b2edc64ff14 100644 (file)
@@ -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
 
index bc6166d6a1716ee7954083fb10460ad00e54b30d..fa61d5367b593d959c1839de143f1f0c767490db 100644 (file)
@@ -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)
index 03c3440ef04b8cf6d42fed922c7920d9245e7bad..0764153c71cdbb7d9ed415990117c13d54af77c3 100644 (file)
@@ -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
index e254da57a6ac270899f40e9271b60dfdfb9c2836..0bfbd7f19f24abb4a714c2f75ba9930290d7da4a 100644 (file)
@@ -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
index 483c587a08d0a7682de79def66096ccfe50d4dac..aea8dfcff8812d0802f55a3edfa16953f0c1b8b1 100644 (file)
@@ -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
index 09ebe2e37c4faefcb5ff68932c92883b6ab6fad8..fbb14f9dbc0b68eca3f452d77e5f18b974a1ded8 100644 (file)
@@ -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"