Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
r8 committed May 31, 2016
2 parents ccbe6f7 + 2b50e9d commit 4022494
Show file tree
Hide file tree
Showing 9 changed files with 181 additions and 21 deletions.
20 changes: 17 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,18 @@
0.1.0 (2015-03-23)
------------------
# Change Log

* Initial release
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).

## [0.2.0] - (2016-05-31)
### Changed
- Update github url to use https [[daohoangson](https://github.com/daohoangson)]
- Set runit dependency to version 1.7.4 [[levitin](https://github.com/levitin)]

### Added
- Create spec tests [[levitin](https://github.com/levitin)]
- Extend mailhog configuration with command line options [[levitin](https://github.com/levitin)]
- Extend readme documentation with command line options [[levitin](https://github.com/levitin)]

## [0.1.0] - (2015-03-23)

- Initial release
7 changes: 3 additions & 4 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
source "https://rubygems.org"

gem "berkshelf"
gem "stove", "~> 3.0.0"
source 'https://rubygems.org'

gem 'berkshelf'
gem 'stove', '~> 4.0.0'
1 change: 1 addition & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
Copyright (c) 2015 Sergey Storchay
Modified 2016 Gleb Levitin, dkd Internet Service GmbH

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
44 changes: 43 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,53 @@

This cookbook installs [MailHog](https://github.com/mailhog/MailHog).

Attributes
-----

This cookbook contains the following attributes:

| Key | Type | Default | Description |
|--------------------------------------------------|---------|-------------------------------------------------------------------|------------------------------------------------------------------------------|
| ['mailhog']['version'] | String | 0.2.0 | Version of the MailHog to install |
| ['mailhog']['install_method'] | String | binary | MailHog install method |
| ['mailhog']['binary']['url'] | String | nil | MailHog binary url |
| ['mailhog']['binary']['mode'] | Integer | 0755 | Access permissions to the MailHog binary file |
| ['mailhog']['binary']['path'] | String | /usr/local/bin/MailHog | Location of the MailHog binary file |
| ['mailhog']['binary']['prefix_url'] | String | https://github.com/mailhog/MailHog/releases/download/v | MailHog binary prefix url |
| ['mailhog']['binary']['checksum']['linux_386'] | String | a72d1016b70964562c8a77a3b57637a77889ee61f3b22973e0a7beb17181d8da | MailHog binary file checksum for linux_386 |
| ['mailhog']['binary']['checksum']['linux_amd64'] | String | e8e9acb4fa4470f4d4c3a4bba312f335bfc28122ea723599531699f099b4c9a5 | MailHog binary file checksum for linux_amd64 |
| ['mailhog']['service']['owner'] | String | root | User that should own the mailhog service |
| ['mailhog']['service']['group'] | String | root | Group that should own the mailhog service |
| ['mailhog']['smtp']['ip'] | String | 0.0.0.0 | Interface for SMTP server to bind to |
| ['mailhog']['smtp']['port'] | Integer | 1025 | Port for SMTP server to bind to |
| ['mailhog']['smtp']['outgoing'] | String | nil | JSON file defining outgoing SMTP servers |
| ['mailhog']['api']['ip'] | String | 0.0.0.0 | Interface for HTTP API server to bind to |
| ['mailhog']['api']['port'] | Integer | 8025 | Port for HTTP API server to bind to |
| ['mailhog']['ui']['ip'] | String | 0.0.0.0 | Interface for HTTP UI server to bind to |
| ['mailhog']['ui']['port'] | Integer | 8025 | Port for HTTP UI server to bind to |
| ['mailhog']['cors-origin'] | String | nil | If set, a Access-Control-Allow-Origin header is returned for API endpoints |
| ['mailhog']['hostname'] | String | mailhog.example | Hostname to use for EHLO/HELO and message IDs |
| ['mailhog']['storage'] | String | memory | Set message storage: memory / mongodb / maildir |
| ['mailhog']['mongodb']['ip'] | String | 127.0.0.1 | Host for MongoDB |
| ['mailhog']['mongodb']['port'] | Integer | 27017 | Port for MongoDB |
| ['mailhog']['mongodb']['db'] | String | mailhog | MongoDB database name for message storage |
| ['mailhog']['mongodb']['collection'] | String | messages | MongoDB collection name for message storage |
| ['mailhog']['jim']['enable'] | Boolean | false | Set to true to enable Jim |
| ['mailhog']['jim']['accept'] | Float | 0.99 | Chance of accepting an incoming connection |
| ['mailhog']['jim']['disconnect'] | Float | 0.005 | Chance of randomly disconnecting a session |
| ['mailhog']['jim']['linkspeed']['affect'] | Float | 0.1 | Chance of applying a rate limit |
| ['mailhog']['jim']['linkspeed']['max'] | Integer | 10240 | Maximum link speed (in bytes per second) |
| ['mailhog']['jim']['linkspeed']['min'] | Integer | 1024 | Minimum link speed (in bytes per second) |
| ['mailhog']['jim']['reject']['auth'] | Float | 0.05 | Chance of rejecting an AUTH command |
| ['mailhog']['jim']['reject']['recipient'] | Float | 0.05 | Chance of rejecting a RCPT TO command |
| ['mailhog']['jim']['reject']['sender'] | Float | 0.05 | Chance of rejecting a MAIL FROM command |

Usage
-----

Include the mailhog recipe to install MailHog on your system:
```chef
include_recipe "mailhog"
include_recipe "mailhog::default"
```

MailHog service is installed and managed via `runit`.
Expand All @@ -33,6 +74,7 @@ License
-------

Copyright (c) 2015 Sergey Storchay, http://r8.com.ua
Modified 2016 Gleb Levitin, dkd Internet Service GmbH

Licensed under MIT:
http://raw.github.com/r8/chef-mailhog/master/LICENSE
40 changes: 36 additions & 4 deletions attributes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# Recipe:: default
#
# Copyright (c) 2015 Sergey Storchay, All Rights Reserved.
# Modified 2016 Gleb Levitin, dkd Internet Service GmbH
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
Expand All @@ -23,14 +24,45 @@
# SOFTWARE.
#

default['mailhog']['version'] = '0.1.6'
default['mailhog']['version'] = '0.2.0'
default['mailhog']['install_method'] = 'binary'

default['mailhog']['binary']['url'] = nil # Set it to override automatical generation

default['mailhog']['binary']['mode'] = 0755
default['mailhog']['binary']['path'] = '/usr/local/bin/MailHog'

default['mailhog']['binary']['prefix_url'] = 'http://github.com/mailhog/MailHog/releases/download/v'
default['mailhog']['binary']['checksum']['linux_386'] = 'a72d1016b70964562c8a77a3b57637a77889ee61f3b22973e0a7beb17181d8da'
default['mailhog']['binary']['checksum']['linux_amd64'] = 'e8e9acb4fa4470f4d4c3a4bba312f335bfc28122ea723599531699f099b4c9a5'
default['mailhog']['binary']['prefix_url'] = 'https://github.com/mailhog/MailHog/releases/download/v'
default['mailhog']['binary']['checksum']['linux_386'] = '06fc1d7bf2fced86962ab274d8f1e6c7df74a6ec3c6310aff26792bb93122d98'
default['mailhog']['binary']['checksum']['linux_amd64'] = '11aaae19388d0a6543c935188fcc4157772d852c10be2a5d96168ee23ae6845f'

default['mailhog']['service']['owner'] = 'root'
default['mailhog']['service']['group'] = 'root'

default['mailhog']['smtp']['ip'] = '127.0.0.1'
default['mailhog']['smtp']['port'] = 1025
default['mailhog']['smtp']['outgoing'] = nil

default['mailhog']['api']['ip'] = '0.0.0.0'
default['mailhog']['api']['port'] = 8025
default['mailhog']['ui']['ip'] = '0.0.0.0'
default['mailhog']['ui']['port'] = 8025

default['mailhog']['cors-origin'] = nil
default['mailhog']['hostname'] = 'mailhog.example'

default['mailhog']['storage'] = 'memory'
default['mailhog']['mongodb']['ip'] = '127.0.0.1'
default['mailhog']['mongodb']['port'] = 27017
default['mailhog']['mongodb']['db'] = 'mailhog'
default['mailhog']['mongodb']['collection'] = 'messages'

default['mailhog']['jim']['enable'] = false
default['mailhog']['jim']['accept'] = 0.99
default['mailhog']['jim']['disconnect'] = 0.005
default['mailhog']['jim']['linkspeed']['affect'] = 0.1
default['mailhog']['jim']['linkspeed']['max'] = 10240
default['mailhog']['jim']['linkspeed']['min'] = 1024
default['mailhog']['jim']['reject']['auth'] = 0.05
default['mailhog']['jim']['reject']['recipient'] = 0.05
default['mailhog']['jim']['reject']['sender'] = 0.05
4 changes: 2 additions & 2 deletions metadata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
maintainer_email 'r8@r8.com.ua'
license 'MIT'
description 'Installs/Configures mailhog'
version '0.1.0'
version '0.2.0'

depends 'runit', '>= 0.0.0'
depends 'runit', '= 1.7.4'

%w(debian ubuntu centos redhat smartos).each do |os|
supports os, '>= 0.0.0'
Expand Down
31 changes: 30 additions & 1 deletion recipes/binary.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# Recipe:: default
#
# Copyright (c) 2015 Sergey Storchay, All Rights Reserved.
# Modified 2016 Gleb Levitin, dkd Internet Service GmbH
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
Expand All @@ -23,7 +24,7 @@
# SOFTWARE.
#

include_recipe 'runit'
include_recipe 'runit::default'

arch = node['kernel']['machine'] =~ /x86_64/ ? 'amd64' : '386'

Expand All @@ -45,5 +46,33 @@

# Setup runit service
runit_service 'mailhog' do
options({
:smtp_ip => node['mailhog']['smtp']['ip'],
:smtp_port => node['mailhog']['smtp']['port'],
:smtp_outgoing => node['mailhog']['smtp']['outgoing'],
:ui_ip => node['mailhog']['ui']['ip'],
:ui_port => node['mailhog']['ui']['port'],
:api_ip => node['mailhog']['api']['ip'],
:api_port => node['mailhog']['api']['port'],
:cors_origin => node['mailhog']['cors-origin'],
:hostname => node['mailhog']['hostname'],
:storage => node['mailhog']['storage'],
:mongodb_ip => node['mailhog']['mongodb']['ip'],
:mongodb_port => node['mailhog']['mongodb']['port'],
:mongodb_db => node['mailhog']['mongodb']['db'],
:mongodb_collection => node['mailhog']['mongodb']['collection'],
:jim_enable => node['mailhog']['jim']['enable'],
:jim_accept => node['mailhog']['jim']['accept'],
:jim_disconnect => node['mailhog']['jim']['disconnect'],
:jim_linkspeed_affect => node['mailhog']['jim']['linkspeed']['affect'],
:jim_linkspeed_max => node['mailhog']['jim']['linkspeed']['max'],
:jim_linkspeed_min => node['mailhog']['jim']['linkspeed']['min'],
:jim_reject_auth => node['mailhog']['jim']['reject']['auth'],
:jim_reject_recipient => node['mailhog']['jim']['reject']['recipient'],
:jim_reject_sender => node['mailhog']['jim']['reject']['sender']
})
default_logger true
owner node['mailhog']['service']['owner']
group node['mailhog']['service']['group']
action [:enable, :restart]
end
23 changes: 22 additions & 1 deletion templates/default/sv-mailhog-run.erb
Original file line number Diff line number Diff line change
@@ -1,3 +1,24 @@
#!/bin/sh
exec 2>&1
exec /usr/bin/env MailHog
exec /usr/bin/env MailHog \
-smtp-bind-addr=<%= @options[:smtp_ip] %>:<%= @options[:smtp_port] %> \
-outgoing-smtp=<%= @options[:smtp_outgoing] %> \
-ui-bind-addr=<%= @options[:ui_ip] %>:<%= @options[:ui_port] %> \
-api-bind-addr=<%= @options[:api_ip] %>:<%= @options[:api_port] %> \
-cors-origin=<%= @options[:cors_origin] %> \
-hostname=<%= @options[:hostname] %> \
-storage=<%= @options[:storage] %> \
-mongo-uri=<%= @options[:mongodb_ip] %>:<%= @options[:mongodb_port] %> \
-mongo-db=<%= @options[:mongodb_db] %> \
-mongo-coll=<%= @options[:mongodb_collection] %> \
<% if @options[:jim_enable] %>
-invite-jim \
<% end %>
-jim-accept=<%= @options[:jim_accept] %> \
-jim-disconnect=<%= @options[:jim_disconnect] %> \
-jim-linkspeed-affect=<%= @options[:jim_linkspeed_affect] %> \
-jim-linkspeed-max=<%= @options[:jim_linkspeed_max] %> \
-jim-linkspeed-min=<%= @options[:jim_linkspeed_min] %> \
-jim-reject-auth=<%= @options[:jim_reject_auth] %> \
-jim-reject-recipient=<%= @options[:jim_reject_recipient] %> \
-jim-reject-sender=<%= @options[:jim_reject_sender] %>
32 changes: 27 additions & 5 deletions test/integration/default/serverspec/default_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,33 @@

describe 'mailhog::default' do

# Serverspec examples can be found at
# http://serverspec.org/resource_types.html

it 'does something' do
skip 'Replace this with meaningful tests'
describe file('/usr/local/bin/MailHog') do
it { should exist }
it { should be_file }
it { should be_mode 755 }
it { should be_owned_by 'root' }
it { should be_grouped_into 'root' }
end

describe file('/etc/service/mailhog/run') do
it { should exist }
it { should be_file }
it { should be_mode 755 }
it { should be_owned_by 'root' }
it { should be_grouped_into 'root' }
end

describe service('mailhog') do
it { should be_running }
end

describe port(1025) do
it { should be_listening.on('127.0.0.1').with('tcp') }
end

describe port(8025) do
#see: https://github.com/mailhog/MailHog/issues/87
it { should be_listening.on('::').with('tcp6') }
end

end

0 comments on commit 4022494

Please sign in to comment.