Dovecot Testing
This package is used to test IMAP and POP client libraries by giving them a consistent mailbox to work with. This simple
to use library lets developers run their test suites locally using Vagrant and on Travis-CI without having to make any
modifications., (*1)
This package can be used for testing libraries in any language. It was originally built to support a PHP library,
Fetch, so there is some extra support for PHP developers already built in. I encourage
everyone to submit feature requests or, even better, pull requests to help make this package more consumable for other
languages., (*2)
Usage
SetupEnvironment.sh
The SetupEnvironment.sh file acts as a wrapper around a number of different scripts. It identifies which of the
systems below it is being asked to control and then takes the appropriate steps to get the environment setup for
testing., (*3)
The optimal way to utilize this script is to integrate it directly into your test suite, typically as bootstrap or
pretest action. This way you can simply call your test suite as normal and will be assured of a completely consistent
environment., (*4)
Server Settings
- Username: testuser
- Password: applesauce
- IMAP: 143
- IMAPS: 993
- POP: 110
- POPS: 995
- Vagrant IP Address: 172.31.1.2
- Travis IP Address: 127.0.0.1
PHP
This package is available via Composer, which makes integrating it into Travis-CI trivial., (*5)
First add the relevant line into your composer configuration:, (*6)
"require-dev": {
"tedivm/dovecottesting": "~1"
},
Then modify your Travis configuration:, (*7)
before_script:
- composer install --dev
- vendor/tedivm/dovecottesting/SetupEnvironment.sh
Vagrant Notes
You'll need to have Vagrant and VirtualBox installed for local
development. Once these packages are installed the only thing left to do is call SetupEnvironment.sh as outlined above., (*8)
The first time you start the environment with Vagrant it may need to download the template box. This can add a few
minutes to the start time of the script but will only need to happen once., (*9)
If an environment does already exist than this script will simply reset it's email back to the original status so the
test can be run again. This process takes just a few seconds., (*10)
The virtual machine will turn itself off 30 minutes after the last time SetupEnvironment.sh was run, which should occur
before every run of your test suite. This keeps the machine running while you're testing so you can have a very quick
turnaround, but also makes sure it isn't left running when not being used., (*11)
Travis CI Notes
Just like with Vagrant, you simply need to run the SetupEnvironment.sh script before running your tests. Getting the
package onto Travis CI can be done through a package manager directly, as with the composer example above, or through
through a wrapper script that pulls it directly from git., (*12)
Adding Additional Emails
This package works by storing a copy of a working Dovecot mail directory and then copying that directory into the test environment. Adding a new email in means sending it to the running instance of Dovecot and then updating the resources directory to make sure those changes stick between uses. This can be done a number of ways., (*13)
The preferred way is to connect a mail client to the running instance of Dovecot, and then using that to transfer the email in. Most mail clients, such as Mail.app, allow drag and drop transfer of emails between accounts. This method is simpliest because it does not require setting up an SMTP server, as it simply reuses an existing "real" account to create the message and then transfers it in. This was the method used to creating the initial set of emails., (*14)
Another option is to enable postfix directly on the Vagrant instance and to use that to recieve messages. This gets a little more complicated because it does require getting a mail server setup and integrated with Dovecot., (*15)
A final method is to email testuser@tedivm.com with the desired message, and then to open an issue here to request it's inclusion. There is obviously a bit of turnaround here, so please attempt to add it in on your own and feel free to issue a pull request to get it included here., (*16)