diff options
-rw-r--r-- | .rubocop.yml | 14 | ||||
-rw-r--r-- | .rubocop_todo.yml | 393 | ||||
-rw-r--r-- | Rakefile | 8 | ||||
-rwxr-xr-x | bin/nickserver | 2 | ||||
-rw-r--r-- | lib/nickserver/couch/fetch_key.rb | 2 | ||||
-rw-r--r-- | lib/nickserver/daemon.rb | 4 | ||||
-rw-r--r-- | lib/nickserver/hkp/fetch_key.rb | 4 | ||||
-rw-r--r-- | lib/nickserver/hkp/fetch_key_info.rb | 4 | ||||
-rw-r--r-- | lib/nickserver/server.rb | 12 | ||||
-rw-r--r-- | test/test_helper.rb | 12 | ||||
-rw-r--r-- | test/unit/hkp_test.rb | 18 | ||||
-rw-r--r-- | test/unit/nickserver_test.rb | 24 |
12 files changed, 453 insertions, 44 deletions
diff --git a/.rubocop.yml b/.rubocop.yml new file mode 100644 index 0000000..652bfba --- /dev/null +++ b/.rubocop.yml @@ -0,0 +1,14 @@ +inherit_from: .rubocop_todo.yml + +Style/GuardClause: + Enabled: false + +Style/HashSyntax: + EnforcedStyle: ruby19_no_mixed_keys + +Lint/DeprecatedClassMethods: + Enabled: true + +# complains about our nested module end; end style +Lint/EndAlignment: + Enabled: false diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml new file mode 100644 index 0000000..e636a8b --- /dev/null +++ b/.rubocop_todo.yml @@ -0,0 +1,393 @@ +# This configuration was generated by +# `rubocop --auto-gen-config` +# on 2016-05-25 12:42:07 +0200 using RuboCop version 0.40.0. +# The point is for the user to remove these configuration records +# one by one as the offenses are removed from the code base. +# Note that changes in the inspected code, or installation of new +# versions of RuboCop, may require this file to be generated again. + +# Offense count: 1 +Lint/AmbiguousRegexpLiteral: + Exclude: + - 'lib/nickserver/daemon.rb' + +# Offense count: 2 +# Configuration parameters: AllowSafeAssignment. +Lint/AssignmentInCondition: + Exclude: + - 'Rakefile' + - 'lib/nickserver/daemon.rb' + +# Offense count: 1 +Lint/Eval: + Exclude: + - 'Rakefile' + +# Offense count: 2 +Lint/HandleExceptions: + Exclude: + - 'Rakefile' + +# Offense count: 3 +Lint/IneffectiveAccessModifier: + Exclude: + - 'lib/nickserver/config.rb' + - 'lib/nickserver/couch/fetch_key.rb' + +# Offense count: 2 +Lint/NonLocalExitFromIterator: + Exclude: + - 'test/unit/hkp_test.rb' + +# Offense count: 2 +Lint/RescueException: + Exclude: + - 'lib/nickserver/config.rb' + - 'lib/nickserver/couch/fetch_key.rb' + +# Offense count: 5 +# Cop supports --auto-correct. +# Configuration parameters: AllowUnusedKeywordArguments, IgnoreEmptyMethods. +Lint/UnusedMethodArgument: + Exclude: + - 'lib/nickserver/couch/fetch_key.rb' + - 'lib/nickserver/daemon.rb' + - 'test/unit/hkp_test.rb' + +# Offense count: 1 +Lint/UselessAccessModifier: + Exclude: + - 'lib/nickserver/config.rb' + +# Offense count: 7 +Lint/UselessAssignment: + Exclude: + - 'lib/nickserver/config.rb' + - 'lib/nickserver/daemon.rb' + - 'lib/nickserver/hkp/key_info.rb' + - 'test/unit/hkp_test.rb' + +# Offense count: 7 +Metrics/AbcSize: + Max: 19 + +# Offense count: 3 +# Configuration parameters: CountComments. +Metrics/ClassLength: + Max: 213 + +# Offense count: 2 +Metrics/CyclomaticComplexity: + Max: 10 + +# Offense count: 49 +# Configuration parameters: AllowHeredoc, AllowURI, URISchemes. +# URISchemes: http, https +Metrics/LineLength: + Max: 229 + +# Offense count: 21 +# Configuration parameters: CountComments. +Metrics/MethodLength: + Max: 17 + +# Offense count: 2 +Metrics/PerceivedComplexity: + Max: 8 + +# Offense count: 1 +# Cop supports --auto-correct. +Performance/RedundantBlockCall: + Exclude: + - 'lib/nickserver/daemon.rb' + +# Offense count: 1 +Style/AccessorMethodName: + Exclude: + - 'lib/nickserver/server.rb' + +# Offense count: 18 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, SupportedStyles, ProceduralMethods, FunctionalMethods, IgnoredMethods. +# SupportedStyles: line_count_based, semantic, braces_for_chaining +# ProceduralMethods: benchmark, bm, bmbm, create, each_with_object, measure, new, realtime, tap, with_object +# FunctionalMethods: let, let!, subject, watch +# IgnoredMethods: lambda, proc, it +Style/BlockDelimiters: + Exclude: + - 'lib/nickserver/couch/fetch_key.rb' + - 'lib/nickserver/daemon.rb' + - 'lib/nickserver/hkp/fetch_key.rb' + - 'lib/nickserver/hkp/fetch_key_info.rb' + - 'lib/nickserver/server.rb' + - 'test/unit/hkp_test.rb' + - 'test/unit/nickserver_test.rb' + +# Offense count: 8 +# Cop supports --auto-correct. +# Configuration parameters: IndentWhenRelativeTo, SupportedStyles, IndentOneStep, IndentationWidth. +# SupportedStyles: case, end +Style/CaseIndentation: + Enabled: false + +# Offense count: 1 +# Configuration parameters: EnforcedStyle, SupportedStyles. +# SupportedStyles: nested, compact +Style/ClassAndModuleChildren: + Exclude: + - 'test/test_helper.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +Style/ColonMethodCall: + Exclude: + - 'test/unit/nickserver_test.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +Style/CommentIndentation: + Exclude: + - 'test/unit/hkp_test.rb' + +# Offense count: 1 +Style/ConstantName: + Exclude: + - 'lib/nickserver/email_address.rb' + +# Offense count: 8 +Style/Documentation: + Exclude: + - 'spec/**/*' + - 'test/**/*' + - 'lib/nickserver/config.rb' + - 'lib/nickserver/couch/fetch_key.rb' + - 'lib/nickserver/daemon.rb' + - 'lib/nickserver/hkp/fetch_key.rb' + - 'lib/nickserver/hkp/fetch_key_info.rb' + - 'lib/nickserver/hkp/key_info.rb' + - 'lib/nickserver/hkp/parse_key_info.rb' + - 'lib/nickserver/server.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +Style/ElseAlignment: + Exclude: + - 'lib/nickserver/server.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, SupportedStyles. +# SupportedStyles: empty, nil, both +Style/EmptyElse: + Exclude: + - 'lib/nickserver/daemon.rb' + +# Offense count: 10 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, SupportedStyles. +# SupportedStyles: empty_lines, no_empty_lines +Style/EmptyLinesAroundClassBody: + Exclude: + - 'lib/nickserver/couch/fetch_key.rb' + - 'lib/nickserver/daemon.rb' + - 'lib/nickserver/hkp/fetch_key_info.rb' + - 'lib/nickserver/hkp/parse_key_info.rb' + - 'test/test_helper.rb' + - 'test/unit/hkp_test.rb' + - 'test/unit/nickserver_test.rb' + +# Offense count: 4 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, SupportedStyles. +# SupportedStyles: empty_lines, no_empty_lines +Style/EmptyLinesAroundModuleBody: + Exclude: + - 'lib/nickserver/hkp/fetch_key.rb' + - 'lib/nickserver/hkp/fetch_key_info.rb' + - 'lib/nickserver/hkp/key_info.rb' + +# Offense count: 1 +# Configuration parameters: EnforcedStyle, SupportedStyles. +# SupportedStyles: format, sprintf, percent +Style/FormatString: + Exclude: + - 'test/test_helper.rb' + +# Offense count: 35 +# Configuration parameters: AllowedVariables. +Style/GlobalVars: + Exclude: + - 'Rakefile' + +# Offense count: 3 +# Cop supports --auto-correct. +# Configuration parameters: MaxLineLength. +Style/IfUnlessModifier: + Exclude: + - 'lib/nickserver/daemon.rb' + - 'lib/nickserver/hkp/key_info.rb' + +# Offense count: 6 +# Cop supports --auto-correct. +# Configuration parameters: Width. +Style/IndentationWidth: + Exclude: + - 'lib/nickserver/couch/fetch_key.rb' + - 'lib/nickserver/hkp/fetch_key.rb' + - 'lib/nickserver/hkp/fetch_key_info.rb' + - 'lib/nickserver/hkp/key_info.rb' + - 'lib/nickserver/hkp/parse_key_info.rb' + - 'lib/nickserver/server.rb' + +# Offense count: 2 +# Cop supports --auto-correct. +Style/LeadingCommentSpace: + Exclude: + - 'Rakefile' + - 'test/unit/hkp_test.rb' + +# Offense count: 6 +# Configuration parameters: EnforcedStyle, SupportedStyles. +# SupportedStyles: snake_case, camelCase +Style/MethodName: + Enabled: false + +# Offense count: 5 +Style/MultilineBlockChain: + Exclude: + - 'lib/nickserver/couch/fetch_key.rb' + - 'lib/nickserver/hkp/fetch_key.rb' + - 'lib/nickserver/hkp/fetch_key_info.rb' + - 'lib/nickserver/server.rb' + - 'test/unit/nickserver_test.rb' + +# Offense count: 3 +# Cop supports --auto-correct. +Style/MutableConstant: + Exclude: + - 'lib/nickserver/config.rb' + - 'lib/nickserver/couch/fetch_key.rb' + - 'lib/nickserver/version.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +Style/NegatedIf: + Exclude: + - 'bin/nickserver' + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: PreferredDelimiters. +Style/PercentLiteralDelimiters: + Exclude: + - 'nickserver.gemspec' + +# Offense count: 2 +# Cop supports --auto-correct. +Style/RedundantBegin: + Exclude: + - 'lib/nickserver/config.rb' + - 'lib/nickserver/daemon.rb' + +# Offense count: 16 +# Cop supports --auto-correct. +Style/RedundantSelf: + Exclude: + - 'lib/nickserver/config.rb' + - 'lib/nickserver/couch/fetch_key.rb' + - 'lib/nickserver/daemon.rb' + - 'lib/nickserver/hkp/fetch_key.rb' + - 'lib/nickserver/hkp/fetch_key_info.rb' + +# Offense count: 7 +# Cop supports --auto-correct. +# Configuration parameters: AllowAsExpressionSeparator. +Style/Semicolon: + Exclude: + - 'lib/nickserver/daemon.rb' + +# Offense count: 2 +# Cop supports --auto-correct. +Style/SpaceAfterComma: + Exclude: + - 'lib/nickserver/hkp/fetch_key.rb' + - 'test/unit/nickserver_test.rb' + +# Offense count: 4 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, SupportedStyles. +# SupportedStyles: space, no_space +Style/SpaceAroundEqualsInParameterDefault: + Enabled: false + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: AllowForAlignment. +Style/SpaceAroundOperators: + Exclude: + - 'test/test_helper.rb' + +# Offense count: 3 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, SupportedStyles. +# SupportedStyles: space, no_space +Style/SpaceBeforeBlockBraces: + Enabled: false + +# Offense count: 5 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, SupportedStyles, EnforcedStyleForEmptyBraces, SpaceBeforeBlockParameters. +# SupportedStyles: space, no_space +Style/SpaceInsideBlockBraces: + Enabled: false + +# Offense count: 46 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces, SupportedStyles. +# SupportedStyles: space, no_space +Style/SpaceInsideHashLiteralBraces: + Enabled: false + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, SupportedStyles. +# SupportedStyles: use_perl_names, use_english_names +Style/SpecialGlobalVars: + Enabled: false + +# Offense count: 83 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, SupportedStyles, ConsistentQuotesInMultiline. +# SupportedStyles: single_quotes, double_quotes +Style/StringLiterals: + Enabled: false + +# Offense count: 4 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, SupportedStyles. +# SupportedStyles: final_newline, final_blank_line +Style/TrailingBlankLines: + Exclude: + - 'bin/nickserver' + - 'lib/nickserver/couch/fetch_key.rb' + - 'lib/nickserver/hkp/fetch_key.rb' + - 'test/unit/test_helper.rb' + +# Offense count: 2 +# Cop supports --auto-correct. +Style/UnneededPercentQ: + Exclude: + - 'nickserver.gemspec' + +# Offense count: 1 +# Cop supports --auto-correct. +Style/WhileUntilDo: + Exclude: + - 'Rakefile' + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: SupportedStyles, MinSize, WordRegex. +# SupportedStyles: percent, brackets +Style/WordArray: + EnforcedStyle: brackets @@ -10,9 +10,11 @@ require "rake/testtask" ## Rake::TestTask.new do |t| - t.pattern = "test/unit/*_test.rb" + t.pattern = "test/**/*_test.rb" + t.libs << "test" + t.verbose = true end -task :default => :test +task default: :test ## ## GEM BUILDING AND INSTALLING @@ -24,7 +26,7 @@ $spec = eval(File.read(File.join($base_dir, $spec_path))) $gem_path = File.join($base_dir, 'pkg', "#{$spec.name}-#{$spec.version}.gem") def run(cmd) - PTY.spawn(cmd) do |output, input, pid| + PTY.spawn(cmd) do |output, _input, _pid| begin while line = output.gets do puts line diff --git a/bin/nickserver b/bin/nickserver index 062684f..f3795bf 100755 --- a/bin/nickserver +++ b/bin/nickserver @@ -7,7 +7,7 @@ def load_local_gem(dir_path='../..') base_directory = File.expand_path(dir_path, File.symlink?(__FILE__) ? File.readlink(__FILE__) : __FILE__) if !$LOAD_PATH.include? "#{base_directory}/lib" - if File.exists?("#{base_directory}/Gemfile.lock") + if File.exist?("#{base_directory}/Gemfile.lock") ENV['BUNDLE_GEMFILE'] ||= "#{base_directory}/Gemfile" require 'bundler' Bundler.require(:default) diff --git a/lib/nickserver/couch/fetch_key.rb b/lib/nickserver/couch/fetch_key.rb index c671515..3fe2a63 100644 --- a/lib/nickserver/couch/fetch_key.rb +++ b/lib/nickserver/couch/fetch_key.rb @@ -24,7 +24,7 @@ module Nickserver; module Couch # def couch_request(uid) query = {"reduce" => "false", "key" => "\"#{uid}\""} - request = EventMachine::HttpRequest.new(FetchKey.couch_url).get(:timeout => @timeout, :query => query) + request = EventMachine::HttpRequest.new(FetchKey.couch_url).get(timeout: @timeout, query: query) request.callback {|http| if http.response_header.status != 200 self.fail http.response_header.status, 'Unknown Error' diff --git a/lib/nickserver/daemon.rb b/lib/nickserver/daemon.rb index 36fe581..7d0f02a 100644 --- a/lib/nickserver/daemon.rb +++ b/lib/nickserver/daemon.rb @@ -105,7 +105,7 @@ module Nickserver def kill_pid file = Config.pid_file - if File.exists?(file) + if File.exist?(file) pid = pid_from_file(file) if pid Process.kill('TERM', pid) @@ -164,7 +164,7 @@ module Nickserver # def redirect_output if log_path = Config.log_file - FileUtils.mkdir_p File.dirname(log_path), :mode => 0755 + FileUtils.mkdir_p File.dirname(log_path), mode: 0755 FileUtils.touch log_path File.chmod(0600, log_path) if Config.user && Process::Sys.getuid == 0 diff --git a/lib/nickserver/hkp/fetch_key.rb b/lib/nickserver/hkp/fetch_key.rb index c24b2c7..44621d3 100644 --- a/lib/nickserver/hkp/fetch_key.rb +++ b/lib/nickserver/hkp/fetch_key.rb @@ -26,8 +26,8 @@ module Nickserver; module HKP # fetches ascii armored OpenPGP public key from the keyserver # def get_key_by_fingerprint(key_id) - params = {:op => 'get', :search => "0x" + key_id, :exact => 'on', :options => 'mr'} - http = EventMachine::HttpRequest.new(Config.hkp_url).get(:query => params) + params = {op: 'get', search: "0x" + key_id, exact: 'on', options: 'mr'} + http = EventMachine::HttpRequest.new(Config.hkp_url).get(query: params) http.callback { if http.response_header.status != 200 self.fail http.response_header.status, "HKP Request failed" diff --git a/lib/nickserver/hkp/fetch_key_info.rb b/lib/nickserver/hkp/fetch_key_info.rb index bc12488..2448bb1 100644 --- a/lib/nickserver/hkp/fetch_key_info.rb +++ b/lib/nickserver/hkp/fetch_key_info.rb @@ -10,8 +10,8 @@ module Nickserver; module HKP def search(uid) # in practice, exact=on seems to have no effect - params = {:op => 'vindex', :search => uid, :exact => 'on', :options => 'mr', :fingerprint => 'on'} - EventMachine::HttpRequest.new(Config.hkp_url).get(:query => params).callback {|http| + params = {op: 'vindex', search: uid, exact: 'on', options: 'mr', fingerprint: 'on'} + EventMachine::HttpRequest.new(Config.hkp_url).get(query: params).callback {|http| parser = ParseKeyInfo.new http.response_header, http.response keys = parser.keys(uid) if keys.any? diff --git a/lib/nickserver/server.rb b/lib/nickserver/server.rb index 9487b43..32afdae 100644 --- a/lib/nickserver/server.rb +++ b/lib/nickserver/server.rb @@ -21,7 +21,7 @@ module Nickserver # def self.start(opts={}) Nickserver::Config.load - options = {:host => '127.0.0.1', :port => Nickserver::Config.port.to_i}.merge(opts) + options = {host: '127.0.0.1', port: Nickserver::Config.port.to_i}.merge(opts) unless defined?(TESTING) puts "Starting nickserver #{options[:host]}:#{options[:port]}" end @@ -51,15 +51,15 @@ module Nickserver private def send_error(msg = "not supported") - send_response(:status => 500, :content => "500 #{msg}\n") + send_response(status: 500, content: "500 #{msg}\n") end def send_not_found(msg = "Not Found") - send_response(:status => 404, :content => "404 #{msg}\n") + send_response(status: 404, content: "404 #{msg}\n") end def send_response(opts = {}) - options = {:status => 200, :content_type => 'text/plain', :content => ''}.merge(opts) + options = {status: 200, content_type: 'text/plain', content: ''}.merge(opts) response = EM::DelegatedHttpResponse.new(self) response.status = options[:status] response.content_type options[:content_type] @@ -69,7 +69,7 @@ module Nickserver def send_key(uid) get_key_from_uid(uid) do |key| - send_response :content => format_response(:address => uid, :openpgp => key) + send_response content: format_response(address: uid, openpgp: key) end end @@ -98,7 +98,7 @@ module Nickserver if status == 404 send_not_found else - send_response(:status => status, :content => msg) + send_response(status: status, content: msg) end } end diff --git a/test/test_helper.rb b/test/test_helper.rb index 7fbe400..d4765bc 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -15,7 +15,7 @@ class Minitest::Test Nickserver::Config.load # by default, mock all non-localhost network connections - WebMock.disable_net_connect!(:allow_localhost => true) + WebMock.disable_net_connect!(allow_localhost: true) end def file_content(filename) @@ -35,23 +35,23 @@ class Minitest::Test end def stub_sks_vindex_reponse(uid, opts = {}) - options = {:status => 200, :body => ""}.merge(opts) + options = {status: 200, body: ""}.merge(opts) stub_http_request(:get, Nickserver::Config.hkp_url).with( - :query => {:op => 'vindex', :search => uid, :exact => 'on', :options => 'mr', :fingerprint => 'on'} + query: {op: 'vindex', search: uid, exact: 'on', options: 'mr', fingerprint: 'on'} ).to_return(options) end def stub_sks_get_reponse(key_id, opts = {}) - options = {:status => 200, :body => ""}.merge(opts) + options = {status: 200, body: ""}.merge(opts) stub_http_request(:get, Nickserver::Config.hkp_url).with( - :query => {:op => 'get', :search => "0x"+key_id, :exact => 'on', :options => 'mr'} + query: {op: 'get', search: "0x"+key_id, exact: 'on', options: 'mr'} ).to_return(options) end def stub_couch_response(uid, opts = {}) # can't stub localhost, so set couch_host to anything else Nickserver::Config.stub :couch_host, 'notlocalhost' do - options = {:status => 200, :body => ""}.merge(opts) + options = {status: 200, body: ""}.merge(opts) query = "\?key=#{"%22#{uid}%22"}&reduce=false" stub_http_request(:get, /#{Regexp.escape(Nickserver::Couch::FetchKey.couch_url)}.*#{query}/).to_return(options) yield diff --git a/test/unit/hkp_test.rb b/test/unit/hkp_test.rb index f3cdc95..0ecde2d 100644 --- a/test/unit/hkp_test.rb +++ b/test/unit/hkp_test.rb @@ -28,7 +28,7 @@ class HkpTest < Minitest::Test def test_key_info_not_found uid = 'leaping_lemur@leap.se' - stub_sks_vindex_reponse(uid, :status => 404) + stub_sks_vindex_reponse(uid, status: 404) test_em_errback "Nickserver::HKP::FetchKeyInfo.new.search '#{uid}'" do |error| assert_equal 404, error end @@ -36,7 +36,7 @@ class HkpTest < Minitest::Test def test_no_matching_key_found uid = 'leaping_lemur@leap.se' - stub_sks_vindex_reponse(uid, :status => 200) + stub_sks_vindex_reponse(uid, status: 200) test_em_errback "Nickserver::HKP::FetchKeyInfo.new.search '#{uid}'" do |error| assert_equal 404, error end @@ -45,8 +45,8 @@ class HkpTest < Minitest::Test def test_fetch_key uid = 'cloudadmin@leap.se' key_id = 'E818C478D3141282F7590D29D041EB11B1647490' - stub_sks_vindex_reponse(uid, :body => file_content(:leap_vindex_result)) - stub_sks_get_reponse(key_id, :body => file_content(:leap_public_key)) + stub_sks_vindex_reponse(uid, body: file_content(:leap_vindex_result)) + stub_sks_get_reponse(key_id, body: file_content(:leap_public_key)) test_em_callback "Nickserver::HKP::FetchKey.new.get '#{uid}'" do |key_text| assert_equal file_content(:leap_public_key), key_text @@ -57,8 +57,8 @@ class HkpTest < Minitest::Test uid = 'cloudadmin@leap.se' key_id = 'E818C478D3141282F7590D29D041EB11B1647490' - stub_sks_vindex_reponse(uid, :body => file_content(:leap_vindex_result)) - stub_sks_get_reponse(key_id, :status => 404) + stub_sks_vindex_reponse(uid, body: file_content(:leap_vindex_result)) + stub_sks_get_reponse(key_id, status: 404) test_em_errback "Nickserver::HKP::FetchKey.new.get '#{uid}'" do |error| assert_equal 404, error @@ -69,7 +69,7 @@ class HkpTest < Minitest::Test uid = 'chiiph@leap.se' key_id = '9A753A6B' - stub_sks_vindex_reponse(uid, :body => file_content(:short_key_vindex_result)) + stub_sks_vindex_reponse(uid, body: file_content(:short_key_vindex_result)) test_em_errback "Nickserver::HKP::FetchKey.new.get '#{uid}'" do |error| assert_equal 500, error end @@ -98,7 +98,7 @@ class HkpTest < Minitest::Test stub_config(:hkp_url, hkp_url) do stub_config(:hkp_ca_file, ca_file) do #stub_config(:hkp_ca_file, file_path('autistici-ca.pem')) do - assert File.exists?(Nickserver::Config.hkp_ca_file) + assert File.exist?(Nickserver::Config.hkp_ca_file) uid = 'elijah@riseup.net' test_em_callback "Nickserver::HKP::FetchKeyInfo.new.search '#{uid}'" do |keys| assert_equal 1, keys.size @@ -156,7 +156,7 @@ class HkpTest < Minitest::Test end def fetch_key_info(body_source, uid, &block) - stub_sks_vindex_reponse(uid, :body => file_content(body_source)) + stub_sks_vindex_reponse(uid, body: file_content(body_source)) test_em_callback "Nickserver::HKP::FetchKeyInfo.new.search '#{uid}'", &block end diff --git a/test/unit/nickserver_test.rb b/test/unit/nickserver_test.rb index c74d3d8..65ade8c 100644 --- a/test/unit/nickserver_test.rb +++ b/test/unit/nickserver_test.rb @@ -19,11 +19,11 @@ class NickserverTest < Minitest::Test def test_GET_served_via_SKS uid = 'cloudadmin@leap.se' key_id = 'E818C478D3141282F7590D29D041EB11B1647490' - stub_sks_vindex_reponse(uid, :body => file_content(:leap_vindex_result)) - stub_sks_get_reponse(key_id, :body => file_content(:leap_public_key)) + stub_sks_vindex_reponse(uid, body: file_content(:leap_vindex_result)) + stub_sks_get_reponse(key_id, body: file_content(:leap_public_key)) start do - params = {:query => {"address" => uid}} + params = {query: {"address" => uid}} get(params) do |http| assert_equal file_content(:leap_public_key), JSON.parse(http.response)["openpgp"] stop @@ -34,11 +34,11 @@ class NickserverTest < Minitest::Test def test_POST_served_via_SKS uid = 'cloudadmin@leap.se' key_id = 'E818C478D3141282F7590D29D041EB11B1647490' - stub_sks_vindex_reponse(uid, :body => file_content(:leap_vindex_result)) - stub_sks_get_reponse(key_id, :body => file_content(:leap_public_key)) + stub_sks_vindex_reponse(uid, body: file_content(:leap_vindex_result)) + stub_sks_get_reponse(key_id, body: file_content(:leap_public_key)) start do - params = {:body => {"address" => uid}} + params = {body: {"address" => uid}} post(params) do |http| assert_equal file_content(:leap_public_key), JSON.parse(http.response)["openpgp"] stop @@ -49,9 +49,9 @@ class NickserverTest < Minitest::Test def test_GET_served_via_couch_not_found domain = "example.org" uid = "bananas@" + domain - stub_couch_response(uid, :status => 404) do + stub_couch_response(uid, status: 404) do start do - params = {:query => {"address" => uid}, :head => {:host => domain}} + params = {query: {"address" => uid}, head: {host: domain}} get(params) do |http| assert_equal 404, http.response_header.status stop @@ -63,9 +63,9 @@ class NickserverTest < Minitest::Test def test_GET_served_via_couch_empty_results domain = "example.org" uid = "stompy@" + domain - stub_couch_response(uid, :body => file_content(:empty_couchdb_result)) do + stub_couch_response(uid, body: file_content(:empty_couchdb_result)) do start do - params = {:query => {"address" => uid}, :head => {:host => domain}} + params = {query: {"address" => uid}, head: {host: domain}} get(params) do |http| assert_equal 404, http.response_header.status stop @@ -77,9 +77,9 @@ class NickserverTest < Minitest::Test def test_GET_served_via_couch_success domain = "example.org" uid = "blue@" + domain - stub_couch_response(uid, :body => file_content(:blue_couchdb_result)) do + stub_couch_response(uid, body: file_content(:blue_couchdb_result)) do start do - params = {:query => {"address" => uid}, :head => {:host => domain}} + params = {query: {"address" => uid}, head: {host: domain}} get(params) do |http| assert_equal file_content(:blue_nickserver_result), http.response stop |