From b45de7552aa29779d45706f6bfa9b723f7a8167a Mon Sep 17 00:00:00 2001 From: a9s-internal Date: Mon, 3 Nov 2025 09:03:30 +0100 Subject: [PATCH 1/4] Update automerge dependabot workflows --- .github/dependabot.yml | 41 +++++++++++++++++++ .../workflows/dependabot-pr-auto-merge.yml | 30 ++++++++++++++ .github/workflows/linter_ruby.yml | 16 ++++++++ 3 files changed, 87 insertions(+) create mode 100644 .github/dependabot.yml create mode 100644 .github/workflows/dependabot-pr-auto-merge.yml create mode 100644 .github/workflows/linter_ruby.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..7c249b6 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,41 @@ +# version: 2 + +# registries: +# github: +# type: git +# url: https://github.com +# username: x-access-token +# password: "${{ secrets.GIT_TOKEN }}" + +# updates: +# - package-ecosystem: "bundler" +# directory: '/' +# registries: "*" +# insecure-external-code-execution: allow +# schedule: +# interval: "daily" +# time: "09:00" +# timezone: "Europe/Berlin" +# target-branch: "develop" +# labels: +# - "Ruby dependencies" + +version: 2 + +registries: + github: + type: git + url: https://github.com + username: x-access-token + password: "${{ secrets.GIT_TOKEN }}" # saved as a dependabot secret +updates: + - package-ecosystem: "bundler" + directory: "/" + registries: "*" + insecure-external-code-execution: allow + schedule: + interval: "daily" + target-branch: "develop" + labels: + - "Ruby dependencies" + \ No newline at end of file diff --git a/.github/workflows/dependabot-pr-auto-merge.yml b/.github/workflows/dependabot-pr-auto-merge.yml new file mode 100644 index 0000000..c9ed65e --- /dev/null +++ b/.github/workflows/dependabot-pr-auto-merge.yml @@ -0,0 +1,30 @@ +name: Dependabot auto-merge +on: pull_request + +permissions: + contents: write + pull-requests: write + checks: read + +jobs: + dependabot-pr-auto-merge: + runs-on: ubuntu-latest + if: github.event.pull_request.user.login == 'dependabot[bot]' + + steps: + - name: Suite Status Checks + id: suite-checks + uses: poseidon/wait-for-status-checks@v0.6.0 + with: + token: ${{ secrets.GITHUB_TOKEN }} + ignore: dependabot-email-notification + + - name: Dependabot metadata + id: dependabot-metadata + uses: dependabot/fetch-metadata@v2 + + - name: Auto-merge Dependabot PR + run: | + gh pr merge --auto --squash "${{ github.event.pull_request.html_url }}" + env: + GH_TOKEN: ${{ secrets.GIT_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/linter_ruby.yml b/.github/workflows/linter_ruby.yml new file mode 100644 index 0000000..9a40306 --- /dev/null +++ b/.github/workflows/linter_ruby.yml @@ -0,0 +1,16 @@ +name: Lint and SAST + +on: + pull_request: + workflow_dispatch: + +jobs: + lint: + uses: anynines/int-gitops/.github/workflows/linter_ruby.yml@master + secrets: + token: ${{ secrets.GITHUB_TOKEN }} + + sast: + uses: anynines/int-gitops/.github/workflows/sast_ruby.yml@master + secrets: + token: ${{ secrets.GITHUB_TOKEN }} From cf3be87dcbc32ff88431dde09a60c2e0d4a9f772 Mon Sep 17 00:00:00 2001 From: Jan-Robin Aumann Date: Tue, 4 Nov 2025 09:09:43 +0100 Subject: [PATCH 2/4] add rubocop --- .rubocop.yml | 45 +++++++++++++++++++++++++++++++ Gemfile | 4 +++ Gemfile.lock | 76 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 125 insertions(+) create mode 100644 .rubocop.yml diff --git a/.rubocop.yml b/.rubocop.yml new file mode 100644 index 0000000..fb535ff --- /dev/null +++ b/.rubocop.yml @@ -0,0 +1,45 @@ +plugins: + - rubocop-performance + - rubocop-rails + - rubocop-rspec + +AllCops: + # Insert your target ruby version + TargetRubyVersion: 3.2.x + NewCops: enable + + +# Overwrite or add rules to create your own house style +# +# # Use `[a, [b, c]]` not `[ a, [ b, c ] ]` +# Layout/SpaceInsideArrayLiteralBrackets: +# Enabled: false + +Layout/IndentationConsistency: + Enabled: true + +Layout/IndentationWidth: + Enabled: true + +Bundler: + Enabled: true +Gemspec: + Enabled: true +Layout: + Enabled: true +Lint: + Enabled: true +Metrics: + Enabled: true +Naming: + Enabled: true +Performance: + Enabled: true + Exclude: + - "spec/**/*" +Rails: + Enabled: true +Security: + Enabled: true +Style: + Enabled: true diff --git a/Gemfile b/Gemfile index a38f628..3d6f037 100644 --- a/Gemfile +++ b/Gemfile @@ -17,6 +17,10 @@ gem 'erubis' gem 'honeybadger' gem 'psych', '< 4' +gem "rubocop" +gem "rubocop-rspec" +gem "rubocop-rails-omakase", require: false + group :development, :test do gem 'rake' gem 'rspec' diff --git a/Gemfile.lock b/Gemfile.lock index f92a995..3e8a974 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,21 +1,56 @@ GEM remote: https://rubygems.org/ specs: + activesupport (7.2.3) + base64 + benchmark (>= 0.3) + bigdecimal + concurrent-ruby (~> 1.0, >= 1.3.1) + connection_pool (>= 2.2.5) + drb + i18n (>= 1.6, < 2) + logger (>= 1.4.2) + minitest (>= 5.1) + securerandom (>= 0.3) + tzinfo (~> 2.0, >= 2.0.5) amq-protocol (2.3.2) amqp (1.8.0) amq-protocol (>= 2.2.0) eventmachine + ast (2.4.3) + base64 (0.3.0) + benchmark (0.5.0) + bigdecimal (3.3.1) + concurrent-ruby (1.3.5) + connection_pool (2.5.4) daemon-kit (0.3.3) eventmachine (>= 0.12.10) thor diff-lcs (1.5.0) + drb (2.2.3) erubis (2.7.0) eventmachine (1.2.7) honeybadger (5.0.2) + i18n (1.14.7) + concurrent-ruby (~> 1.0) + json (2.15.2) + language_server-protocol (3.17.0.5) + lint_roller (1.1.0) + logger (1.7.0) + minitest (5.26.0) mocha (2.0.2) ruby2_keywords (>= 0.0.5) + parallel (1.27.0) + parser (3.3.10.0) + ast (~> 2.4.1) + racc + prism (1.6.0) psych (3.3.4) + racc (1.8.1) + rack (3.2.4) + rainbow (3.1.1) rake (13.0.6) + regexp_parser (2.11.3) rspec (3.12.0) rspec-core (~> 3.12.0) rspec-expectations (~> 3.12.0) @@ -29,9 +64,47 @@ GEM diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.12.0) rspec-support (3.12.0) + rubocop (1.81.7) + json (~> 2.3) + language_server-protocol (~> 3.17.0.2) + lint_roller (~> 1.1.0) + parallel (~> 1.10) + parser (>= 3.3.0.2) + rainbow (>= 2.2.2, < 4.0) + regexp_parser (>= 2.9.3, < 3.0) + rubocop-ast (>= 1.47.1, < 2.0) + ruby-progressbar (~> 1.7) + unicode-display_width (>= 2.4.0, < 4.0) + rubocop-ast (1.47.1) + parser (>= 3.3.7.2) + prism (~> 1.4) + rubocop-performance (1.26.1) + lint_roller (~> 1.1) + rubocop (>= 1.75.0, < 2.0) + rubocop-ast (>= 1.47.1, < 2.0) + rubocop-rails (2.33.4) + activesupport (>= 4.2.0) + lint_roller (~> 1.1) + rack (>= 1.1) + rubocop (>= 1.75.0, < 2.0) + rubocop-ast (>= 1.44.0, < 2.0) + rubocop-rails-omakase (1.1.0) + rubocop (>= 1.72) + rubocop-performance (>= 1.24) + rubocop-rails (>= 2.30) + rubocop-rspec (3.7.0) + lint_roller (~> 1.1) + rubocop (~> 1.72, >= 1.72.1) + ruby-progressbar (1.13.0) ruby2_keywords (0.0.5) safely (0.3.2) + securerandom (0.4.1) thor (1.2.1) + tzinfo (2.0.6) + concurrent-ruby (~> 1.0) + unicode-display_width (3.2.0) + unicode-emoji (~> 4.1) + unicode-emoji (4.1.0) PLATFORMS ruby @@ -45,6 +118,9 @@ DEPENDENCIES psych (< 4) rake rspec + rubocop + rubocop-rails-omakase + rubocop-rspec safely RUBY VERSION From 2624e3a79ed5e65901a2788bb68b384be34f7146 Mon Sep 17 00:00:00 2001 From: Jan-Robin Aumann Date: Tue, 4 Nov 2025 09:11:54 +0100 Subject: [PATCH 3/4] rubocop auto fixes --- Capfile | 4 +- Rakefile | 2 +- config/boot.rb | 16 +- config/deploy.rb | 17 +- config/deploy/production.rb | 2 +- config/environment.rb | 3 +- .../write_shared_webserver_config_files.rb | 4 +- config/pre-daemonize/configure_app.rb | 4 +- lib/virtual_host_service_worker.rb | 4 +- .../amqp_dispatcher.rb | 4 +- .../haproxy_v_host_writer.rb | 2 +- .../nginx_v_host_writer.rb | 38 ++--- .../v_host_writer.rb | 7 +- libexec/virtual_host_service_worker-daemon.rb | 10 +- script/console | 2 +- script/destroy | 2 +- script/generate | 2 +- .../nginx_v_host_writer_spec.rb | 150 ++++++++---------- spec/spec_helper.rb | 36 ++--- tasks/rspec.rake | 2 +- 20 files changed, 138 insertions(+), 173 deletions(-) diff --git a/Capfile b/Capfile index 6a798eb..6178812 100644 --- a/Capfile +++ b/Capfile @@ -1,4 +1,4 @@ load 'deploy' # Uncomment if you are using Rails' asset pipeline - # load 'deploy/assets' -load 'config/deploy' # remove this line to skip loading any of the default tasks \ No newline at end of file +# load 'deploy/assets' +load 'config/deploy' # remove this line to skip loading any of the default tasks diff --git a/Rakefile b/Rakefile index 0c1d636..7aa4c51 100644 --- a/Rakefile +++ b/Rakefile @@ -1,4 +1,4 @@ -require File.expand_path('../config/boot', __FILE__) +require File.expand_path('../config/boot', __FILE__) require 'rake' require 'daemon_kit/tasks' diff --git a/config/boot.rb b/config/boot.rb index 9df5cc6..1323af6 100644 --- a/config/boot.rb +++ b/config/boot.rb @@ -1,7 +1,7 @@ # Don't change this file! # Configure your daemon in config/environment.rb -DAEMON_ROOT = "#{File.expand_path(File.dirname(__FILE__))}/.." unless defined?( DAEMON_ROOT ) +DAEMON_ROOT = "#{File.expand_path(File.dirname(__FILE__))}/.." unless defined?(DAEMON_ROOT) require "rubygems" require "bundler/setup" @@ -23,7 +23,7 @@ def pick_boot end def vendor_kit? - File.exists?( "#{DAEMON_ROOT}/vendor/daemon-kit" ) + File.exist?("#{DAEMON_ROOT}/vendor/daemon-kit") end end @@ -43,17 +43,17 @@ def load_initializer class GemBoot < Boot def load_initializer begin - require 'rubygems' unless defined?( ::Gem ) + require 'rubygems' unless defined?(::Gem) gem 'daemon-kit' require 'daemon_kit/initializer' - rescue ::Gem::LoadError => e - msg = < true } default_run_options[:pty] = true ##### Overwritten and changed default capistrano tasks ##### namespace :deploy do - task :start, :roles => :app, :except => { :no_release => true } do run "cd #{current_path} && DAEMON_ENV=#{env} bundle exec bin/virtual_host_service_worker --pidfile #{pidfile} start" end @@ -36,8 +35,8 @@ end task :restart, :roles => :app, :except => { :no_release => true } do - stop - start + stop + start end desc "Additional Symlinks" @@ -45,15 +44,13 @@ run "ln -nfs #{shared_path}/config/amqp.yml #{release_path}/config/amqp.yml" run "ln -nfs #{shared_path}/config/application.yml #{release_path}/config/application.yml" end - end - + ##### After and Before Tasks ##### before "deploy:restart", "deploy:additional_symlink" after "deploy:restart", "deploy:cleanup" -#require 'config/boot' -#require 'airbrake/capistrano' +# require 'config/boot' +# require 'airbrake/capistrano' require './config/boot' - diff --git a/config/deploy/production.rb b/config/deploy/production.rb index c28224c..c9a266a 100644 --- a/config/deploy/production.rb +++ b/config/deploy/production.rb @@ -4,4 +4,4 @@ set :user, "deploy" set :env, "production" set :pidfile, "tmp/pids/worker.pid" -set :branch, fetch(:branch, "master") \ No newline at end of file +set :branch, fetch(:branch, "master") diff --git a/config/environment.rb b/config/environment.rb index 2e48d55..928f95a 100644 --- a/config/environment.rb +++ b/config/environment.rb @@ -1,7 +1,7 @@ # Be sure to restart your daemon when you modify this file # Uncomment below to force your daemon into production mode -#ENV['DAEMON_ENV'] ||= 'production' +# ENV['DAEMON_ENV'] ||= 'production' # Boot up require File.join(File.dirname(__FILE__), 'boot') @@ -10,7 +10,6 @@ Bundler.require :default, DaemonKit.env DaemonKit::Initializer.run do |config| - # The name of the daemon as reported by process monitoring tools config.daemon_name = 'virtual_host_service_worker' diff --git a/config/post-daemonize/write_shared_webserver_config_files.rb b/config/post-daemonize/write_shared_webserver_config_files.rb index 3389453..e52f036 100644 --- a/config/post-daemonize/write_shared_webserver_config_files.rb +++ b/config/post-daemonize/write_shared_webserver_config_files.rb @@ -2,5 +2,5 @@ return else puts "=> write_shared_webserver_config_files" - VirtualHostServiceWorker::NginxVHostWriter.write_shared_webserver_config_files -end \ No newline at end of file + VirtualHostServiceWorker::NginxVHostWriter.write_shared_webserver_config_files +end diff --git a/config/pre-daemonize/configure_app.rb b/config/pre-daemonize/configure_app.rb index 3b17b06..5b17a63 100644 --- a/config/pre-daemonize/configure_app.rb +++ b/config/pre-daemonize/configure_app.rb @@ -1,11 +1,11 @@ require 'yaml' require 'honeybadger' -DAEMON_ENV = 'development' unless defined?( DAEMON_ENV ) +DAEMON_ENV = 'development' unless defined?(DAEMON_ENV) APP_CONFIG = YAML.load_file(File.join(File.dirname(__FILE__), '..', 'application.yml'))[DAEMON_ENV] unless APP_CONFIG['honeybadger_api_key'].empty? Honeybadger.configure do |config| config.api_key = APP_CONFIG['honeybadger_api_key'] end -end \ No newline at end of file +end diff --git a/lib/virtual_host_service_worker.rb b/lib/virtual_host_service_worker.rb index a050413..526d054 100644 --- a/lib/virtual_host_service_worker.rb +++ b/lib/virtual_host_service_worker.rb @@ -1,8 +1,6 @@ module VirtualHostServiceWorker - autoload :VHostWriter, 'virtual_host_service_worker/v_host_writer.rb' autoload :AmqpDispatcher, 'virtual_host_service_worker/amqp_dispatcher.rb' autoload :HaproxyVHostWriter, 'virtual_host_service_worker/haproxy_v_host_writer.rb' autoload :NginxVHostWriter, 'virtual_host_service_worker/nginx_v_host_writer.rb' - -end \ No newline at end of file +end diff --git a/lib/virtual_host_service_worker/amqp_dispatcher.rb b/lib/virtual_host_service_worker/amqp_dispatcher.rb index 9ececc0..903bcf2 100644 --- a/lib/virtual_host_service_worker/amqp_dispatcher.rb +++ b/lib/virtual_host_service_worker/amqp_dispatcher.rb @@ -1,7 +1,5 @@ module VirtualHostServiceWorker - class AmqpDispatcher - ## # dispatches amqp-messages to method calls # @@ -37,4 +35,4 @@ def self.dispatch(payload) end end end -end \ No newline at end of file +end diff --git a/lib/virtual_host_service_worker/haproxy_v_host_writer.rb b/lib/virtual_host_service_worker/haproxy_v_host_writer.rb index eb5c0aa..b18a525 100644 --- a/lib/virtual_host_service_worker/haproxy_v_host_writer.rb +++ b/lib/virtual_host_service_worker/haproxy_v_host_writer.rb @@ -26,7 +26,7 @@ def self.delete_v_host(server_name) def self.write_bundled_certificates(server_name, ca_cert, cert, ssl_key) pem_path = build_pem_path(server_name) - FileUtils.rm(pem_path) if File.exist?(pem_path) + FileUtils.rm_f(pem_path) File.open(pem_path, 'w') do |f| f.write(pem_template.result({ diff --git a/lib/virtual_host_service_worker/nginx_v_host_writer.rb b/lib/virtual_host_service_worker/nginx_v_host_writer.rb index 3d28b66..859cec5 100644 --- a/lib/virtual_host_service_worker/nginx_v_host_writer.rb +++ b/lib/virtual_host_service_worker/nginx_v_host_writer.rb @@ -2,7 +2,6 @@ require 'fileutils' module VirtualHostServiceWorker - ## # This class provides methods to add virtual hosts to an nginx configuration. # Public interface: @@ -10,7 +9,6 @@ module VirtualHostServiceWorker # self.write_shared_webserver_config_files # class NginxVHostWriter < VHostWriter - ## # Adds a new virtual hosts configured with a ssl certificate to the nginx config. # The virtual host information is passed as hash to the method. The hash must contain the @@ -44,7 +42,8 @@ def self.setup_v_host(payload) # def self.delete_v_host(server_name) v_host_file = File.join(APP_CONFIG['v_host_config_dir'].split('/'), "#{server_name}.conf") - v_host_link = File.join(APP_CONFIG['v_host_link_dir'].split('/'), "#{server_name}.conf") if APP_CONFIG['v_host_link_dir'] + v_host_link = File.join(APP_CONFIG['v_host_link_dir'].split('/'), + "#{server_name}.conf") if APP_CONFIG['v_host_link_dir'] key_file = File.join(APP_CONFIG['cert_dir'].split('.'), server_name.gsub('*', 'wild'), "#{server_name}.key") pem_file = File.join(APP_CONFIG['cert_dir'].split('/'), server_name.gsub('*', 'wild'), "#{server_name}.pem") @@ -78,40 +77,36 @@ def self.write_shared_webserver_config_files upstream_config_file = File.join(APP_CONFIG['upstream_config'].split('/')) File.open(upstream_config_file, 'w') do |f| f.write(upstream_template.result({ - :routers => APP_CONFIG['routers'] - })) + :routers => APP_CONFIG['routers'] + })) end reload_config end - protected - ## # Write the actual virtual host configuration pointing to the certificate fiels. # def self.write_webserver_config(server_name, server_aliases) - template_file = File.join(File.dirname(__FILE__), '..', '..', 'templates', 'nginx_v_host.conf.erb') template = Erubis::Eruby.new(File.read(template_file)) server_aliases ||= '' server_aliases = server_aliases.gsub(',', ' ') - v_host_file = File.join(APP_CONFIG['v_host_config_dir'].split('/'), "#{server_name.gsub('*', 'wild')}.conf") v_host_config = template.result({ - :server_name => server_name, - :server_aliases => server_aliases, - :path_to_ssl_files => APP_CONFIG['cert_dir'].to_s + server_name.gsub('*', 'wild') + '/' - }) + :server_name => server_name, + :server_aliases => server_aliases, + :path_to_ssl_files => APP_CONFIG['cert_dir'].to_s + server_name.gsub('*', + 'wild') + '/' + }) - FileUtils.rm(v_host_file) if File.exist?(v_host_file) + FileUtils.rm_f(v_host_file) File.open(v_host_file, 'w') do |f| f.write(v_host_config) end - end ## @@ -124,16 +119,17 @@ def self.link_webserver_config(server_name) v_host_file = File.join(APP_CONFIG['v_host_config_dir'].split('/'), "#{server_name.gsub('*', 'wild')}.conf") v_host_link = File.join(APP_CONFIG['v_host_link_dir'].split('/'), "#{server_name.gsub('*', 'wild')}.conf") - execute_command("ln -s #{v_host_file} #{v_host_link}") unless File.exists?(v_host_link) + execute_command("ln -s #{v_host_file} #{v_host_link}") unless File.exist?(v_host_link) end ## # Wirte the ssl key file to directory specified by the application config (config/application.yml). # def self.write_ssl_key(server_name, key) - key_file = File.join(APP_CONFIG['cert_dir'].split('/'), server_name.gsub('*', 'wild'), "#{server_name.gsub('*', 'wild')}.key") + key_file = File.join(APP_CONFIG['cert_dir'].split('/'), server_name.gsub('*', 'wild'), + "#{server_name.gsub('*', 'wild')}.key") - FileUtils.rm(key_file) if File.exist?(key_file) + FileUtils.rm_f(key_file) FileUtils.mkdir_p(File.dirname(key_file)) File.open(key_file, 'w') do |f| @@ -146,9 +142,10 @@ def self.write_ssl_key(server_name, key) # directory specified by the application config (config/application.yml). # def self.write_bundled_certificates(server_name, ca_cert, cert) - pem_file = File.join(APP_CONFIG['cert_dir'].split('/'), server_name.gsub('*', 'wild'), "#{server_name.gsub('*', 'wild')}.pem") + pem_file = File.join(APP_CONFIG['cert_dir'].split('/'), server_name.gsub('*', 'wild'), + "#{server_name.gsub('*', 'wild')}.pem") - FileUtils.rm(pem_file) if File.exist?(pem_file) + FileUtils.rm_f(pem_file) FileUtils.mkdir_p(File.dirname(pem_file)) File.open(pem_file, 'w') do |f| @@ -172,6 +169,5 @@ def self.config_valid? command = "#{APP_CONFIG['nginx_command']} -t -c #{APP_CONFIG['webserver_config']}" execute_command(command, 'Invalid nginx configuration') end - end end diff --git a/lib/virtual_host_service_worker/v_host_writer.rb b/lib/virtual_host_service_worker/v_host_writer.rb index 82b5b84..6acd3de 100644 --- a/lib/virtual_host_service_worker/v_host_writer.rb +++ b/lib/virtual_host_service_worker/v_host_writer.rb @@ -1,8 +1,6 @@ module VirtualHostServiceWorker - class VHostWriter - - def self.setup_v_host(payload) + def self.setup_v_host(_payload) raise NotImplementedError.new end @@ -15,9 +13,8 @@ def self.execute_command(command, custom_message = nil, expected_return = 0) if $?.exitstatus != expected_return raise "Exception on executing command: #{command}\n Custom Message: #{custom_message}\n Command-Result: #{stdout}" end + return true end - end - end diff --git a/libexec/virtual_host_service_worker-daemon.rb b/libexec/virtual_host_service_worker-daemon.rb index ca2edf1..43e1bee 100644 --- a/libexec/virtual_host_service_worker-daemon.rb +++ b/libexec/virtual_host_service_worker-daemon.rb @@ -1,23 +1,22 @@ require 'json' DaemonKit::Application.running! do |config| - end DaemonKit::AMQP.run do |connection| - connection.on_tcp_connection_loss do |connection, settings| + connection.on_tcp_connection_loss do |connection, _settings| puts "--> detected connection lost" Honeybadger.notify("--> detected connection lost") connection.reconnect(false, 10) end - connection.on_connection_interruption do |conn| + connection.on_connection_interruption do |_conn| puts "--> detected connection interruption" Honeybadger.notify("--> detected connection interruption") EventMachine.stop end - connection.on_error do |conn, connection_close| + connection.on_error do |_conn, connection_close| Honeybadger.notify("--> Handling a connection-level exception.") puts "--------" puts "Handling a connection-level exception." @@ -29,7 +28,7 @@ EventMachine.stop end - channel = AMQP::Channel.new(connection) + channel = AMQP::Channel.new(connection) channel.on_connection_interruption do |ch| puts "--> Channel #{ch.id} detected connection interruption" @@ -57,4 +56,3 @@ VirtualHostServiceWorker::AmqpDispatcher.dispatch(JSON.parse(payload)) end end - diff --git a/script/console b/script/console index b2342b7..9c880dd 100755 --- a/script/console +++ b/script/console @@ -1,4 +1,4 @@ #!/usr/bin/env ruby #!/usr/bin/env ruby -require File.expand_path('../../config/boot', __FILE__) +require File.expand_path('../../config/boot', __FILE__) require 'daemon_kit/commands/console' diff --git a/script/destroy b/script/destroy index 2bfad52..0d7b383 100755 --- a/script/destroy +++ b/script/destroy @@ -1,4 +1,4 @@ #!/usr/bin/env ruby #!/usr/bin/env ruby -require File.expand_path( '../../config/environment', __FILE__ ) +require File.expand_path('../../config/environment', __FILE__) require 'daemon_kit/commands/generate' diff --git a/script/generate b/script/generate index 2bfad52..0d7b383 100755 --- a/script/generate +++ b/script/generate @@ -1,4 +1,4 @@ #!/usr/bin/env ruby #!/usr/bin/env ruby -require File.expand_path( '../../config/environment', __FILE__ ) +require File.expand_path('../../config/environment', __FILE__) require 'daemon_kit/commands/generate' diff --git a/spec/lib/virtual_host_service_worker/nginx_v_host_writer_spec.rb b/spec/lib/virtual_host_service_worker/nginx_v_host_writer_spec.rb index 2b7d5e3..42e526b 100644 --- a/spec/lib/virtual_host_service_worker/nginx_v_host_writer_spec.rb +++ b/spec/lib/virtual_host_service_worker/nginx_v_host_writer_spec.rb @@ -1,52 +1,51 @@ require 'spec_helper' describe VirtualHostServiceWorker::NginxVHostWriter do - let :valid_payload do { - "id"=>1, - "ssl_certificate"=> + "id" => 1, + "ssl_certificate" => "-----BEGIN CERTIFICATE-----\nMIID1DCCAbwCAQEwDQYJKoZIhvcNAQEFBQAwgYgxCzAJBgNVBAYTAkRFMREwDwYD\nVQQIEwhTYWFybGFuZDEVMBMGA1UEBxMMU2FhcmJydWVja2VuMQ0wCwYDVQQKEwRh\ndnRxMRAwDgYDVQQLEwdob3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nga0gZvkpflxiJs6zFTnwx/ficAcHWDngY+d5m78CUUS6Agh8a6r8+TbishLzv5Xi\n7SafqACgm2JJN+2VDmY3AkBefIidvB3re7rBkUa/7x0AzXE1KIqDTHsyA1+Zw/+5\nDVyMxqPfW1XvQj5Vx2naUio7gy3zg5Y+v7+LbJY2g7Cc\n-----END RSA PRIVATE KEY-----", - "server_name"=>"eXample.de", - "organization_guid"=>"a-valid-org-guid", - "created_at"=>"2013-07-03T07:52:05Z", - "updated_at"=>"2013-07-03T07:52:05Z" + "server_name" => "eXample.de", + "organization_guid" => "a-valid-org-guid", + "created_at" => "2013-07-03T07:52:05Z", + "updated_at" => "2013-07-03T07:52:05Z" } end let :valid_payload_with_wildcard_server_name do { - "id"=>1, - "ssl_certificate"=> + "id" => 1, + "ssl_certificate" => "-----BEGIN CERTIFICATE-----\nMIID1DCCAbwCAQEwDQYJKoZIhvcNAQEFBQAwgYgxCzAJBgNVBAYTAkRFMREwDwYD\nVQQIEwhTYWFybGFuZDEVMBMGA1UEBxMMU2FhcmJydWVja2VuMQ0wCwYDVQQKEwRh\ndnRxMRAwDgYDVQQLEwdob3N0aW5nMQ0wCwYDVQQDEwRvbGxpMR8wHQYJKoZIhvcN\nAQkBFhBvd29sZkBhdmFydGVxLmRlMB4XDTEzMDYyNTA3NDg1MloXDTE0MDYyNTA3\nNDg1MlowWzELMAkGA1UEBhMCREUxEzARBgNVBAgTClNvbWUtU3RhdGUxCzAJBgNV\nBAcTAnNiMQwwCgYDVQQKEwNvcmcxDTALBgNVBAsTBHVuaXQxDTALBgNVBAMTBG5h\nbWUwgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBAJhiuU8QqHPlk+HEpcu861BH\ngVDUTOkjcqTHmWBcOafykhfCUrLe6gU1NHgA1z2vixuX87RCEqHb99wwWurCEc79\nyc+9LG2Va6khuC+X8xEH9/W0qul7E8u1OhwQVtTAVkv2AXFvhsOfUM+PN6EDdp8d\n4Fg53M9DY1PfKk0mc27hA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n8pIXwlKy\n3uoFNTR4ANc9r4sbl/O0QhKh2/fcMFrqwhHO/cnPvSxtlWupIbgvl/MRB/f1tKrp\nexPLtTocEFbUwFZL9gFxb4bDn1DPjzehA3afHeBYOdzPQ2NT3ypNJnNu4QIDAQAB\nAoGBAIdsZQbQ5QNqaUvguP8g+3aytUeiBF/EcuPhxnqOO2b3+cFHnrr7w7mxGNn0\n1VQqp1N0bM4rUeeqVtHF32Z15eBRM1cR+2OA4Tg1bs91OmC0Btpq/zNPGzhQCeN7\nNEXsnzJhP7MOg8RmXGL89vDMJfjGrg3bsBGQmTezJelAK7wJAkEAx3tzafAUlWGv\nwW5a1U2eRBKGVXXUgdnvn3TLaLArhDzzLJ4+o/42p9kAo4crVWRve/IZPF+wydb1\nLyCfs72qhwJBAMOPVUKecFj9sD3gVheMsYNPtxR6P1goHQkX6GGSLF1in5hweuoq\nhOMj1OR9ZzSRi27g0enrpoCanl4L9h9FbVcCQGHPUCnTg+Qy/8ByYatQ4ZczFhb1\nLXt15p5i4BG2v7+ZOwrXlJNIZHgsWLnV3xOBqYA2ltUZfk+ZTKMM9gFlsCUCQQCK\nga0gZvkpflxiJs6zFTnwx/ficAcHWDngY+d5m78CUUS6Agh8a6r8+TbishLzv5Xi\n7SafqACgm2JJN+2VDmY3AkBefIidvB3re7rBkUa/7x0AzXE1KIqDTHsyA1+Zw/+5\nDVyMxqPfW1XvQj5Vx2naUio7gy3zg5Y+v7+LbJY2g7Cc\n-----END RSA PRIVATE KEY-----", - "server_name"=>"*.eXample.de", - "organization_guid"=>"a-valid-org-guid", - "created_at"=>"2013-07-03T07:52:05Z", - "updated_at"=>"2013-07-03T07:52:05Z" + "server_name" => "*.eXample.de", + "organization_guid" => "a-valid-org-guid", + "created_at" => "2013-07-03T07:52:05Z", + "updated_at" => "2013-07-03T07:52:05Z" } end let :valid_payload_with_empty_ca_cert do { - "id"=>1, - "ssl_certificate"=> + "id" => 1, + "ssl_certificate" => "-----BEGIN CERTIFICATE-----\nM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+d5m78CUUS6Agh8a6r8+TbishLzv5Xi\n7SafqACgm2JJN+2VDmY3AkBefIidvB3re7rBkUa/7x0AzXE1KIqDTHsyA1+Zw/+5\nDVyMxqPfW1XvQj5Vx2naUio7gy3zg5Y+v7+LbJY2g7Cc\n-----END RSA PRIVATE KEY-----", - "server_name"=>"*.eXample.de", - "organization_guid"=>"a-valid-org-guid", - "created_at"=>"2013-07-03T07:52:05Z", - "updated_at"=>"2013-07-03T07:52:05Z" + "server_name" => "*.eXample.de", + "organization_guid" => "a-valid-org-guid", + "created_at" => "2013-07-03T07:52:05Z", + "updated_at" => "2013-07-03T07:52:05Z" } end @@ -55,19 +54,18 @@ error_log logs/error.log; pid logs/nginx.pid; worker_rlimit_nofile 8192; - + #{' '} events { worker_connections 4096; } - + http { index index.html index.htm index.php; } end_of_config end - + describe '.setup_v_host' do - before :each do `rm -f #{APP_CONFIG['cert_dir']}example.de/example.de.pem` `rm -f #{APP_CONFIG['cert_dir']}example.de/example.de.key` @@ -75,24 +73,23 @@ `rm -f #{APP_CONFIG['v_host_link_dir']}example.de.conf` if APP_CONFIG['v_host_link_dir'] `rm -f #{APP_CONFIG['v_host_link_dir']}wild.example.de.conf` if APP_CONFIG['v_host_link_dir'] end - + context 'with a valid cert, ca cert and ssl key' do - it 'should create the key file' do VirtualHostServiceWorker::NginxVHostWriter.setup_v_host(valid_payload) - expect(File.exists?("#{APP_CONFIG['v_host_config_dir']}/example.de.conf")).to be true + expect(File.exist?("#{APP_CONFIG['v_host_config_dir']}/example.de.conf")).to be true end - + it 'should create the cert key file' do VirtualHostServiceWorker::NginxVHostWriter.setup_v_host(valid_payload) - expect(File.exists?("#{APP_CONFIG['cert_dir']}/example.de/example.de.key")).to be true + expect(File.exist?("#{APP_CONFIG['cert_dir']}/example.de/example.de.key")).to be true end - + it 'should create the cert pem file' do VirtualHostServiceWorker::NginxVHostWriter.setup_v_host(valid_payload) - expect(File.exists?("#{APP_CONFIG['cert_dir']}/example.de/example.de.pem")).to be true + expect(File.exist?("#{APP_CONFIG['cert_dir']}/example.de/example.de.pem")).to be true end - + it 'should reload the nginx configuration' do VirtualHostServiceWorker::NginxVHostWriter.expects(:reload_config).once VirtualHostServiceWorker::NginxVHostWriter.setup_v_host(valid_payload) @@ -100,7 +97,7 @@ it 'should link the nginx configuration to the directory specified in the config' do VirtualHostServiceWorker::NginxVHostWriter.setup_v_host(valid_payload) - expect(File.exists?("#{APP_CONFIG['v_host_link_dir']}/example.de.conf")).to be true + expect(File.exist?("#{APP_CONFIG['v_host_link_dir']}/example.de.conf")).to be true end it 'should write the right pem certificate file path to the nginx configuration' do @@ -116,30 +113,29 @@ nginx_config_file_content = File.read("#{APP_CONFIG['v_host_link_dir']}/example.de.conf") expect(nginx_config_file_content).to include "#{APP_CONFIG['cert_dir']}example.de/example.de.key" end - end context 'without a ca certificate' do it 'should create the cert pem file' do VirtualHostServiceWorker::NginxVHostWriter.setup_v_host(valid_payload_with_empty_ca_cert) - expect(File.exists?("#{APP_CONFIG['cert_dir']}/wild.example.de/wild.example.de.pem")).to be true + expect(File.exist?("#{APP_CONFIG['cert_dir']}/wild.example.de/wild.example.de.pem")).to be true end end context 'with a wildcard server name' do it 'should replace the asterix in the certificates file name' do VirtualHostServiceWorker::NginxVHostWriter.setup_v_host(valid_payload_with_wildcard_server_name) - expect(File.exists?("#{APP_CONFIG['cert_dir']}/wild.example.de/wild.example.de.pem")).to be true + expect(File.exist?("#{APP_CONFIG['cert_dir']}/wild.example.de/wild.example.de.pem")).to be true end it 'should replace the asterix in the key file name' do VirtualHostServiceWorker::NginxVHostWriter.setup_v_host(valid_payload_with_wildcard_server_name) - expect(File.exists?("#{APP_CONFIG['cert_dir']}/wild.example.de/wild.example.de.key")).to be true + expect(File.exist?("#{APP_CONFIG['cert_dir']}/wild.example.de/wild.example.de.key")).to be true end - + it 'should replace the asterix in the server config file' do VirtualHostServiceWorker::NginxVHostWriter.setup_v_host(valid_payload_with_wildcard_server_name) - expect(File.exists?("#{APP_CONFIG['v_host_config_dir']}/wild.example.de.conf")).to be true + expect(File.exist?("#{APP_CONFIG['v_host_config_dir']}/wild.example.de.conf")).to be true end it 'should write the right pem certificate file path to the nginx configuration' do @@ -157,7 +153,7 @@ end it 'should not replace the asterisk in the server name for the nginx server name configuration field' do - VirtualHostServiceWorker::NginxVHostWriter.setup_v_host(valid_payload_with_wildcard_server_name) + VirtualHostServiceWorker::NginxVHostWriter.setup_v_host(valid_payload_with_wildcard_server_name) nginx_config_file_content = File.read("#{APP_CONFIG['v_host_link_dir']}wild.example.de.conf") expect(nginx_config_file_content).to include "server_name *.example.de" @@ -165,14 +161,13 @@ end context 'with a server name already existing in the webserver config' do - before :each do `mkdir #{APP_CONFIG['cert_dir']}example.de` - `echo '#{'content_to_override'*1000}' > #{APP_CONFIG['cert_dir']}example.de/example.de.pem` - `echo '#{'content_to_override'*1000}' > #{APP_CONFIG['cert_dir']}example.de/example.de.key` - `echo '#{'content_to_override'*1000}' > #{APP_CONFIG['v_host_config_dir']}example.de.conf` - `echo '#{'content_to_override'*1000}' > #{APP_CONFIG['v_host_link_dir']}example.de.conf` if APP_CONFIG['v_host_link_dir'] - `echo '#{'content_to_override'*1000}' > #{APP_CONFIG['v_host_link_dir']}wild.example.de.conf` if APP_CONFIG['v_host_link_dir'] + `echo '#{'content_to_override' * 1000}' > #{APP_CONFIG['cert_dir']}example.de/example.de.pem` + `echo '#{'content_to_override' * 1000}' > #{APP_CONFIG['cert_dir']}example.de/example.de.key` + `echo '#{'content_to_override' * 1000}' > #{APP_CONFIG['v_host_config_dir']}example.de.conf` + `echo '#{'content_to_override' * 1000}' > #{APP_CONFIG['v_host_link_dir']}example.de.conf` if APP_CONFIG['v_host_link_dir'] + `echo '#{'content_to_override' * 1000}' > #{APP_CONFIG['v_host_link_dir']}wild.example.de.conf` if APP_CONFIG['v_host_link_dir'] end it 'should find the existing files (the before each in the test should work)' do @@ -181,52 +176,48 @@ it 'should replace the cert pem file' do VirtualHostServiceWorker::NginxVHostWriter.setup_v_host(valid_payload) - expect(File.read("#{APP_CONFIG['cert_dir']}example.de/example.de.pem")).not_to include 'content_to_override' + expect(File.read("#{APP_CONFIG['cert_dir']}example.de/example.de.pem")).not_to include 'content_to_override' end it 'should replace the ssl key' do VirtualHostServiceWorker::NginxVHostWriter.setup_v_host(valid_payload) - expect(File.read("#{APP_CONFIG['cert_dir']}example.de/example.de.key")).not_to include 'content_to_override' + expect(File.read("#{APP_CONFIG['cert_dir']}example.de/example.de.key")).not_to include 'content_to_override' end it 'should replace the config file' do VirtualHostServiceWorker::NginxVHostWriter.setup_v_host(valid_payload) - expect(File.read("#{APP_CONFIG['v_host_config_dir']}/wild.example.de.conf")).not_to include 'content_to_override' + expect(File.read("#{APP_CONFIG['v_host_config_dir']}/wild.example.de.conf")).not_to include 'content_to_override' end - end - end - + describe '.delete_v_host' do - context 'with a not existing virtual host' do it 'should do nothing and should not raise an exception' do end end context 'with a existing virtual host' do - before :each do - `rm -f #{APP_CONFIG['v_host_link_dir']}example.de.conf` if APP_CONFIG['v_host_link_dir'] + `rm -f #{APP_CONFIG['v_host_link_dir']}example.de.conf` if APP_CONFIG['v_host_link_dir'] VirtualHostServiceWorker::NginxVHostWriter.setup_v_host(valid_payload) end - + it 'should delete the vhost config file' do VirtualHostServiceWorker::NginxVHostWriter.delete_v_host('eXample.de') - expect(File.exists?("#{APP_CONFIG['v_host_config_dir']}example.de.conf")).to be false + expect(File.exist?("#{APP_CONFIG['v_host_config_dir']}example.de.conf")).to be false end - + it 'should delete the ssl key file' do VirtualHostServiceWorker::NginxVHostWriter.delete_v_host('eXample.de') - expect(File.exists?("#{APP_CONFIG['cert_dir']}example.de/example.de.key")).to be false + expect(File.exist?("#{APP_CONFIG['cert_dir']}example.de/example.de.key")).to be false end - + it 'should delete the pem file' do VirtualHostServiceWorker::NginxVHostWriter.delete_v_host('eXample.de') - expect(File.exists?("#{APP_CONFIG['cert_dir']}example.de/example.de.pem")).to be false + expect(File.exist?("#{APP_CONFIG['cert_dir']}example.de/example.de.pem")).to be false end - + it 'should reload the nginx configuration' do VirtualHostServiceWorker::NginxVHostWriter.expects(:reload_config).once VirtualHostServiceWorker::NginxVHostWriter.delete_v_host('eXample.de') @@ -236,45 +227,36 @@ VirtualHostServiceWorker::NginxVHostWriter.delete_v_host('eXample.de') expect(File.symlink?("#{APP_CONFIG['v_host_link_dir']}example.de.conf")).to be false end - end - end - + describe '.config_valid?' do context 'with a valid config file' do - before :each do APP_CONFIG['webserver_config'] = "#{APP_CONFIG['v_host_config_dir']}valid_nginx.conf" - + File.open(APP_CONFIG['webserver_config'], 'w') do |f| f.write(valid_nginx_config) end - end - + it 'should be true' do expect(VirtualHostServiceWorker::NginxVHostWriter.config_valid?).to be true end - end - + context 'with an invalid config file' do - before :each do APP_CONFIG['webserver_config'] = "#{APP_CONFIG['v_host_config_dir']}invalid_nginx.conf" - + File.open(APP_CONFIG['webserver_config'], 'w') do |f| f.write(APP_CONFIG['webserver_config'] + 'syntaxerror') end end - + it 'should raise Exception' do - expect{VirtualHostServiceWorker::NginxVHostWriter.config_valid?}.to raise_error + expect { VirtualHostServiceWorker::NginxVHostWriter.config_valid? }.to raise_error end - end - end - -end \ No newline at end of file +end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 3cdb986..c520bcb 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,4 +1,4 @@ -DAEMON_ENV = 'test' unless defined?( DAEMON_ENV ) +DAEMON_ENV = 'test' unless defined?(DAEMON_ENV) require 'rspec' require 'mocha' @@ -16,24 +16,24 @@ FileUtils.mkdir_p('tmp/haproxy/config') APP_CONFIG = { - "amqp_channel" => "channel", - "queue_id" => 123, - "cert_dir" => File.expand_path('../../tmp/cert_dir', __FILE__) + '/', + "amqp_channel" => "channel", + "queue_id" => 123, + "cert_dir" => File.expand_path('../../tmp/cert_dir', __FILE__) + '/', "v_host_config_dir" => File.expand_path('../../tmp/v_host_config_dir', __FILE__) + '/', - "v_host_link_dir" => File.expand_path('../../tmp/v_host_link_dir', __FILE__) + '/', - "webserver_config" => File.expand_path('../../tmp/webserver_config', __FILE__), - "shared_config" => File.expand_path('../../tmp/shared_config',__FILE__), - "upstream_config" => File.expand_path('../../tmp/upstream_config', __FILE__), - "nginx_command" => File.expand_path('../../spec/support/nginx_dummy', __FILE__), - "routers" => [], - - "haproxy_command" => File.expand_path('../../spec/support/haproxy_dummy', __FILE__), - "haproxy_reload" => File.expand_path('../../spec/support/haproxy_dummy', __FILE__), - "haproxy_dir" => File.expand_path('../../tmp/haproxy/', __FILE__), - "haproxy_config" => File.expand_path('../../tmp/haproxy/config/haproxy.cfg', __FILE__), - "haproxy_cert_dir" => File.expand_path('../../tmp/haproxy/certificates', __FILE__) + '/', - "haproxy_cert_list" => File.expand_path('../../tmp/haproxy/haproxy-certificate-list', __FILE__), - "haproxy_ssl_ciphers" => "[alpn h2 ssl-min-ver TLSv1.2]", + "v_host_link_dir" => File.expand_path('../../tmp/v_host_link_dir', __FILE__) + '/', + "webserver_config" => File.expand_path('../../tmp/webserver_config', __FILE__), + "shared_config" => File.expand_path('../../tmp/shared_config', __FILE__), + "upstream_config" => File.expand_path('../../tmp/upstream_config', __FILE__), + "nginx_command" => File.expand_path('../../spec/support/nginx_dummy', __FILE__), + "routers" => [], + + "haproxy_command" => File.expand_path('../../spec/support/haproxy_dummy', __FILE__), + "haproxy_reload" => File.expand_path('../../spec/support/haproxy_dummy', __FILE__), + "haproxy_dir" => File.expand_path('../../tmp/haproxy/', __FILE__), + "haproxy_config" => File.expand_path('../../tmp/haproxy/config/haproxy.cfg', __FILE__), + "haproxy_cert_dir" => File.expand_path('../../tmp/haproxy/certificates', __FILE__) + '/', + "haproxy_cert_list" => File.expand_path('../../tmp/haproxy/haproxy-certificate-list', __FILE__), + "haproxy_ssl_ciphers" => "[alpn h2 ssl-min-ver TLSv1.2]", } DaemonKit::Application.running! diff --git a/tasks/rspec.rake b/tasks/rspec.rake index 2078b66..a974c16 100644 --- a/tasks/rspec.rake +++ b/tasks/rspec.rake @@ -9,5 +9,5 @@ if ['test', 'development'].include?(DAEMON_ENV) # Want other tests/tasks run by default? # Add them to the list - task :default => [:spec] #, :features] + task :default => [:spec] # , :features] end From 9aec7b3f6bbe084085482fc69be6ff17d7130246 Mon Sep 17 00:00:00 2001 From: Jan-Robin Aumann Date: Tue, 4 Nov 2025 09:23:38 +0100 Subject: [PATCH 4/4] rubocop auto fixes --- .../amqp_dispatcher.rb | 9 +++-- .../haproxy_v_host_writer.rb | 4 +-- .../amqp_dispatcher_spec.rb | 36 +++++++++---------- .../haproxy_v_host_writer_spec.rb | 3 -- 4 files changed, 24 insertions(+), 28 deletions(-) diff --git a/lib/virtual_host_service_worker/amqp_dispatcher.rb b/lib/virtual_host_service_worker/amqp_dispatcher.rb index a7fc989..d6588c4 100644 --- a/lib/virtual_host_service_worker/amqp_dispatcher.rb +++ b/lib/virtual_host_service_worker/amqp_dispatcher.rb @@ -1,20 +1,19 @@ module VirtualHostServiceWorker class AmqpDispatcher - def self.push_reload_to_amqp AMQP.start(APP_CONFIG['amqp']) do |connection| channel = AMQP::Channel.new(connection) exchange = channel.fanout(APP_CONFIG['amqp_channel'], :durable => true) - + payload = { :action => 'reload', } - + exchange.publish(payload.to_json, :persistent => true) do connection.close { EventMachine.stop } end end - + return true end @@ -36,7 +35,7 @@ def self.dispatch(payload) if payload['ssl_certificate'] and payload['ssl_ca_certificate'] and payload['ssl_key'] DaemonKit.logger.info("adding a new vhost: #{payload['server_name']}") - + if APP_CONFIG['use_haproxy'] == true VirtualHostServiceWorker::HaproxyVHostWriter.setup_v_host(payload) DaemonKit.logger.info("HAProxy - Succesfully added vhost #{payload['server_name']}") diff --git a/lib/virtual_host_service_worker/haproxy_v_host_writer.rb b/lib/virtual_host_service_worker/haproxy_v_host_writer.rb index 2d97b20..9b19bd9 100644 --- a/lib/virtual_host_service_worker/haproxy_v_host_writer.rb +++ b/lib/virtual_host_service_worker/haproxy_v_host_writer.rb @@ -75,8 +75,8 @@ def self.reload_config def self.haproxy_instance_limit_reached? currentInstances = `(ps aux | grep haproxy | wc -l)` - result = ((currentInstances.strip.to_i -1) >= APP_CONFIG['haproxy_reload_max_instances'].to_i) - + result = ((currentInstances.strip.to_i(-1)) >= APP_CONFIG['haproxy_reload_max_instances'].to_i) + return result end diff --git a/spec/lib/virtual_host_service_worker/amqp_dispatcher_spec.rb b/spec/lib/virtual_host_service_worker/amqp_dispatcher_spec.rb index 1bf0d46..38d9ca0 100644 --- a/spec/lib/virtual_host_service_worker/amqp_dispatcher_spec.rb +++ b/spec/lib/virtual_host_service_worker/amqp_dispatcher_spec.rb @@ -7,7 +7,7 @@ let(:exchange) { double('exchange') } let(:server_name) { 'test_name' } - let (:valid_payload) do + let(:valid_payload) do { 'id' => 1, 'ssl_certificate' => @@ -29,23 +29,23 @@ } end - before do + before do stub_const('APP_CONFIG', { - 'use_haproxy' => true, - 'haproxy_reload_max_instances' => 4, - 'haproxy_command' => File.expand_path('../../../support/haproxy_dummy', __FILE__), - 'haproxy_reload' => File.expand_path('../../../support/haproxy_dummy', __FILE__), - 'haproxy_dir' => File.expand_path('../../tmp/haproxy/', __FILE__), - 'haproxy_config' => File.expand_path('../../tmp/haproxy/config/haproxy.cfg', __FILE__), - 'haproxy_cert_dir' => File.expand_path('../../tmp/haproxy/certificates', __FILE__) + '/', - 'haproxy_cert_list' => File.expand_path('../../tmp/haproxy/haproxy-certificate-list', __FILE__), - 'haproxy_ssl_ciphers' => "[alpn h2 ssl-min-ver TLSv1.2]", - 'amqp' => { host: 'localhost' }, - 'amqp_channel' => 'test_channel' - }) + 'use_haproxy' => true, + 'haproxy_reload_max_instances' => 4, + 'haproxy_command' => File.expand_path('../../../support/haproxy_dummy', __FILE__), + 'haproxy_reload' => File.expand_path('../../../support/haproxy_dummy', __FILE__), + 'haproxy_dir' => File.expand_path('../../tmp/haproxy/', __FILE__), + 'haproxy_config' => File.expand_path('../../tmp/haproxy/config/haproxy.cfg', __FILE__), + 'haproxy_cert_dir' => File.expand_path('../../tmp/haproxy/certificates', __FILE__) + '/', + 'haproxy_cert_list' => File.expand_path('../../tmp/haproxy/haproxy-certificate-list', __FILE__), + 'haproxy_ssl_ciphers' => "[alpn h2 ssl-min-ver TLSv1.2]", + 'amqp' => { host: 'localhost' }, + 'amqp_channel' => 'test_channel' + }) allow(described_class).to receive(:server_name).and_return(server_name) - + allow(AMQP).to receive(:start).and_yield(connection) allow(AMQP::Channel).to receive(:new).with(connection).and_return(channel) allow(channel).to receive(:fanout).with('test_channel', durable: true).and_return(exchange) @@ -64,9 +64,9 @@ described_class.push_reload_to_amqp expected_payload = { action: 'reload', - }.to_json + }.to_json - expect(exchange).to have_received(:publish).with(expected_payload, persistent: true) + expect(exchange).to have_received(:publish).with(expected_payload, persistent: true) end it 'reqeus when haproxy instance limit reached' do @@ -80,4 +80,4 @@ described_class.dispatch(reload_payload) end end -end \ No newline at end of file +end diff --git a/spec/lib/virtual_host_service_worker/haproxy_v_host_writer_spec.rb b/spec/lib/virtual_host_service_worker/haproxy_v_host_writer_spec.rb index 8e0ccdf..1716786 100644 --- a/spec/lib/virtual_host_service_worker/haproxy_v_host_writer_spec.rb +++ b/spec/lib/virtual_host_service_worker/haproxy_v_host_writer_spec.rb @@ -94,9 +94,6 @@ end describe '.setup_v_host' do - - - context 'with a valid cert, ca cert and ssl key' do it 'should create .pem file' do VirtualHostServiceWorker::HaproxyVHostWriter.setup_v_host(valid_payload)