Projects
home:rottame:yggdra_agents
mailserver_agent
Log In
Username
Password
We truncated the diff of some files because they were too big. If you want to see the full diff for every file,
click here
.
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
Expand all
Collapse all
Changes of Revision 8
View file
rubygem-mailserver_agent.changes
Changed
@@ -1,4 +1,9 @@ ------------------------------------------------------------------- +Tue Dec 2 13:32:21 UTC 2025 - Angelo Grossini <rottame@intercom.it> + +- update dependencies + +------------------------------------------------------------------- Thu Jun 6 07:19:57 UTC 2024 - Angelo Grossini <angelo@intercom.it> - fix path in systems service
View file
rubygem-mailserver_agent.spec
Changed
@@ -1,26 +1,30 @@ +%define package_version 1.0.2 %define mod_name mailserver_agent %define mod_full_name %{mod_name}-%{version} Name: rubygem-mailserver_agent -Version: 1.0.1 +Version: %{package_version} Release: 0 Summary: Mailserver DKIM Agent License: Apache-2.0 Group: Development/Languages/Ruby URL: https://intercom.it -Source: %{mod_full_name}.gem -Source1: mailserver_agent.service -Source2: mailserver_agent.tempfiles -Source3: mailserver_agent.yml -Source4: tomte.yml -Source5: mailserver_agent.logrotate -Source6: mailserver_agent.sudoers +Source: https://gems.intercom.it/gems/%{mod_full_name}.gem +Source1: mailserver_agent.logrotate +Source2: mailserver_agent.service +Source3: mailserver_agent.sudoers +Source4: mailserver_agent.tempfiles +Source5: tomte.yml +Source6: mailserver_agent.yml +Source7: gem2rpm.yml BuildRequires: ruby-macros >= 5 BuildRequires: systemd-rpm-macros +BuildRequires: %{ruby >= 1.9} +BuildRequires: %{rubygem gem2rpm} BuildRequires: sudo Requires: amavisd-new -BuildRequires: %{rubygem gem2rpm} -BuildRequires: ruby-macros >= 5 +Requires: sudo +BuildRoot: %{_tmppath}/%{mod_full_name}-build %description Mailserver DKIM agent provisioning agent @@ -38,47 +42,40 @@ %build %install -%gem_install \ - --symlink-binaries \ - -f - +%gem_install -f --symlink-binaries --no-ri --no-rdoc +install -d -m 0644 %{buildroot}%{_localstatedir}/lib/mailserver_agent +install -D -m 0644 %{SOURCE1} %{buildroot}%{_sysconfdir}/logrotate.d/mailserver_agent +install -D -m 0644 %{SOURCE2} %{buildroot}%{_unitdir}/mailserver_agent.service +install -D -m 0644 %{SOURCE3} %{buildroot}%{_sysconfdir}/sudoers.d/mailserver_agent +install -D -m 0644 %{SOURCE4} %{buildroot}%{_tmpfilesdir}/mailserver_agent.conf +install -D -m 0644 %{SOURCE5} %{buildroot}%{_sysconfdir}/mailserver_agent/tomte.yml +install -D -m 0644 %{SOURCE6} %{buildroot}%{_sysconfdir}/mailserver_agent/mailserver_agent.yml install -d %{buildroot}%{_sbindir} -install -d %{buildroot}%{_sysconfdir}/tomte -install -d %{buildroot}%{_localstatedir}/lib/tomte -install -d -m 0755 %{buildroot}%{_sysconfdir}/sudoers.d -install -d -m 0755 %{buildroot}%{_sysconfdir}/logrotate.d - -install -D -m 0644 %{SOURCE1} %{buildroot}%{_unitdir}/mailserver_agent.service -install -D -m 0644 %{SOURCE2} %{buildroot}%{_tmpfilesdir}/mailserver_agent.conf ln -s /usr/sbin/service %{buildroot}%{_sbindir}/rcmailserver_agent -install -D -m 0644 %{SOURCE3} %{buildroot}%{_sysconfdir}/tomte/mailserver_agent.yml -install -D -m 0644 %{SOURCE4} %{buildroot}%{_sysconfdir}/tomte/tomte.yml -install -m 0644 %{SOURCE6} %{buildroot}%{_sysconfdir}/sudoers.d/mailserver_agent -install -m 0644 %{SOURCE5} %{buildroot}%{_sysconfdir}/logrotate.d/mailserver_agent - %gem_packages %files -n mailserver_agent -%dir %{_sysconfdir}/tomte -%attr(0700, tomte, tomte) %dir %{_localstatedir}/lib/tomte - -%config(noreplace) %{_sysconfdir}/tomte/mailserver_agent.yml -%config(noreplace) %{_sysconfdir}/tomte/tomte.yml -%config %{_sysconfdir}/logrotate.d/mailserver_agent +%defattr(-, root, root) +%ghost /run/mailserver_agent +%dir %{_sysconfdir}/mailserver_agent +%config(noreplace) %{_sysconfdir}/mailserver_agent/tomte.yml +%config(noreplace) %{_sysconfdir}/mailserver_agent/mailserver_agent.yml %attr(0440, root, root) %config %{_sysconfdir}/sudoers.d/mailserver_agent +%attr(0440, root, root) %config(noreplace) %{_sysconfdir}/logrotate.d/mailserver_agent + +%attr(0700, dkim_agent, dkim_agent) %dir %{_localstatedir}/lib/mailserver_agent %{_unitdir}/mailserver_agent.service %{_tmpfilesdir}/mailserver_agent.conf %{_sbindir}/rcmailserver_agent -%ghost /run/mailserver_agent %pre -n mailserver_agent -%{_bindir}/getent group tomte >/dev/null || %{_sbindir}/groupadd -r tomte -%{_bindir}/getent passwd tomte >/dev/null || %{_sbindir}/useradd -r -d %{_localstatedir}/lib/tomte -s /bin/false -c "intercom mail policyd" -g tomte tomte +%{_bindir}/getent group dkim_agent >/dev/null || %{_sbindir}/groupadd -r dkim_agent +%{_bindir}/getent passwd dkim_agent >/dev/null || %{_sbindir}/useradd -r -d %{_localstatedir}/lib/mailserver_agent -s /bin/false -c "intercom mail policyd" -g dkim_agent dkim_agent %service_add_pre mailserver_agent.service exit 0 @@ -95,4 +92,4 @@ %service_del_postun mailserver_agent.service exit 0 -%changelog \ No newline at end of file +%changelog
View file
gem2rpm.yml
Added
@@ -0,0 +1,4 @@ +--- +:disable_docs: true +:patches: +:sources: \ No newline at end of file
View file
mailserver_agent-1.0.1.gem/data/.gitignore
Deleted
@@ -1,47 +0,0 @@ -# Documentation -doc -.yardoc -.yardopts - -# Mac -**/.DS_Store - -# Eclipse -*/.project -.project - -# IntelliJ -.idea - -# Redcar -*/.redcar -.redcar - -# Rubinius -*.rbc - -# Backup -*~ -_*.rb - -# build packages -pkg - -config/*.yml - -.bundle -.ruby-gemset - -log/*.log - -vendor - - -tmp - -gems -Dockerfile.dev -asgard-self-signed.pem -.vscode - -rpm_sources
View file
mailserver_agent-1.0.1.gem/data/Makefile
Deleted
@@ -1,57 +0,0 @@ -PHONY: docker-image devel shell install bin-script rpm-src tempfiles - -$(eval VERSION = $(shell grep VERSION lib/mailserver_agent/version.rb | sed -r 's/^.*"(.*?)".*/\1/g')) - -PREFIX ?= /usr -DESTDIR ?= -DOCKERFILE = Dockerfile.dev - -tempfiles: tmp/home Makefile -tmp/home: - mkdir -p tmp/home - touch tmp/home - -docker-image: tempfiles tmp/docker-image -tmp/docker-image: ${DOCKERFILE} - docker build -t mailserver_agent -f ${DOCKERFILE} . || exit 1 - touch tmp/docker-image - -devel: tempfiles docker-image - docker run -ti --rm \ - -v ${PWD}:/mailserver_agent \ - --add-host=asgard.dev.me:172.17.0.1 \ - -v ${PWD}/tmp/home:/home/app \ - -v ${PWD}/../nisse/tomte-agents:/gems/tomte-agents:ro \ - -v ${PWD}/../nisse/tomte-core:/gems/tomte-core:ro \ - -v ${PWD}/../nisse/tomte-protocol:/gems/tomte-protocol:ro \ - -v ${PWD}/../nisse/tomte-resources:/gems/tomte-resources:ro \ - -v ${PWD}/../activeresource-hel/:/gems/activeresource-hel:ro \ - mailserver_agent \ - bundle exec ./bin/mailserver_agent -e development -D - -shell: tempfiles docker-image - docker run -ti --rm \ - -v ${PWD}:/mailserver_agent \ - --add-host=asgard.dev.me:172.17.0.1 \ - -v ${PWD}/tmp/home:/home/app \ - -v ${PWD}/../nisse/tomte-agents:/gems/tomte-agents:ro \ - -v ${PWD}/../nisse/tomte-core:/gems/tomte-core:ro \ - -v ${PWD}/../nisse/tomte-protocol:/gems/tomte-protocol:ro \ - -v ${PWD}/../nisse/tomte-resources:/gems/tomte-resources:ro \ - -v ${PWD}/../activeresource-hel/:/gems/activeresource-hel:ro \ - mailserver_agent \ - bash - -rpm-sources: - rm -f mailserver_agent-*.gem - mkdir -p rpm_sources - gem build mailserver_agent.gemspec - mv mailserver_agent-${VERSION}.gem rpm_sources/ - cp support/mailserver_agent.service rpm_sources/mailserver_agent.service - cp support/mailserver_agent.tempfiles rpm_sources/mailserver_agent.tempfiles - cp support/mailserver_agent.sudoers rpm_sources/mailserver_agent.sudoers - cp support/mailserver_agent.logrotate rpm_sources/mailserver_agent.logrotate - cp config/mailserver_agent.yml.sample rpm_sources/mailserver_agent.yml - cp config/tomte.yml.sample rpm_sources/tomte.yml - cp mailserver_agent.spec.in rpm_sources/rubygem-mailserver_agent.spec - sed -i s/VERSION/${VERSION}/g rpm_sources/rubygem-mailserver_agent.spec \ No newline at end of file
View file
mailserver_agent-1.0.1.gem/data/support/mailserver_agent.service
Deleted
@@ -1,15 +0,0 @@ -Unit -Description=Starts and stops hel mailserver agent - -Service -Type=simple -User=tomte -Group=tomte -PIDFile=/run/mailserver_agent/mailserver_agent.pid -ExecStart=/usr/bin/mailserver_agent --pidfile /run/mailserver_agent/mailserver_agent.pid -e production --no-daemonize -WorkingDirectory=/var/lib/tomte -Restart=always - -Install -WantedBy=multi-user.target -
View file
mailserver_agent-1.0.1.gem/data/test.rb
Deleted
@@ -1,69 +0,0 @@ -# encoding: utf-8 -require "rubygems" -require "amqp" # requires version >= 0.8.0.RC14 - -puts "=> Example of automatic AMQP channel and queues recovery" - -AMQP.start(:host => "localhost") do |connection, open_ok| - connection.on_error do |ch, connection_close| - raise connection_close.reply_text - end - - ch1 = AMQP::Channel.new(connection) - ch1.auto_recovery = true - ch1.on_error do |ch, channel_close| - raise channel_close.reply_text - end - - ch2 = AMQP::Channel.new(connection) - ch2.auto_recovery = true - ch2.on_error do |ch, channel_close| - raise channel_close.reply_text - end - - if ch1.auto_recovering? - puts "Channel #{ch1.id} IS auto-recovering" - end - - if ch2.auto_recovering? - puts "Channel #{ch2.id} IS auto-recovering" - end - - - connection.on_tcp_connection_loss do |conn, settings| - puts "network failure Trying to reconnect..." - conn.reconnect(false, 2) - end - - connection.on_error do |conn, connection_close| - puts "connection.close Reply code = #{connection_close.reply_code}, reply text = #{connection_close.reply_text}" - if connection_close.reply_code == 320 - puts "connection.close Setting up a periodic reconnection timer..." - # every 30 seconds - conn.periodically_reconnect(30) - end - end - - ch1.queue("amqpgem.examples.queue1", :auto_delete => true).bind("amq.fanout") - ch1.queue("amqpgem.examples.queue2", :auto_delete => true).bind("amq.fanout") - ch1.queue("amqpgem.examples.queue3", :auto_delete => true).bind("amq.fanout").subscribe do |metadata, payload| - puts payload - end - - fanout = ch2.fanout("amq.fanout") - - EventMachine::PeriodicTimer.new(2) do - fanout.publish(:hello) - end - - show_stopper = Proc.new { - connection.disconnect { puts "Disconnected. Exiting..."; EventMachine.stop } - } - - Signal.trap "TERM", show_stopper - Signal.trap "INT", show_stopper - EM.add_timer(30, show_stopper) - - - puts "Connected, authenticated. To really exercise this example, shut AMQP broker down for a few seconds. If you don't it will exit gracefully in 30 seconds." -end \ No newline at end of file
View file
mailserver_agent-1.0.1.gem/checksums.yaml.gz -> mailserver_agent-1.0.2.gem/checksums.yaml.gz
Changed
@@ -1,7 +1,7 @@ --- SHA256: - metadata.gz: 509cb9f46c051b68033c9a671e6fa052582e3176005be941b39baff77d53495d - data.tar.gz: d58ac55315769b4002c4236e250c1a5300c3b728fc4d5fe75d67aa045d11a446 + metadata.gz: f5777568ea7081f973af4d9b493c4e83676d0c5185c1f0c1d477aaf6f5c8b836 + data.tar.gz: 51179869b49c3b193631383027a4bc54876634627201e5ebd30bb1d3c7aa706f SHA512: - metadata.gz: 1714c2bcd5ff53dda7296898e2b7ae45dcf7501bb4cda88db491932df50167395e12090a31e6b70f240d62578963a21e4b3c9026bbe63cc0b1ed9d74939f6a3c - data.tar.gz: cfb32b6b0d13c4e8c724fb384c7fbb487be58fb12d420ecbe00897b540631c40950b5ccb53f3d41c980ab5a94cfb0b71ed603d19f6b824e1c2c6cc6ce93aa86b + metadata.gz: 481f4b4a297ea1720178be78e54813a76bf233e7edf17e966171637eb2378a9557f03732e60665c476673ff7bf7206e8a0b377c2c51da9787d57f8cf659328b0 + data.tar.gz: 81b2b6a3f1e216740d15a5a528c81055c0dfcf6947c2b234fddef48b376699f2bea41891d34249b544191001983bdc581aba571c58885853332ea85e08898b13
View file
mailserver_agent-1.0.2.gem/data/Gemfile
Added
@@ -0,0 +1,7 @@ +source "http://rubygems.org" +source 'http://gems.intercom.it/' + +# Specify your gem's dependencies in a.gemspec +gemspec + +gem "ygg_provisioner", path: '../ygg_provisioner'
View file
mailserver_agent-1.0.2.gem/data/Gemfile.lock
Added
@@ -0,0 +1,184 @@ +PATH + remote: ../ygg_provisioner + specs: + ygg_provisioner (1.5.0) + eventmachine (~> 1.2.3) + kyotocabinet + publisher + sqlite3 + tomte-agents + +PATH + remote: . + specs: + mailserver_agent (1.0.1) + activeresource-hel (~> 0.5.0) + activesupport (~> 6.0) + sentry-raven (~> 3) + tomte-agents (~> 1.1, >= 1.1.1) + tomte-core (~> 1.2, >= 1.2.1) + tomte-protocol (~> 1.2, >= 1.2.0) + ygg_provisioner (~> 1.5, >= 1.5.0) + +GEM + remote: http://rubygems.org/ + remote: http://gems.intercom.it/ + specs: + actionview (6.0.6.1) + activesupport (= 6.0.6.1) + builder (~> 3.1) + erubi (~> 1.4) + rails-dom-testing (~> 2.0) + rails-html-sanitizer (~> 1.1, >= 1.2.0) + activemodel (6.0.6.1) + activesupport (= 6.0.6.1) + activemodel-serializers-xml (1.0.2) + activemodel (> 5.x) + activesupport (> 5.x) + builder (~> 3.1) + activerecord (6.0.6.1) + activemodel (= 6.0.6.1) + activesupport (= 6.0.6.1) + activeresource (5.1.1) + activemodel (>= 5.0, < 7) + activemodel-serializers-xml (~> 1.0) + activesupport (>= 5.0, < 7) + activeresource-hel (0.5.0.2) + activemodel (~> 6.0, >= 6.0.0) + activeresource (~> 5, >= 5.1.0) + awesome_print (~> 1.8, >= 1.8.0) + kaminari (~> 1.1, >= 1.1.1) + activesupport (6.0.6.1) + concurrent-ruby (~> 1.0, >= 1.0.2) + i18n (>= 0.7, < 2) + minitest (~> 5.1) + tzinfo (~> 1.1) + zeitwerk (~> 2.2, >= 2.2.2) + addressable (2.8.8) + public_suffix (>= 2.0.2, < 8.0) + amq-protocol (2.3.0) + amqp (1.8.0) + amq-protocol (>= 2.2.0) + eventmachine + awesome_print (1.9.2) + bigdecimal (3.3.1) + bson (1.12.5) + bson_ext (1.12.5) + bson (~> 1.12.5) + builder (3.2.3) + byebug (11.1.3) + case (0.5.2.1) + coderay (1.1.3) + concurrent-ruby (1.3.5) + crack (1.0.1) + bigdecimal + rexml + crass (1.0.6) + diff-lcs (1.3) + erubi (1.10.0) + eventmachine (1.2.5) + faraday (1.0.0) + multipart-post (>= 1.2, < 3) + hashdiff (1.2.1) + i18n (1.14.7) + concurrent-ruby (~> 1.0) + json (2.7.6) + kaminari (1.2.0) + activesupport (>= 4.1.0) + kaminari-actionview (= 1.2.0) + kaminari-activerecord (= 1.2.0) + kaminari-core (= 1.2.0) + kaminari-actionview (1.2.0) + actionview + kaminari-core (= 1.2.0) + kaminari-activerecord (1.2.0) + activerecord + kaminari-core (= 1.2.0) + kaminari-core (1.2.0) + kyotocabinet (1.33) + loofah (2.4.0) + crass (~> 1.0.2) + nokogiri (>= 1.5.9) + method_source (1.1.0) + mime-types (3.3.1) + mime-types-data (~> 3.2015) + mime-types-data (3.2016.0521) + mini_portile2 (2.3.0) + minitest (5.15.0) + multipart-post (2.0.0) + nokogiri (1.8.5) + mini_portile2 (~> 2.3.0) + pry (0.14.2) + coderay (~> 1.1) + method_source (~> 1.0) + public_suffix (4.0.7) + publisher (1.1.2) + rails-dom-testing (2.0.3) + activesupport (>= 4.2.0) + nokogiri (>= 1.6) + rails-html-sanitizer (1.3.0) + loofah (~> 2.3) + rake (12.3.3) + rexml (3.4.4) + rspec (3.10.0) + rspec-core (~> 3.10.0) + rspec-expectations (~> 3.10.0) + rspec-mocks (~> 3.10.0) + rspec-core (3.10.1) + rspec-support (~> 3.10.0) + rspec-expectations (3.10.1) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.10.0) + rspec-mocks (3.10.2) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.10.0) + rspec-support (3.10.2) + sentry-raven (3.0.0) + faraday (>= 1.0) + sqlite3 (1.3.9) + thor (0.20.3) + thread_safe (0.3.6) + tomte-agents (1.1.1) + tomte-core (>= 1.2.0) + tomte-protocol (>= 1.1.1) + tomte-core (1.2.2) + activesupport (>= 5.0.0) + bson (>= 1.12.5) + bson_ext (>= 1.12.5) + case (>= 0.5.2) + json (>= 2.2.0) + mime-types + pry (>= 0.12.2) + rake + thor (>= 0.20.3) + uuidtools (>= 2.1.5) + wml-compat (>= 0.8.6) + tomte-protocol (1.2.3) + amqp (>= 1.8.0) + tomte-core (>= 1.2.0) + tzinfo (1.2.7) + thread_safe (~> 0.1) + uuidtools (3.0.0) + webmock (3.25.0) + addressable (>= 2.8.0) + crack (>= 0.3.2) + hashdiff (>= 0.4.0, < 2.0.0) + wml-compat (0.8.13) + awesome_print (>= 1.1.0) + uuidtools (>= 2.1.0) + zeitwerk (2.2.2) + +PLATFORMS + x86_64-linux + +DEPENDENCIES + byebug + mailserver_agent! + pry + rake + rspec + webmock + ygg_provisioner! + +BUNDLED WITH + 2.2.34
View file
mailserver_agent-1.0.2.gem/data/bin/mailserver_agent_convert_store
Added
@@ -0,0 +1,58 @@ +#!/usr/bin/ruby + +require 'rubygems' + +require 'active_support/core_ext' +require 'ygg/provisioner/model_store' +require 'json' + +class JSONStore < Ygg::Provisioner::ModelStore::Kyotocabinet + def marshal(data) + JSON.dump(data) + end + + def unmarshal(data) + JSON.load(data).symbolize_keys + end +end + +module Ygg +module Provisioner + + # Simple CLI utility to migrate all records from one store to another. + # + # Usage: + # ygg_provisioner_convert_store SOURCE_PATH DESTINATION_PATH + # + # Both SOURCE_PATH and DESTINATION_PATH are opaque specifications understood + # by {Ygg::Provisioner::ModelStore.instantiate}, typically filesystem paths + # such as: + # - /path/to/db.kch + # - /path/to/db.sqlite3 + class StoreConverter + def self.run(argv) + unless argv.size == 2 + $stderr.puts "Usage: #{$0} SOURCE DESTINATION" + exit 1 + end + + source_spec, dest_spec = argv + + source = JSONStore.new(source_spec) + dest = ModelStore.instantiate(dest_spec) + + migrated = 0 + + source.each_pair do |key, value| + dest.put(key, {cfg: value, state: {}, _type: 'Ygg::SimpleService::Email::Domain::Model'}) + migrated += 1 + end + + $stdout.puts "Migrated #{migrated} records from #{source_spec.inspect} to #{dest_spec.inspect}" + end + end + +end +end + +Ygg::Provisioner::StoreConverter.run(ARGV)
View file
mailserver_agent-1.0.1.gem/data/bin/mailserver_agent_shell -> mailserver_agent-1.0.2.gem/data/bin/mailserver_agent_shell
Changed
@@ -17,4 +17,4 @@ # Tomte::Agents::Framework.setup(:async => true, :application => 'mailserver_agent') Tomte::Agent::MailServerAgent::new(:argv => ARGV) -binding.pry \ No newline at end of file +binding.pry
View file
mailserver_agent-1.0.2.gem/data/build/mailserver_agent.logrotate
Changed
(renamed from data/support/mailserver_agent.logrotate)
View file
mailserver_agent-1.0.2.gem/data/build/mailserver_agent.service
Added
@@ -0,0 +1,15 @@ +Unit +Description=Starts and stops hel mailserver agent + +Service +Type=simple +User=tomte +Group=tomte +PIDFile=/run/mailserver_agent/mailserver_agent.pid +ExecStart=/usr/sbin/mailserver_agent --pidfile /run/mailserver_agent/mailserver_agent.pid -e production --no-daemonize +WorkingDirectory=/var/lib/tomte +Restart=always + +Install +WantedBy=multi-user.target +
View file
mailserver_agent-1.0.2.gem/data/build/mailserver_agent.spec.in
Changed
(renamed from data/mailserver_agent.spec.in)
View file
mailserver_agent-1.0.2.gem/data/build/mailserver_agent.sudoers
Changed
(renamed from data/support/mailserver_agent.sudoers)
View file
mailserver_agent-1.0.2.gem/data/build/mailserver_agent.tempfiles
Changed
(renamed from data/support/mailserver_agent.tempfiles)
View file
mailserver_agent-1.0.2.gem/data/build/mailserver_agent.yml
Changed
(renamed from data/config/mailserver_agent.yml.sample)
View file
mailserver_agent-1.0.2.gem/data/build/tomte.yml
Changed
(renamed from data/config/tomte.yml.sample)
View file
mailserver_agent-1.0.1.gem/data/lib/mailserver_agent.rb -> mailserver_agent-1.0.2.gem/data/lib/mailserver_agent.rb
Changed
@@ -1,3 +1,4 @@ +require 'logger' $:.unshift File::dirname(__FILE__) require 'mailserver_agent/ygg' @@ -19,14 +20,14 @@ def sync load_data sync_domains - rescue + rescue ex = $! if defined?(Raven) Raven.capture_exception(ex) end raise ex end - + protected @@ -35,14 +36,14 @@ dom.store! dom.cabinet_key end - Ygg::SimpleService::Email::Domain.get_stored.each do | dom | + Ygg::SimpleService::Email::Domain.each_stored do | dom | next if keys.include?(dom.cabinet_key) dom.delete_stored! end Ygg::SimpleService::Email::Domain.provision! #Models::Email::Domain.transaction do # ygg_pks = - # domains.each do | domain | + # domains.each do | domain | # ygg_pks << domain.uuid if domain.create_or_update_db_domain! # end @@ -54,8 +55,8 @@ # doms = old.map(&:domain).map{|d| "@#{d}"} # Models::Amavis::User.where(email: doms).map(&:destroy) # old.map(&:destroy!) - # end + # end #end end end -end \ No newline at end of file +end
View file
mailserver_agent-1.0.1.gem/data/lib/mailserver_agent/version.rb -> mailserver_agent-1.0.2.gem/data/lib/mailserver_agent/version.rb
Changed
@@ -1,3 +1,3 @@ module MailServerAgent - VERSION = "1.0.1" + VERSION = "1.0.2" end
View file
mailserver_agent-1.0.1.gem/data/lib/mailserver_agent/ygg/simple_service/email/domain.rb -> mailserver_agent-1.0.2.gem/data/lib/mailserver_agent/ygg/simple_service/email/domain.rb
Changed
@@ -1,139 +1,145 @@ -require 'kyotocabinet' +require 'ygg/provisioner/model' module Ygg module SimpleService module Email class Domain < ActiveResource::Hel::Resource - def self.cabinet - @cabinet ||= begin - path = Tomte.config:mailserver:db - raise StandardError.new("missing database path") unless path.present? - - path = Pathname.new(path) - path = MailServerAgent.root.join(path) unless path.absolute? - path.dirname.mkpath unless path.dirname.exist? + class Model < Ygg::Provisioner::Model + end - db = KyotoCabinet::DB.new - result = db.open(path.to_s, KyotoCabinet::DB::OWRITER | KyotoCabinet::DB::OCREATE) - raise StandardError.new("cannot open cache database #{path.to_s}") unless result - db + class << self + def db_path + Model.db_path end - end - def self.get_stored - stored = - # #each swallows exceptions - ex = nil - cabinet.each do | key, data | - next unless key =~ /\A#{self.name}/ - data = JSON.parse(data) - stored << new(data, true) - rescue - # #each swallows exceptions - ex = $! + def db_path=(path) + Model.db_path = path end - # #each swallows exceptions - raise ex if ex - stored - end - def self.provision! - logger.debug "rebuilding amavis config" - amavis_config = - path = Tomte.config:mailserver:private_keys_path - raise StandardError.new("missing private keys path") unless path.present? - - path = Pathname.new(path) - path = MailServerAgent.root.join(path) unless path.absolute? - - # store private keys in a subdirectory to make the process almost atomic - tmppath = path.join('private_keys.tmp') - # delete old tempdir if exists - tmppath.rmtree if tmppath.exist? - tmppath.mkpath - - bckpath = path.join('private_keys.old') - - path = path.join('private_keys') - path.mkpath unless path.exist? - - get_stored.each do | record | - dk = record.dkim_key || {} - if dk:enabled - key_filename = "#{record.domain}.pem" - options = '' - - opts = - opts << "t=>'#{dk:flags}'" if dk:flags.present? - opts << "h=>'#{dk:hash}'" if dk:hash.present? - - options = ", #{opts.join(', ')}" if opts.any? - amavis_config << "dkim_key('#{record.domain}', '#{dk:selector}', '#{path.join(key_filename)}'#{options});" - - logger.debug "-> write private key #{path.join(key_filename).to_s}" - tmpfile = tmppath.join(key_filename) - tmpfile.open('w+') { |f| f.write dk:private_key } + def each_stored(&block) + Model.each do | obj | + data = obj.serialize + yield new data:cfg end end - cfgfile = Tomte.config:mailserver:amavis_config - raise StandardError.new("missing amavis config path") unless cfgfile.present? - cfgfile = Pathname.new(cfgfile) - cfgfile = MailServerAgent.root.join(cfgfile) unless cfgfile.absolute? - - bckcfgfile = Pathname.new("#{cfgfile.to_s}.bck") - - bckpath.rmtree if bckpath.exist? - cfgfile.rename(bckcfgfile) if cfgfile.exist? - - logger.debug "-> write amavis config #{cfgfile.to_s}" - cfg = "use strict;\n#{amavis_config.join("\n")}\n1;" - cfgfile.open('w+') {|f| f.write cfg } - path.rename(bckpath) if path.exist? - tmppath.rename(path) - - logger.debug "-> restart amavis: command '#{Tomte.config:mailserver:amavis_reload}'" - logger.debug `#{Tomte.config:mailserver:amavis_reload}` + def provision! + debug "rebuilding amavis config" + amavis_config = + path = Tomte.config:mailserver:private_keys_path + raise StandardError.new("missing private keys path") unless path.present? + + path = Pathname.new(path) + path = MailServerAgent.root.join(path) unless path.absolute? + + # store private keys in a subdirectory to make the process almost atomic + tmppath = path.join('private_keys.tmp') + # delete old tempdir if exists + tmppath.rmtree if tmppath.exist? + tmppath.mkpath + + bckpath = path.join('private_keys.old') + + path = path.join('private_keys') + path.mkpath unless path.exist? + + each_stored do | record | + dk = record.dkim_key || {} + if dk:enabled + key_filename = "#{record.domain}.pem" + options = '' + + opts = + opts << "t=>'#{dk:flags}'" if dk:flags.present? + opts << "h=>'#{dk:hash}'" if dk:hash.present? + + options = ", #{opts.join(', ')}" if opts.any? + amavis_config << "dkim_key('#{record.domain}', '#{dk:selector}', '#{path.join(key_filename)}'#{options});" + + debug "-> write private key #{path.join(key_filename).to_s}" + tmpfile = tmppath.join(key_filename) + tmpfile.open('w+') { |f| f.write dk:private_key } + end + end + + cfgfile = Tomte.config:mailserver:amavis_config + raise StandardError.new("missing amavis config path") unless cfgfile.present? + cfgfile = Pathname.new(cfgfile) + cfgfile = MailServerAgent.root.join(cfgfile) unless cfgfile.absolute? + + bckcfgfile = Pathname.new("#{cfgfile.to_s}.bck") + + bckpath.rmtree if bckpath.exist? + cfgfile.rename(bckcfgfile) if cfgfile.exist? + + debug "-> write amavis config #{cfgfile.to_s}" + cfg = "use strict;\n#{amavis_config.join("\n")}\n1;" + cfgfile.open('w+') {|f| f.write cfg } + path.rename(bckpath) if path.exist? + tmppath.rename(path) + + debug "-> restart amavis: command '#{Tomte.config:mailserver:amavis_reload}'" + debug `#{Tomte.config:mailserver:amavis_reload}` + end + + protected + + def debug(*args) + logger&.debug *args + end end self.load_remote_schema = true self.timeout = 120 - def cabinet_key - "#{self.class.name}##{self.id}" - end - def store! - data = to_json - self.class.cabinet.set(cabinet_key, data) + record = begin + Model.find(self.id) + rescue Ygg::Provisioner::Model::NotFound => ex + Model.new + end + + record.update_config as_json + record.save! + @stored = nil end def get_stored - data = self.class.cabinet.get(cabinet_key) - stored = nil - if data
View file
mailserver_agent-1.0.1.gem/data/lib/tomte/agents/mailserver_agent.rb -> mailserver_agent-1.0.2.gem/data/lib/tomte/agents/mailserver_agent.rb
Changed
@@ -13,10 +13,9 @@ DEFAULT_MAIL_AGENT_OPTIONS = { } - read_configuration 'mailserver_agent.yml', :path => :application, :queue => :before - read_configuration 'mailserver_agent.yml', :path => :system - read_configuration 'config/agent.yml', :path => :cwd - read_configuration 'mailserver_agent.yml', :path => :cwd + + read_configuration 'tomte.yml', :path => '/etc/mailserver_agent', :queue => :before + read_configuration 'mailserver_agent.yml', :path => '/etc/mailserver_agent', :queue => :before caption "Mail Agent" help_text "Whohoho!" @@ -35,8 +34,6 @@ def setup(options = {}) log.debug '+ Init: setup ActiveRecord' - #ActiveRecord::Base.logger = log - #::MailAgent::Models::Email::Base.establish_connection config:database:email if config:raven && config:raven:dsn require 'raven' @@ -56,6 +53,8 @@ ActiveResource::Hel::Resource.ssl_options = {verify_mode: OpenSSL::SSL::VERIFY_NONE} if ENV'SSL_VERIFY_NONE' ActiveResource::Hel::Resource.use_configuration :hel ActiveResource::Hel::Resource.logger = log + + Ygg::SimpleService::Email::Domain.db_path = Tomte.config:mailserver:db end end
View file
mailserver_agent-1.0.1.gem/data/mailserver_agent.gemspec -> mailserver_agent-1.0.2.gem/data/mailserver_agent.gemspec
Changed
@@ -3,35 +3,32 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require 'mailserver_agent/version' -Gem::Specification.new do |spec| - spec.name = "mailserver_agent" - spec.version = MailServerAgent::VERSION - spec.authors = "Angelo Grossini" - spec.email = "angelo@intercom.it" - spec.description = %q{Intercom mail DKIM provisioning agent} - spec.summary = %q{Mail agent} - spec.homepage = "https://intercom.it" - spec.license = "MIT" +Gem::Specification.new do |s| + s.name = 'mailserver_agent' + s.version = MailServerAgent::VERSION + s.authors = 'Angelo Grossini' + s.email = 'angelo@intercom.it' + s.description = %q{Intercom mail DKIM provisioning agent} + s.summary = %q{Mail agent} + s.homepage = 'https://intercom.it' + s.license = 'MIT' - spec.files = `git ls-files`.split($/) - spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) } - spec.test_files = spec.files.grep(%r{^(test|spec|features)/}) - spec.require_paths = "lib" + s.files = `git ls-files`.split("\n").reject{|f| f.start_with?('.') } + s.executables = s.files.grep(%r{^bin/}) { |f| File.basename(f) } + s.test_files = s.files.grep(%r{^(test|spec|features)/}) + s.require_paths = 'lib' + s.add_dependency 'tomte-agents', '~> 1.1', '>= 1.1.1' + s.add_dependency 'tomte-core', '~> 1.2', '>= 1.2.1' + s.add_dependency 'tomte-protocol', '~> 1.2', '>= 1.2.0' + s.add_dependency 'activesupport', '~> 6.0' + s.add_dependency 'ygg_provisioner', '~> 1.5', '>= 1.5.0' + s.add_dependency 'activeresource-hel', '~> 0.5.0' + s.add_dependency 'sentry-raven', '~> 3' - spec.add_dependency "tomte-agents", '~> 1.1', '>= 1.1.1' - spec.add_dependency "tomte-core", '~> 1.2', '>= 1.2.1' - spec.add_dependency "tomte-protocol", '~> 1.2', '>= 1.2.0' - spec.add_dependency "activesupport", '~> 6.0' - spec.add_dependency "kyotocabinet", '~> 1.0' - spec.add_dependency "ygg_provisioner", '~> 1.2', '>= 1.2.0' - spec.add_dependency "activeresource-hel", '~> 0.5.0' - spec.add_dependency "sentry-raven", '~> 3' - - #spec.add_development_dependency "sqlite3" - #spec.add_development_dependency "bundler", "~> 1.3" - #spec.add_development_dependency "rake" - #spec.add_development_dependency "pry" - #spec.add_development_dependency "rspec" - #spec.add_development_dependency "timecop" + s.add_development_dependency 'byebug', '~> 11.1', '>= 11.1.30' + s.add_development_dependency 'webmock', '~> 3.25', '>= 3.25.0' + s.add_development_dependency 'rake', '~> 12.3', '>= 12.3.0' + s.add_development_dependency 'pry', '~> 0.14', '>= 0.14.0' + s.add_development_dependency 'rspec', '~> 3.10', '>= 3.10.0' end
View file
mailserver_agent-1.0.2.gem/data/spec/spec_helper.rb
Added
@@ -0,0 +1,100 @@ +# This file was generated by the `rspec --init` command. Conventionally, all +# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`. +# The generated `.rspec` file contains `--require spec_helper` which will cause +# this file to always be loaded, without a need to explicitly require it in any +# files. +# +# Given that it is always loaded, you are encouraged to keep this file as +# light-weight as possible. Requiring heavyweight dependencies from this file +# will add to the boot time of your test suite on EVERY test run, even for an +# individual file that may not need all of that loaded. Instead, consider making +# a separate helper file that requires the additional dependencies and performs +# the additional setup, and require it from the spec files that actually need +# it. +# +# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration +RSpec.configure do |config| + # rspec-expectations config goes here. You can use an alternate + # assertion/expectation library such as wrong or the stdlib/minitest + # assertions if you prefer. + config.expect_with :rspec do |expectations| + # This option will default to `true` in RSpec 4. It makes the `description` + # and `failure_message` of custom matchers include text for helper methods + # defined using `chain`, e.g.: + # be_bigger_than(2).and_smaller_than(4).description + # # => "be bigger than 2 and smaller than 4" + # ...rather than: + # # => "be bigger than 2" + expectations.include_chain_clauses_in_custom_matcher_descriptions = true + end + + # rspec-mocks config goes here. You can use an alternate test double + # library (such as bogus or mocha) by changing the `mock_with` option here. + config.mock_with :rspec do |mocks| + # Prevents you from mocking or stubbing a method that does not exist on + # a real object. This is generally recommended, and will default to + # `true` in RSpec 4. + mocks.verify_partial_doubles = true + end + + # This option will default to `:apply_to_host_groups` in RSpec 4 (and will + # have no way to turn it off -- the option exists only for backwards + # compatibility in RSpec 3). It causes shared context metadata to be + # inherited by the metadata hash of host groups and examples, rather than + # triggering implicit auto-inclusion in groups with matching metadata. + config.shared_context_metadata_behavior = :apply_to_host_groups + +# The settings below are suggested to provide a good initial experience +# with RSpec, but feel free to customize to your heart's content. +=begin + # This allows you to limit a spec run to individual examples or groups + # you care about by tagging them with `:focus` metadata. When nothing + # is tagged with `:focus`, all examples get run. RSpec also provides + # aliases for `it`, `describe`, and `context` that include `:focus` + # metadata: `fit`, `fdescribe` and `fcontext`, respectively. + config.filter_run_when_matching :focus + + # Allows RSpec to persist some state between runs in order to support + # the `--only-failures` and `--next-failure` CLI options. We recommend + # you configure your source control system to ignore this file. + config.example_status_persistence_file_path = "spec/examples.txt" + + # Limits the available syntax to the non-monkey patched syntax that is + # recommended. For more details, see: + # - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/ + # - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/ + # - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode + config.disable_monkey_patching! + + # This setting enables warnings. It's recommended, but in some cases may + # be too noisy due to issues in dependencies. + config.warnings = true + + # Many RSpec users commonly either run the entire suite or an individual + # file, and it's useful to allow more verbose output when running an + # individual spec file. + if config.files_to_run.one? + # Use the documentation formatter for detailed output, + # unless a formatter has already been configured + # (e.g. via a command-line flag). + config.default_formatter = "doc" + end + + # Print the 10 slowest examples and example groups at the + # end of the spec run, to help surface which specs are running + # particularly slow. + config.profile_examples = 10 + + # Run specs in random order to surface order dependencies. If you find an + # order dependency and want to debug it, you can fix the order by providing + # the seed, which is printed after each run. + # --seed 1234 + config.order = :random + + # Seed global randomization in this process using the `--seed` CLI option. + # Setting this allows you to use `--seed` to deterministically reproduce + # test failures related to randomization by passing the same `--seed` value + # as the one that triggered the failure. + Kernel.srand config.seed +=end +end
View file
mailserver_agent-1.0.2.gem/data/spec/support/data.json
Added
@@ -0,0 +1,82 @@ + + { + "id": 2, + "domain": "foobar.foo", + "virtual": null, + "relay_only": false, + "policy_id": 1, + "uuid": "cc805490-d85c-4542-b9d5-c3b186a7e9d9", + "mx": "mailbox.intercom.it", + "aliases": + { + "user": "abuse", + "domain": "foobar.foo", + "forwards": + { + "fqda": "fry@intercom.it", + "_type": "Ygg::SimpleService::Email::Box::Forward" + } + , + "fqda": "abuse@foobar.foo", + "_type": "Ygg::SimpleService::Email::Domain::Alias" + }, + { + "user": "postmaster", + "domain": "foobar.foo", + "forwards": + { + "fqda": "fry@intercom.it", + "_type": "Ygg::SimpleService::Email::Box::Forward" + } + , + "fqda": "postmaster@foobar.foo", + "_type": "Ygg::SimpleService::Email::Domain::Alias" + } + , + "dkim_key": { + "enabled": true, + "selector": "dk1", + "private_key": "-----BEGIN RSA PRIVATE KEY-----\nMIICXQIBAAKBgQC4Kf+jXxGHj9Rp7YBLCvSg0z0ZgPE79EKW7YQBawLBlJexIOR9\nj6FqcJgFvQT1CnOhtHkDtVjZKK0ZceNjEHhkPlHbB3Wl8wybL7USMauq7pFvVeFN\nZ1iSOHAoVj1yvVgYkz5j2W34ZApgiW3aFSgqMYnZEVNqcUAHRhYmz7TyqwIDAQAB\nAoGAChXatxKsvhTFWCu2e+WUsf3/eZcTHupofyVwtjcrBnjhucSIXsvv1glmeeH5\nFIZHANMGUYqr2/CbUipnfnRXc2YcTxITwzZY9Rt9DN1yqLc3xYfQeh3WtCkmtsvZ\nKXJ918IJ80d/9j/R3xVAaSxLcFGOY4LjR9hGsjze6aTMITECQQDi15Pypussrd4L\nWJ1Ssbd3s43Y+QmEAmqq2X8vW/HMOCoTwd3rDekRDNKu9wWgdoopU3lIGucrPW0n\n/PHO9Ge5AkEAz9YQs3SMi7m45t1AaJqkzBH4DrQOp27VmzinHVNlJfV5GUrtQT4N\nxUBA863v3gDT9cJRJNJ1wKhVh6edToRXgwJBANWYhHkB74P8m443fLv3F3ihG7no\nlas101bYwcfIXeAcKpK8A8hnKsShPGj/tM6pj+Ll9NeObYnrpzL2HILw5BECQCLQ\ndue4pDpbl++ELF/ZV7WfZPABlVrSpBFmQggViiH7ppdoB6ogHOpnwvmOr1l+xgKq\n1DDY2ES3bexVVXJrlMUCQQCUrteLSPec6nLAe7vg9Kj3WczkoQEeqbkbK8EgkQKN\n2kQcSYb6CC7PNELBgUx537qAjeRg3FpEW17bqWIuUwKa\n-----END RSA PRIVATE KEY-----\n", + "hash": "sha256", + "flags": "s" + }, + "active": true + }, + { + "id": 3, + "domain": "barfoo.bar", + "virtual": null, + "relay_only": false, + "policy_id": 1, + "uuid": "90716107-999e-4680-a7f4-99a01cec86a3", + "mx": "mailbox.intercom.it", + "aliases": + { + "user": "abuse", + "domain": "barfoo.bar", + "forwards": + { + "fqda": "fry@intercom.it", + "_type": "Ygg::SimpleService::Email::Box::Forward" + } + , + "fqda": "abuse@barfoo.bar", + "_type": "Ygg::SimpleService::Email::Domain::Alias" + }, + { + "user": "postmaster", + "domain": "barfoo.bar", + "forwards": + { + "fqda": "fry@intercom.it", + "_type": "Ygg::SimpleService::Email::Box::Forward" + } + , + "fqda": "postmaster@barfoo.bar", + "_type": "Ygg::SimpleService::Email::Domain::Alias" + } + , + "dkim_key": null, + "active": true + } + \ No newline at end of file
View file
mailserver_agent-1.0.2.gem/data/spec/support/schema.json
Added
@@ -0,0 +1,647 @@ +{ + "type": "Ygg::SimpleService::Email::Domain", + "attrs": { + "id": { + "type": "integer", + "human_name": "", + "notnull": true, + "writable": false, + "readable": true + }, + "domain": { + "type": "string", + "human_name": "", + "default": "", + "notnull": true, + "writable": true, + "readable": true + }, + "virtual": { + "type": "string", + "human_name": "", + "writable": true, + "readable": true + }, + "relay_only": { + "type": "boolean", + "human_name": "", + "notnull": true, + "writable": true, + "readable": true + }, + "generic": { + "type": "boolean", + "human_name": "", + "notnull": true, + "writable": true, + "readable": true + }, + "policy_id": { + "type": "integer", + "human_name": "", + "default": 2, + "notnull": true, + "writable": true, + "readable": true + }, + "created_at": { + "type": "timestamp", + "human_name": "", + "notnull": true, + "writable": false, + "readable": true + }, + "updated_at": { + "type": "timestamp", + "human_name": "", + "notnull": true, + "writable": false, + "readable": true + }, + "uuid": { + "type": "string", + "human_name": "", + "writable": false, + "readable": true + }, + "pop3_merge_junk": { + "type": "boolean", + "human_name": "", + "writable": true, + "readable": true + }, + "quick_search": { + "type": "string", + "human_name": "", + "writable": true, + "readable": true + }, + "on_hold": { + "type": "boolean", + "human_name": "", + "writable": true, + "readable": true + }, + "mx": { + "type": "string", + "human_name": "", + "writable": true, + "readable": true + }, + "log_entry_details": { + "type": "uniform_references_collection", + "human_name": "", + "writable": true, + "readable": true, + "referenced_class": "Ygg::Core::LogEntry::Detail", + "foreign_key": "obj_id", + "foreign_type": "obj_type", + "as": "obj" + }, + "log_entries": { + "type": "uniform_references_collection", + "human_name": "", + "writable": true, + "readable": true, + "referenced_class": "Ygg::Core::LogEntry" + }, + "notifications": { + "type": "uniform_references_collection", + "human_name": "", + "writable": true, + "readable": true, + "referenced_class": "Ygg::Core::Notification", + "foreign_key": "obj_id", + "foreign_type": "obj_type", + "as": "obj" + }, + "recent_notifications": { + "type": "uniform_references_collection", + "human_name": "", + "writable": true, + "readable": true, + "referenced_class": "Ygg::Core::Notification", + "foreign_key": "obj_id", + "foreign_type": "obj_type", + "as": "obj" + }, + "agreement_service_instance": { + "type": "reference", + "human_name": "", + "writable": true, + "readable": true, + "referenced_class": "Ygg::Shop::Agreement::Service::Instance" + }, + "agreement": { + "type": "reference", + "human_name": "", + "writable": true, + "readable": true, + "referenced_class": "Ygg::Shop::Agreement" + }, + "boxes": { + "type": "uniform_references_collection", + "human_name": "", + "writable": true, + "readable": true, + "referenced_class": "Ygg::SimpleService::Email::Box", + "foreign_key": "simple_email_domain_id" + }, + "aliases": { + "type": "uniform_models_collection", + "human_name": "", + "writable": true, + "readable": true, + "class_name": "Ygg::SimpleService::Email::Domain::Alias", + "schema": { + "type": "Ygg::SimpleService::Email::Domain::Alias", + "attrs": { + "id": { + "type": "integer", + "human_name": "", + "notnull": true, + "writable": false, + "readable": true + }, + "simple_email_domain_id": { + "type": "integer", + "human_name": "", + "writable": true, + "readable": true + }, + "user": { + "type": "string", + "human_name": "", + "default": "", + "notnull": true, + "writable": true, + "readable": true + }, + "domain": { + "type": "string", + "human_name": "", + "default": "", + "notnull": true, + "writable": true, + "readable": true + }, + "policy_id": { + "type": "integer", + "human_name": "", + "writable": true, + "readable": true + }, + "created_at": { + "type": "timestamp", + "human_name": "", + "notnull": true, + "writable": false, + "readable": true
View file
mailserver_agent-1.0.2.gem/data/spec/ygg/simple_service/email/domain_spec.rb
Added
@@ -0,0 +1,401 @@ +require 'spec_helper' +require 'json' +require 'tmpdir' +require 'tempfile' +require 'fileutils' +require 'pathname' +require 'tomte/core' +require 'webmock/rspec' +require_relative '../../../../lib/mailserver_agent' + +RSpec.describe Ygg::SimpleService::Email::Domain do + + before(:all) do + WebMock.enable! + + schema_path = File.expand_path('../../../../support/schema.json', __FILE__) + schema_body = File.read(schema_path) + + # Hel authentication used by ActiveResource::Hel::Resource + stub_request(:post, 'https://foobar.bar/ygg/session/authenticate_by_fqda_and_password') + .with(body: { fqda: 'foobar@foo.bar', password: 'foobar' }.to_json) + .to_return( + status: 200, + body: { + "id": "273ef586-9443-4393-94d8-8316f90e4571", + "active": true, + "authenticated": true, + "status": "authenticated", + "started_at": "2055-11-25T12:14:53.000+01:00", + "capabilities": + "superuser", + , + "valid_until": "2055-12-10T12:14:53.000+01:00", + }.to_json, + headers: { 'Content-Type' => 'application/json' } + ) + + stub_request(:get, 'https://foobar.bar/ygg/simple_service/email/domains/schema') + .to_return( + status: 200, + body: schema_body, + headers: { 'Content-Type' => 'application/json' } + ) + end + + after(:all) do + WebMock.disable! + end + def mailserver_config + Tomte.config:mailserver ||= {} + end + + before do + # Usiamo un tempfile come path del database KyotoCabinet. + # KyotoCabinet aprirà il file indicato da questo path con OCREATE|OWRITER. + db_tempfile = Tempfile.new('domains','.sqlite3') + @db_path = Pathname.new(db_tempfile.path) + db_tempfile.close! + + base_dir = @db_path.dirname + + mailserver_config:db = @db_path.to_s + mailserver_config:private_keys_path = base_dir.join('keys').to_s + mailserver_config:amavis_config = base_dir.join('amavis.conf').to_s + mailserver_config:amavis_reload = 'true' # comando innocuo + + Ygg::SimpleService::Email::Domain.db_path = Tomte.config:mailserver:db + + ActiveResource::Hel::Resource.configurations = { + hel: { + site: 'https://foobar.bar', + identity: 'foobar@foo.bar', + secret: 'foobar' + } + } + ActiveResource::Hel::Resource.use_configuration :hel + end + + after do + FileUtils.rm_f(@db_path.to_s) if defined?(@db_path) + base_dir = @db_path.dirname rescue nil + if base_dir && base_dir.directory? + FileUtils.rm_rf(base_dir.join('keys')) + FileUtils.rm_f(base_dir.join('amavis.conf')) + end + end + + describe '#store!' do + it 'stores domains into the backend store' do + data_path = File.expand_path('../../../../support/data.json', __FILE__) + raw_data = JSON.parse(File.read(data_path)) + + # Initialize Domain instances exactly as they would come from remote JSON + domains = raw_data.map { |attrs| described_class.new(attrs) } + + # Use integrated store! + expect { + domains.each(&:store!) + }.to change{ described_class::Model.count }.by(2) + + stored = + described_class.each_stored do | r | + stored << r + end + + domain_names = stored.map(&:domain) + expect(domain_names).to include('foobar.foo', 'barfoo.bar') + + dkim = stored.find { |d| d.domain == 'foobar.foo' }.dkim_key + expect(dkim:enabled).to be(true) + expect(dkim:selector).to eq('dk1') + expect(dkim:hash).to eq('sha256') + expect(dkim:flags).to eq('s') + end + end + + describe '#get_stored' do + it 'returns a new Domain with stored data when the record exists' do + original = described_class.new( + id: 20, + domain: 'stored.example', + dkim_key: { + enabled: true, + private_key: 'KEY', + hash: 'sha256', + flags: 's' + } + ) + + original.store! + + current = described_class.new(id: 20) + stored = current.get_stored + + expect(stored).to be_a(described_class) + expect(stored.id).to eq(20) + expect(stored.domain).to eq('stored.example') + expect(stored.dkim_key:enabled).to be(true) + expect(stored.dkim_key:hash).to eq('sha256') + end + + it 'returns a new Domain with blank id when the record does not exist' do + current = described_class.new(id: 21) + + stored = current.get_stored + + expect(stored).to be_a(described_class) + expect(stored.id).to be_nil + expect(stored.dkim_key).to be_nil.or eq({}) + end + end + + describe '#delete_stored!' do + it 'removes the stored record when it exists' do + domain = described_class.new( + id: 30, + domain: 'delete-me.example', + dkim_key: { + enabled: true, + private_key: 'KEY', + hash: 'sha256', + flags: 's' + } + ) + + domain.store! + expect(domain.get_stored.id).to eq(30) + + expect { + domain.delete_stored! + }.to change{ described_class::Model.count }.by(-1) + end + + it 'is tolerant when the record does not exist' do + domain = described_class.new(id: 31, domain: 'non-existing.example') + + # The method should not raise even if nothing is stored. + expect { + expect { + domain.delete_stored! + }.not_to raise_error + }.not_to change{ described_class::Model.count } + + stored = domain.get_stored + expect(stored.id).to be_nil + end + end + + describe '.provision!' do + it 'raises when the private keys path is missing' do + mailserver_config:private_keys_path = nil + + expect { described_class.provision! } + .to raise_error(StandardError, /missing private keys path/) + end + + it 'raises when the amavis config path is missing' do + mailserver_config:amavis_config = nil +
View file
mailserver_agent-1.0.1.gem/metadata.gz -> mailserver_agent-1.0.2.gem/metadata.gz
Changed
@@ -1,14 +1,14 @@ --- !ruby/object:Gem::Specification name: mailserver_agent version: !ruby/object:Gem::Version - version: 1.0.1 + version: 1.0.2 platform: ruby authors: - Angelo Grossini -autorequire: +autorequire: bindir: bin cert_chain: -date: 2024-06-06 00:00:00.000000000 Z +date: 2025-12-02 00:00:00.000000000 Z dependencies: - !ruby/object:Gem::Dependency name: tomte-agents @@ -85,83 +85,176 @@ - !ruby/object:Gem::Version version: '6.0' - !ruby/object:Gem::Dependency - name: kyotocabinet + name: ygg_provisioner requirement: !ruby/object:Gem::Requirement requirements: - - "~>" - !ruby/object:Gem::Version - version: '1.0' + version: '1.5' + - - ">=" + - !ruby/object:Gem::Version + version: 1.5.0 type: :runtime prerelease: false version_requirements: !ruby/object:Gem::Requirement requirements: - - "~>" - !ruby/object:Gem::Version - version: '1.0' + version: '1.5' + - - ">=" + - !ruby/object:Gem::Version + version: 1.5.0 - !ruby/object:Gem::Dependency - name: ygg_provisioner + name: activeresource-hel requirement: !ruby/object:Gem::Requirement requirements: - - "~>" - !ruby/object:Gem::Version - version: '1.2' - - - ">=" + version: 0.5.0 + type: :runtime + prerelease: false + version_requirements: !ruby/object:Gem::Requirement + requirements: + - - "~>" - !ruby/object:Gem::Version - version: 1.2.0 + version: 0.5.0 +- !ruby/object:Gem::Dependency + name: sentry-raven + requirement: !ruby/object:Gem::Requirement + requirements: + - - "~>" + - !ruby/object:Gem::Version + version: '3' type: :runtime prerelease: false version_requirements: !ruby/object:Gem::Requirement requirements: - - "~>" - !ruby/object:Gem::Version - version: '1.2' + version: '3' +- !ruby/object:Gem::Dependency + name: byebug + requirement: !ruby/object:Gem::Requirement + requirements: + - - "~>" + - !ruby/object:Gem::Version + version: '11.1' - - ">=" - !ruby/object:Gem::Version - version: 1.2.0 + version: 11.1.30 + type: :development + prerelease: false + version_requirements: !ruby/object:Gem::Requirement + requirements: + - - "~>" + - !ruby/object:Gem::Version + version: '11.1' + - - ">=" + - !ruby/object:Gem::Version + version: 11.1.30 - !ruby/object:Gem::Dependency - name: activeresource-hel + name: webmock requirement: !ruby/object:Gem::Requirement requirements: - - "~>" - !ruby/object:Gem::Version - version: 0.5.0 - type: :runtime + version: '3.25' + - - ">=" + - !ruby/object:Gem::Version + version: 3.25.0 + type: :development prerelease: false version_requirements: !ruby/object:Gem::Requirement requirements: - - "~>" - !ruby/object:Gem::Version - version: 0.5.0 + version: '3.25' + - - ">=" + - !ruby/object:Gem::Version + version: 3.25.0 - !ruby/object:Gem::Dependency - name: sentry-raven + name: rake requirement: !ruby/object:Gem::Requirement requirements: - - "~>" - !ruby/object:Gem::Version - version: '3' - type: :runtime + version: '12.3' + - - ">=" + - !ruby/object:Gem::Version + version: 12.3.0 + type: :development prerelease: false version_requirements: !ruby/object:Gem::Requirement requirements: - - "~>" - !ruby/object:Gem::Version - version: '3' + version: '12.3' + - - ">=" + - !ruby/object:Gem::Version + version: 12.3.0 +- !ruby/object:Gem::Dependency + name: pry + requirement: !ruby/object:Gem::Requirement + requirements: + - - "~>" + - !ruby/object:Gem::Version + version: '0.14' + - - ">=" + - !ruby/object:Gem::Version + version: 0.14.0 + type: :development + prerelease: false + version_requirements: !ruby/object:Gem::Requirement + requirements: + - - "~>" + - !ruby/object:Gem::Version + version: '0.14' + - - ">=" + - !ruby/object:Gem::Version + version: 0.14.0 +- !ruby/object:Gem::Dependency + name: rspec + requirement: !ruby/object:Gem::Requirement + requirements: + - - "~>" + - !ruby/object:Gem::Version + version: '3.10' + - - ">=" + - !ruby/object:Gem::Version + version: 3.10.0 + type: :development + prerelease: false + version_requirements: !ruby/object:Gem::Requirement + requirements: + - - "~>" + - !ruby/object:Gem::Version + version: '3.10' + - - ">=" + - !ruby/object:Gem::Version + version: 3.10.0 description: Intercom mail DKIM provisioning agent email: - angelo@intercom.it executables: - mailserver_agent +- mailserver_agent_convert_store - mailserver_agent_shell extensions: extra_rdoc_files: files: -- ".gitignore" - Dockerfile -- Makefile +- Gemfile
View file
mailserver_agent.service
Changed
@@ -6,7 +6,7 @@ User=tomte Group=tomte PIDFile=/run/mailserver_agent/mailserver_agent.pid -ExecStart=/usr/bin/mailserver_agent --pidfile /run/mailserver_agent/mailserver_agent.pid -e production --no-daemonize +ExecStart=/usr/sbin/mailserver_agent --pidfile /run/mailserver_agent/mailserver_agent.pid -e production --no-daemonize WorkingDirectory=/var/lib/tomte Restart=always
Locations
Projects
Search
Status Monitor
Help
Open Build Service
OBS Manuals
API Documentation
OBS Portal
Reporting a Bug
Contact
Mailing List
Forums
Chat (IRC)
Twitter
Open Build Service (OBS)
is an
openSUSE project
.