Commit aa9ce4e7 authored by Joanne Hugé's avatar Joanne Hugé

mail-server: add mail-server with dovecot and postfix

parent ee26003f
Pipeline #28149 passed with stage
# Dovecot
# https://doc.dovecot.org/
[buildout]
extends =
../lua/buildout.cfg
../openssl/buildout.cfg
../zlib/buildout.cfg
[dovecot]
recipe = slapos.recipe.cmmi
url = https://dovecot.org/releases/2.3/dovecot-2.3.20.tar.gz
md5sum = b8add62d0311dcc95ac25b379e8ba043
location = @@LOCATION@@
configure-options =
--enable-maintainer-mode
--prefix=${:location}
--exec-prefix=${:location}
--with-systemd=no
--with-lua=yes
--with-libcrypto=${openssl:location}
environment =
PATH=${pkgconfig:location}/bin:%(PATH)s
PKG_CONFIG_PATH=${lua:location}/lib/pkgconfig
LUA_LIBS=-L${lua:location}/lib -Wl,-rpath=${lua:location}/lib -llua -lm
LUA_CFLAGS=-I${lua:location}/include
LDFLAGS=-L${openssl:location}/lib -Wl,-rpath=${openssl:location}/lib -L${zlib:location}/lib -Wl,-rpath=${zlib:location}/lib
make-targets = install
post-install = cp -r ${:location}/share/doc/dovecot/example-config/* ${:location}/etc/dovecot/
...@@ -28,3 +28,27 @@ pc = ...@@ -28,3 +28,27 @@ pc =
Version: $${version} Version: $${version}
Libs: -L$${libdir} -llua Libs: -L$${libdir} -llua
Cflags: -I$${includedir} Cflags: -I$${includedir}
[lua5.2]
recipe = slapos.recipe.cmmi
shared = true
url = http://www.lua.org/ftp/lua-5.2.3.tar.gz
md5sum = dc7f94ec6ff15c985d2d6ad0f1b35654
configure-command = true
make-options =
"$(uname -sr 2>/dev/null|grep -Eq '^Linux' && echo linux || echo posix)"
MYCFLAGS="-I${readline:location}/include -fPIC"
MYLDFLAGS="-L${readline:location}/lib -Wl,-rpath=${readline:location}/lib"
INSTALL_TOP=@@LOCATION@@
post-install =
mkdir -p %(location)s/lib/pkgconfig
{
make pc INSTALL_TOP=%(location)s
echo '%(pc)s'
} > %(location)s/lib/pkgconfig/lua.pc
pc =
Name: Lua
Description: Lua language engine
Version: $${version}
Libs: -L$${libdir} -llua
Cflags: -I$${includedir}
# mail-server
- Local IMAP / SMTP mail server using Dovecot and Postfix
- Runs on port 10143 and 10025
- Designed to be deployed on 4G / 5G base stations such as ORS
# THIS IS NOT A BUILDOUT FILE, despite purposedly using a compatible syntax.
# The only allowed lines here are (regexes):
# - "^#" comments, copied verbatim
# - "^[" section beginings, copied verbatim
# - lines containing an "=" sign which must fit in the following categorie.
# - "^\s*filename\s*=\s*path\s*$" where "path" is relative to this file
# Copied verbatim.
# - "^\s*hashtype\s*=.*" where "hashtype" is one of the values supported
# by the re-generation script.
# Re-generated.
# - other lines are copied verbatim
# Substitution (${...:...}), extension ([buildout] extends = ...) and
# section inheritance (< = ...) are NOT supported (but you should really
# not need these here).
[template]
filename = instance.cfg.in
md5sum = 7ab3b606972e1b338d28fc1374617835
[template-default]
_update_hash_filename_ = instance-default.cfg.in
md5sum = 123a56ab69723d869bc52169fa5d530b
[dovecot.jinja2.conf]
_update_hash_filename_ = dovecot.jinja2.conf
md5sum = a1f695cb881e9be680b7b8a597a4b0c9
[dovecot-passdb.jinja2.lua]
_update_hash_filename_ = dovecot-passdb.jinja2.lua
md5sum = 060107ee6ad0eb9092529bc2bd1ee52f
[postfix_main.jinja2.cf]
_update_hash_filename_ = postfix_main.jinja2.cf
md5sum = e3b2b86282816ac4020154de70cd5074
[postfix_master.jinja2.cf]
_update_hash_filename_ = postfix_master.jinja2.cf
md5sum = 7752a8b4af5c18dc404e0a862af89272
[postfix_vmailbox.jinja2]
_update_hash_filename_ = postfix_vmailbox.jinja2
md5sum = b01eb42fd9cecc1fcc9bad85f463eea6
[postfix_virtual.jinja2]
_update_hash_filename_ = postfix_virtual.jinja2
md5sum = 701c95b5542890034444cf82ecf2a5e3
function auth_passdb_lookup(req)
return dovecot.auth.PASSDB_RESULT_OK, string.format("password=%s", req.password)
end
function script_init()
return 0
end
function script_deinit()
end
function auth_userdb_iterate()
return {"alpha"}
end
protocols = " imap lmtp pop3"
auth_debug = yes
auth_mechanisms = plain login
auth_username_format = %n
auth_verbose = yes
base_dir = {{ directory['run-dovecot'] }}
state_dir = {{directory['var-dovecot'] }}
mail_temp_dir = {{directory['tmp-dovecot'] }}
default_internal_user = {{ slap_configuration['user-name'] }}
default_login_user = {{ slap_configuration['user-name'] }}
default_internal_group = {{ slap_configuration['user-name'] }}
disable_plaintext_auth = no
mail_location = maildir:~/Maildir
mail_debug = yes
service anvil {
chroot =
}
service imap-login {
chroot =
}
service pop3-login {
chroot =
inet_listener pop3 {
port = 10110
}
inet_listener pop3s {
port = 10995
}
}
service imap-login {
inet_listener imap {
port = 10143
}
inet_listener imaps {
port = 10993
}
}
service auth {
unix_listener {{ postfix_auth }} {
mode = 0660
user = {{ slap_configuration['user-name'] }}
group = {{ slap_configuration['user-name'] }}
}
}
service lmtp {
unix_listener {{ postfix_dovecot_lmtp }} {
user = {{ slap_configuration['user-name'] }}
group = {{ slap_configuration['user-name'] }}
mode = 0600
}
}
log_path = {{ directory['log'] }}/dovecot.log
namespace inbox {
inbox = yes
location =
mailbox Drafts {
special_use = \Drafts
}
mailbox Junk {
special_use = \Junk
}
mailbox Sent {
special_use = \Sent
}
mailbox "Sent Messages" {
special_use = \Sent
}
mailbox Trash {
special_use = \Trash
}
prefix =
}
ssl = no
passdb {
driver = lua
args = file={{ dovecot_passdb_lua }} blocking=yes
}
userdb {
driver = static
args = uid={{ slap_configuration['user-name'] }} gid={{ slap_configuration['user-name'] }} home={{ directory['home-dovecot'] }}/%u
}
{
"type": "object",
"$schema": "http://json-schema.org/draft-04/schema",
"title": "Input Parameters",
"properties": {
"dns_sr_url": {
"default": "",
"title": "DNS SR URL",
"description": "URL of the SR running the DNS server",
"type": "string"
}
}
}
{
"$schema": "http://json-schema.org/draft-04/schema#",
"description": "Values returned by mail server",
"properties": {
"imap-port": {
"description": "IMAP port of the dovecot instance",
"type": "integer"
},
"smtp-port": {
"description": "SMTP port of the postfix instance",
"type": "integer"
},
"imap-smtp-ipv6": {
"description": "IPv6 address of the IMAP and SMTP instances",
"type": "string"
},
"domain": {
"description": "Domain of the mail server",
"type": "string"
}
},
"type": "object"
}
{% set part_list = [] -%}
{% macro section(name) %}{% do part_list.append(name) %}{{ name }}{% endmacro -%}
[directory]
recipe = slapos.cookbook:mkdirectory
home = ${buildout:directory}
etc = ${:home}/etc
var = ${:home}/var
bin = ${:home}/bin
usr = ${:home}/usr
tmp = ${:home}/tmp
run = ${:var}/run
libexec = ${:usr}/libexec
run-dovecot = ${:run}/dovecot
var-dovecot = ${:var}/dovecot
tmp-dovecot = ${:tmp}/dovecot
libexec-dovecot = ${:libexec}/dovecot
home-dovecot = ${:home}/dovecot-home
script = ${:etc}/run
service = ${:etc}/service
promise = ${:etc}/promise
log = ${:var}/log
usr-postfix = ${:usr}/postfix
etc-postfix = ${:etc}/postfix
var-log = ${:var}/log
var-lib = ${:var}/lib
var-lib-postfix = ${:var-lib}/postfix
var-spool = ${:var}/spool
var-spool-postfix = ${:var-spool}/postfix
vhosts = ${:home}/vhosts
# Not used at buildout level, presence needed by postfix.
var-spool-postfix-active = ${:var-spool-postfix}/active
var-spool-postfix-bounce = ${:var-spool-postfix}/bounce
var-spool-postfix-corrupt = ${:var-spool-postfix}/corrupt
var-spool-postfix-defer = ${:var-spool-postfix}/defer
var-spool-postfix-deferred = ${:var-spool-postfix}/deferred
var-spool-postfix-flush = ${:var-spool-postfix}/flush
var-spool-postfix-hold = ${:var-spool-postfix}/hold
var-spool-postfix-incoming = ${:var-spool-postfix}/incoming
var-spool-postfix-maildrop = ${:var-spool-postfix}/maildrop
var-spool-postfix-pid = ${:var-spool-postfix}/pid
var-spool-postfix-private = ${:var-spool-postfix}/private
var-spool-postfix-public = ${:var-spool-postfix}/public
var-spool-postfix-saved = ${:var-spool-postfix}/saved
var-spool-postfix-trace = ${:var-spool-postfix}/trace
[slap-configuration]
recipe = slapos.cookbook:slapconfiguration.serialised
computer = {{ slap_connection['computer-id'] }}
partition = {{ slap_connection['partition-id'] }}
url = {{ slap_connection['server-url'] }}
key = {{ slap_connection['key-file'] }}
cert = {{ slap_connection['cert-file'] }}
[config-base]
recipe = slapos.recipe.template:jinja2
extensions = jinja2.ext.do
extra-context =
context =
section directory directory
section slap_configuration slap-configuration
import netaddr netaddr
${:extra-context}
[dovecot-conf]
<= config-base
url = {{ dovecot_conf_template }}
output = ${directory:etc}/dovecot.conf
extra-context =
key dovecot_passdb_lua dovecot-passdb-lua:output
raw postfix_auth ${directory:var-spool-postfix-private}/auth
raw postfix_dovecot_lmtp ${directory:var-spool-postfix-private}/dovecot-lmtp
[dovecot-passdb-lua]
<= config-base
url = {{ dovecot_passdb_lua_template }}
output = ${directory:etc}/dovecot-passdb.lua
[userinfo]
recipe = slapos.cookbook:userinfo
[ethernet-ip]
recipe = slapos.recipe.build
init =
import netifaces
for i in netifaces.interfaces():
if not (i.startswith("slaptun") or i.startswith("re6stnet") or i == "lo"):
a = netifaces.ifaddresses(i)
if netifaces.AF_INET in a:
try:
options['ipv4'] = a[netifaces.AF_INET][0]['addr']
except:
options['ipv4'] = "0.0.0.0"
[{{ section('postmap-virtual') }}]
recipe = plone.recipe.command
stop-on-error = true
command = '${wrapper-postmap:wrapper-path}' '${postfix-virtual:output}'
update-command = ${:command}
[{{ section('postmap-vmailbox') }}]
recipe = plone.recipe.command
stop-on-error = true
command = '${wrapper-postmap:wrapper-path}' '${postfix-vmailbox:output}'
update-command = ${:command}
[postfix-conf-main]
<= config-base
url = {{ postfix_main_template }}
output = ${directory:etc-postfix}/main.cf
extra-context =
key vmailbox_file postfix-vmailbox:output
key virtual_file postfix-virtual:output
key bin_directory directory:bin
key usr_directory directory:usr-postfix
key queue_directory directory:var-spool-postfix
key data_directory directory:var-lib-postfix
key spool_directory directory:var-spool
key vhosts_directory directory:vhosts
key log_directory directory:var-log
key mail_owner userinfo:pw-name
key setgid_group userinfo:gr-name
key ip_address slap-configuration:ipv6-random
key mail_domain request-dns-entry:connection-domain
raw xz_utils_location {{ xz_utils_location }}
raw postfix_location {{ postfix_location }}
[postfix-conf-master]
<= config-base
url = {{ postfix_master_template }}
output = ${directory:etc-postfix}/master.cf
[postfix-vmailbox]
<= config-base
url = {{ postfix_vmailbox_template }}
output = ${directory:etc-postfix}/postfix-vmailbox
extra-context =
raw mail_domain {{ slapparameter_dict.get('mail_domain', '') }}
[postfix-virtual]
<= config-base
url = {{ postfix_virtual_template }}
output = ${directory:etc-postfix}/postfix-virtual
extra-context =
raw mail_domain {{ slapparameter_dict.get('mail_domain', '') }}
[dovecot-wrapper]
recipe = slapos.recipe.template
output = ${directory:bin}/${:_buildout_section_name_}
inline =
#!/bin/sh
{{ dovecot_binary }} -F -c ${dovecot-conf:output}
[dovecot-service]
recipe = slapos.cookbook:wrapper
command-line = ${dovecot-wrapper:output}
wrapper-path = ${directory:service}/dovecot
mode = 0775
pidfile = ${directory:run}/dovecot.pid
hash-files =
${dovecot-conf:output}
${dovecot-wrapper:output}
[postfix-symlinks-libexec]
recipe = slapos.cookbook:symbolic.link
target-directory = ${directory:usr-postfix}
link-binary =
{{ postfix_location }}/usr/libexec
[postfix-wrapper]
recipe = slapos.recipe.template
output = ${directory:bin}/${:_buildout_section_name_}
inline =
#!/bin/sh
${directory:usr-postfix}/libexec/postfix/master -c ${directory:etc-postfix}
[postfix-service]
recipe = slapos.cookbook:wrapper
command-line = ${postfix-wrapper:output}
wrapper-path = ${directory:service}/postfix
mode = 0775
pidfile = ${directory:run}/postfix.pid
environment =
MAIL_CONFIG=${directory:etc-postfix}
hash-files =
${postfix-conf-main:output}
${postfix-wrapper:output}
[publish-connection-parameters]
recipe = slapos.cookbook:publish
<= monitor-publish
imap-port = 10143
smtp-port = 10025
imap-smtp-ipv6 = ${slap-configuration:ipv6-random}
{% if slapparameter_dict.get('dns_sr_url', '') %}
domain = ${request-dns-entry:connection-domain}
{% endif %}
[imap-listen-promise]
<= monitor-promise-base
promise = check_socket_listening
name = imap_listen.py
config-host = ${slap-configuration:ipv6-random}
config-port = 10143
[smtp-listen-promise]
<= monitor-promise-base
promise = check_socket_listening
name = smtp_listen.py
config-host = ${slap-configuration:ipv6-random}
config-port = 10025
[request-dns-entry]
name = dns-mail-entry
recipe = slapos.cookbook:request.serialised
software-url = {{ slapparameter_dict['dns_sr_url'] }}
software-type = core-network
server-url = {{ slap_connection['server-url'] }}
computer-id = {{ slap_connection['computer-id'] }}
partition-id = {{ slap_connection['partition-id'] }}
key-file = {{ slap_connection['key-file'] }}
cert-file = {{ slap_connection['cert-file'] }}
shared = true
sla-computer_guid = {{ slap_connection['computer-id'] }}
config-name = dns-mail-entry
config-subdomain = mail
config-ip = ${slap-configuration:ipv6-random}
return = domain ip
[base-wrapper]
recipe = slapos.cookbook:wrapper
environment =
MAIL_CONFIG=${directory:etc-postfix}
[base-bin-wrapper]
< = base-wrapper
command-line = ${:path}/${:basename}
wrapper-path = ${directory:bin}/${:basename}
[base-bin-bin-wrapper]
< = base-bin-wrapper
path = {{ postfix_location }}/usr/bin
[base-sbin-bin-wrapper]
< = base-bin-wrapper
path = {{ postfix_location }}/usr/sbin
{% for extend, basename_list in (
(
'base-bin-bin-wrapper',
(
'mailq',
'newaliases',
),
),
(
'base-sbin-bin-wrapper',
(
'postcat',
'postconf',
'postdrop',
'postfix',
'postkick',
'postlock',
'postlog',
'postmap',
'postmulti',
'postqueue',
'postsuper',
'sendmail',
),
),
) %}
{% for basename in basename_list -%}
[{{ section('wrapper-' ~ basename) }}]
< = {{ extend }}
basename = {{ basename }}
{% endfor %}
{% endfor %}
[{{ section('service-postfix-master') }}]
< = base-wrapper
command-line = ${directory:usr}/libexec/postfix/master -c ${directory:etc-postfix}
wrapper-path = ${directory:run}/postfix-master
[buildout]
extends =
{{ template_monitor }}
parts =
directory
dovecot-conf
dovecot-service
postfix-conf-main
postfix-conf-master
postfix-service
postfix-symlinks-libexec
monitor-base
publish-connection-parameters
imap-listen-promise
smtp-listen-promise
{{ part_list | join('\n ') }}
{% if slapparameter_dict.get('dns_sr_url', '') %}
request-dns-entry
{% endif %}
eggs-directory = {{ eggs_directory }}
develop-eggs-directory = {{ develop_eggs_directory }}
offline= true
[buildout]
parts =
switch-softwaretype
eggs-directory = ${buildout:eggs-directory}
develop-eggs-directory = ${buildout:develop-eggs-directory}
offline = true
[default-dynamic-template-parameters]
bin-directory = ${buildout:bin-directory}
buildout-bin-directory = ${buildout:bin-directory}
[dynamic-template-default]
recipe = slapos.recipe.template:jinja2
url = ${template-default:target}
filename = instance-default.cfg
output = $${buildout:directory}/$${:filename}
extensions = jinja2.ext.do
context =
key develop_eggs_directory buildout:develop-eggs-directory
key eggs_directory buildout:eggs-directory
key slapparameter_dict slap-configuration:configuration
raw template_monitor ${monitor2-template:output}
raw dovecot_conf_template ${dovecot.jinja2.conf:target}
raw dovecot_passdb_lua_template ${dovecot-passdb.jinja2.lua:target}
raw dovecot_binary ${dovecot:location}/sbin/dovecot
raw postfix_main_template ${postfix_main.jinja2.cf:target}
raw postfix_master_template ${postfix_master.jinja2.cf:target}
raw postfix_virtual_template ${postfix_virtual.jinja2:target}
raw postfix_vmailbox_template ${postfix_vmailbox.jinja2:target}
raw postfix_location ${postfix:location}
raw xz_utils_location ${xz-utils:location}
section slap_connection slap-connection
[slap-configuration]
recipe = slapos.cookbook:slapconfiguration.serialised
computer = $${slap-connection:computer-id}
partition = $${slap-connection:partition-id}
url = $${slap-connection:server-url}
key = $${slap-connection:key-file}
cert = $${slap-connection:cert-file}
[switch-softwaretype]
recipe = slapos.cookbook:switch-softwaretype
default = dynamic-template-default:output
RootSoftwareInstance = $${:default}
# http://www.postfix.org/STANDARD_CONFIGURATION_README.html
# http://www.postfix.org/postconf.5.html
queue_directory = {{ queue_directory }}
command_directory = {{ bin_directory }}
daemon_directory = {{ usr_directory }}/libexec/postfix
data_directory = {{ data_directory }}
mail_spool_directory = {{ spool_directory }}
html_directory = no
manpage_directory = {{ postfix_location }}/usr/local/man
sample_directory = {{ postfix_location }}/etc/postfix
readme_directory = no
sendmail_path = {{ bin_directory }}/sendmail
newaliases_path = {{ bin_directory }}/newaliases
mailq_path = {{ bin_directory }}/mailq
compatibility_level = 3.6
smtputf8_enable = no
mail_owner = {{ mail_owner }}
setgid_group = {{ setgid_group }}
virtual_mailbox_domains = {{ mail_domain }}
virtual_mailbox_base = {{ vhosts_directory }}
virtual_mailbox_maps = hash:{{ vmailbox_file }}
virtual_minimum_uid = 100
virtual_uid_maps = static:1001
virtual_gid_maps = static:1022
virtual_alias_maps = hash:{{ virtual_file }}
virtual_transport = lmtp:unix:private/dovecot-lmtp
inet_interfaces = {{ ip_address }}
inet_protocols = all
smtp_bind_address = 0.0.0.0
smtp_bind_address6 = ::
import_environment =
MAIL_CONFIG MAIL_DEBUG MAIL_LOGTAG TZ LANG=C
smtpd_tls_security_level = none
smtpd_sasl_type = dovecot
smtpd_sasl_path = private/auth
smtpd_sasl_auth_enable = yes
smtpd_recipient_restrictions =
permit_sasl_authenticated
smtpd_relay_restrictions =
permit_sasl_authenticated
defer_unauth_destination
allow_min_user = yes
local_transport = error
maillog_file = {{ log_directory }}/postfix.log
maillog_file_compressor = {{ xz_utils_location }}/bin/xz
maillog_file_prefixes = {{ log_directory }}
# http://www.postfix.org/master.5.html
# ==========================================================================
# service type private unpriv chroot wakeup maxproc command + args
# (yes) (yes) (yes) (never) (100)
# ==========================================================================
10025 inet n - n - - smtpd
pickup unix n - n 60 1 pickup
cleanup unix n - n - 0 cleanup
qmgr unix n - n 300 1 qmgr
tlsmgr unix - - n 1000? 1 tlsmgr
rewrite unix - - n - - trivial-rewrite
bounce unix - - n - 0 bounce
defer unix - - n - 0 bounce
trace unix - - n - 0 bounce
verify unix - - n - 1 verify
flush unix n - n 1000? 0 flush
proxymap unix - - n - - proxymap
proxywrite unix - - n - 1 proxymap
smtp unix - - n - - smtp
relay unix - - n - - smtp
showq unix n - n - - showq
error unix - - n - - error
retry unix - - n - - error
discard unix - - n - - discard
local unix - n n - - local
virtual unix - n n - - virtual
lmtp unix - - n - - lmtp
anvil unix - - n - 1 anvil
scache unix - - n - 1 scache
postlog unix-dgram n - n - 1 postlogd
postmaster@{{ mail_domain }} postmaster
@{{ mail_domain }} {{ mail_domain }}/catchall
[buildout]
extends =
../../component/xz-utils/buildout.cfg
../../component/postfix/buildout.cfg
../../component/dovecot/buildout.cfg
../../stack/monitor/buildout.cfg
../../stack/slapos.cfg
buildout.hash.cfg
parts =
slapos-cookbook
template
dovecot
postfix
[template]
recipe = slapos.recipe.template
url = ${:_profile_base_location_}/${:filename}
output = ${buildout:directory}/template.cfg
[download-base]
recipe = slapos.recipe.build:download
url = ${:_profile_base_location_}/${:_update_hash_filename_}
[template-default]
<= download-base
[copy-to-instance]
recipe = slapos.recipe.build:download
url = ${:_profile_base_location_}/${:_buildout_section_name_}
filename = ${:_buildout_section_name_}
[dovecot.jinja2.conf]
< = copy-to-instance
[dovecot-passdb.jinja2.lua]
< = copy-to-instance
[postfix_main.jinja2.cf]
< = copy-to-instance
[postfix_master.jinja2.cf]
< = copy-to-instance
[postfix_vmailbox.jinja2]
< = copy-to-instance
[postfix_virtual.jinja2]
< = copy-to-instance
{
"name": "Mail Server",
"description": "Mail Server",
"serialisation": "json-in-xml",
"software-type": {
"default": {
"title": "Default",
"software-type": "default",
"request": "instance-default-input-schema.json",
"response": "instance-default-output-schema.json",
"index": 0
}
}
}
Tests for mail-server software release
##############################################################################
#
# Copyright (c) 2018 Nexedi SA and Contributors. All Rights Reserved.
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsibility of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# guarantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 3
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
from setuptools import setup, find_packages
version = '0.0.1.dev0'
name = 'slapos.test.mail_server'
with open("README.md") as f:
long_description = f.read()
setup(
name=name,
version=version,
description="Test for SlapOS' mail-server",
long_description=long_description,
long_description_content_type='text/markdown',
maintainer="Nexedi",
maintainer_email="info@nexedi.com",
url="https://lab.nexedi.com/nexedi/slapos",
packages=find_packages(),
install_requires=[
'slapos.core',
'slapos.libnetworkcache',
'slapos.cookbook',
],
zip_safe=True,
test_suite='test',
)
##############################################################################
#
# Copyright (c) 2018 Nexedi SA and Contributors. All Rights Reserved.
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsibility of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# guarantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 3
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
import os
from slapos.testing.testcase import makeModuleSetUpAndTestCaseClass
setUpModule, MailServerTestCase = makeModuleSetUpAndTestCaseClass(
os.path.abspath(
os.path.join(os.path.dirname(__file__), '..', 'software.cfg')))
param_dict = {
"mail_domain": "mail.local",
}
class TestDefaultInstance(MailServerTestCase):
@classmethod
def getInstanceParameterDict(cls):
return {'_': json.dumps(param_dict)}
@classmethod
def getInstanceSoftwareType(cls):
return "default"
def test_enb_conf(self):
self.slap.waitForInstance()
connection_parameters = self.computer_partition.getConnectionParameterDict()
imap_smtp_ipv6 = connection_parameters['imap-smtp-ipv6']
imap_port = connection_parameters['imap-port']
smtp_port = connection_parameters['smtp-port']
# Check connection parameters are not empty
self.assertTrue(imap_smtp_ipv6)
self.assertTrue(imap_port)
self.assertTrue(smtp_port)
# Check conf contains correct domain
conf_file = glob.glob(os.path.join(
self.slap.instance_directory, '*', 'etc', 'postfix', 'main.cf'))[0]
with open(conf_file, 'r') as f:
domain_configured = False
for line in f:
if line.startswith("virtual_mailbox_domains"):
self.assertEqual(line, "virtual_mailbox_domains = {}\n".format(param_dict['mail_domain']))
domain_configured = True
self.assertTrue(domain_configured)
...@@ -262,6 +262,11 @@ setup = ${slapos-repository:location}/software/js-drone/test/ ...@@ -262,6 +262,11 @@ setup = ${slapos-repository:location}/software/js-drone/test/
egg = slapos.test.osie_coupler egg = slapos.test.osie_coupler
setup = ${slapos-repository:location}/software/osie-coupler/test/ setup = ${slapos-repository:location}/software/osie-coupler/test/
[slapos.test.mail-server-setup]
<= setup-develop-egg
egg = slapos.test.mail-server
setup = ${slapos-repository:location}/software/mail-server/test/
[slapos.core-repository] [slapos.core-repository]
<= git-clone-repository <= git-clone-repository
repository = https://lab.nexedi.com/nexedi/slapos.core.git repository = https://lab.nexedi.com/nexedi/slapos.core.git
...@@ -364,6 +369,7 @@ eggs += ...@@ -364,6 +369,7 @@ eggs +=
${slapos.test.theia-setup:egg} ${slapos.test.theia-setup:egg}
${slapos.test.turnserver-setup:egg} ${slapos.test.turnserver-setup:egg}
${slapos.test.upgrade_erp5-setup:egg} ${slapos.test.upgrade_erp5-setup:egg}
${slapos.test.mail-server-setup:egg}
# We don't name this interpreter `python`, so that when we run slapos node # We don't name this interpreter `python`, so that when we run slapos node
# software, installation scripts running `python` use a python without any # software, installation scripts running `python` use a python without any
...@@ -457,6 +463,7 @@ tests = ...@@ -457,6 +463,7 @@ tests =
theia ${slapos.test.theia-setup:setup} theia ${slapos.test.theia-setup:setup}
turnserver ${slapos.test.turnserver-setup:setup} turnserver ${slapos.test.turnserver-setup:setup}
upgrade_erp5 ${slapos.test.upgrade_erp5-setup:setup} upgrade_erp5 ${slapos.test.upgrade_erp5-setup:setup}
mail-server ${slapos.test.mail-server-setup:setup}
[versions] [versions]
# recurls are under development # recurls are under development
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment