diff --git a/.codeclimate.yml b/.codeclimate.yml index 5e5fba5..7bb62f4 100644 --- a/.codeclimate.yml +++ b/.codeclimate.yml @@ -2,7 +2,7 @@ engines: rubocop: enabled: true - channel: rubocop-0-75 + channel: rubocop-1-10-0 bundler-audit: enabled: true ratings: diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1591a1f..e661eae 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,6 +14,8 @@ jobs: fail-fast: false matrix: ruby: + - 3.0 + - 2.7 - 2.6 - 2.5 gemfile: diff --git a/.rubocop.yml b/.rubocop.yml index a724b9a..2655b7b 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -2,6 +2,7 @@ require: rubocop-rails AllCops: TargetRubyVersion: 2.5 + NewCops: enable Exclude: - "bin/**/*" - "test/dummy/bin/**/*" @@ -46,7 +47,7 @@ Style/SymbolArray: Enabled: true # Most readable form. -Layout/AlignHash: +Layout/HashAlignment: EnforcedHashRocketStyle: table EnforcedColonStyle: table @@ -95,7 +96,7 @@ Style/SignalException: # Suppressing exceptions can be perfectly fine, and be it to avoid to # explicitly type nil into the rescue since that's what you want to return, # or suppressing LoadError for optional dependencies -Lint/HandleExceptions: +Lint/SuppressedException: Enabled: false Layout/SpaceInsideBlockBraces: @@ -182,6 +183,19 @@ Rails/Present: Exclude: - "lib/**/*" +# we don't have rails everywhere, so just disable these +Rails/NegateInclude: + Enabled: false +Rails/RakeEnvironment: + Enabled: false + +Lint/ConstantDefinitionInBlock: + Exclude: + - "spec/**/*" + +Naming/InclusiveLanguage: + Enabled: false + Style/SingleLineMethods: Exclude: - "test/dummy/app/models/*" @@ -196,6 +210,10 @@ Style/AccessModifierDeclarations: Exclude: - "lib/diaspora_federation/test/factories.rb" +Style/HashAsLastArrayItem: + Exclude: + - "lib/diaspora_federation/validators/*" + # disable this for now, needs to be rechecked later Style/DateTime: Exclude: diff --git a/.ruby-version b/.ruby-version index 5154b3f..9f55b2c 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -2.6 +3.0 diff --git a/Gemfile b/Gemfile index 749da4e..d5e1b80 100644 --- a/Gemfile +++ b/Gemfile @@ -19,14 +19,10 @@ end group :development do # code style - gem "pronto", "0.10.0", require: false - gem "pronto-rubocop", "0.10.0", require: false - gem "rubocop", "0.75.1", require: false - gem "rubocop-rails", "2.3.2", require: false - - # automatic test runs - gem "guard-rspec", require: false - gem "guard-rubocop", require: false + gem "pronto", "0.11.0", require: false + gem "pronto-rubocop", "0.11.1", require: false + gem "rubocop", "1.18.0", require: false + gem "rubocop-rails", "2.11.1", require: false # debugging gem "pry" @@ -34,15 +30,18 @@ group :development do # documentation gem "yard", require: false + + # rails needs this for development + gem "listen" end group :test do # rspec formatter - gem "fuubar", "2.4.1", require: false + gem "fuubar", "2.5.1", require: false gem "nyan-cat-formatter", require: false # test coverage - gem "simplecov", "0.17.1", require: false + gem "simplecov", "0.21.2", require: false gem "simplecov-rcov", "0.2.3", require: false # test helpers @@ -56,6 +55,6 @@ group :development, :test do gem "rake" # unit tests - gem "rspec", "~> 3.9.0" - gem "rspec-rails", "~> 3.9.0" + gem "rspec", "~> 3.10.0" + gem "rspec-rails", "~> 5.0.1" end diff --git a/Gemfile.lock b/Gemfile.lock index a25f53c..f23d938 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -9,7 +9,7 @@ PATH valid (~> 1.0) diaspora_federation-json_schema (0.2.6) diaspora_federation-rails (0.2.6) - actionpack (>= 5, < 7) + actionpack (>= 5.2, < 7) diaspora_federation (= 0.2.6) diaspora_federation-test (0.2.6) diaspora_federation (= 0.2.6) @@ -19,42 +19,42 @@ PATH GEM remote: https://rubygems.org/ specs: - actionpack (6.0.0) - actionview (= 6.0.0) - activesupport (= 6.0.0) - rack (~> 2.0) + actionpack (6.1.4) + actionview (= 6.1.4) + activesupport (= 6.1.4) + rack (~> 2.0, >= 2.0.9) rack-test (>= 0.6.3) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.2.0) - actionview (6.0.0) - activesupport (= 6.0.0) + actionview (6.1.4) + activesupport (= 6.1.4) builder (~> 3.1) erubi (~> 1.4) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.1, >= 1.2.0) - activesupport (6.0.0) + activesupport (6.1.4) concurrent-ruby (~> 1.0, >= 1.0.2) - i18n (>= 0.7, < 2) - minitest (~> 5.1) - tzinfo (~> 1.1) - zeitwerk (~> 2.1, >= 2.1.8) + i18n (>= 1.6, < 2) + minitest (>= 5.1) + tzinfo (~> 2.0) + zeitwerk (~> 2.3) addressable (2.7.0) public_suffix (>= 2.0.2, < 5.0) - ast (2.4.0) - builder (3.2.3) - byebug (11.0.1) - coderay (1.1.2) - concurrent-ruby (1.1.5) - crack (0.4.3) - safe_yaml (~> 1.0.0) - crass (1.0.5) - diff-lcs (1.3) - docile (1.3.2) - erubi (1.9.0) - ethon (0.12.0) - ffi (>= 1.3.0) - fabrication (2.20.2) - faraday (1.4.2) + ast (2.4.2) + builder (3.2.4) + byebug (11.1.3) + coderay (1.1.3) + concurrent-ruby (1.1.9) + crack (0.4.5) + rexml + crass (1.0.6) + diff-lcs (1.4.4) + docile (1.4.0) + erubi (1.10.0) + ethon (0.14.0) + ffi (>= 1.15.0) + fabrication (2.22.0) + faraday (1.4.3) faraday-em_http (~> 1.0) faraday-em_synchrony (~> 1.0) faraday-excon (~> 1.1) @@ -69,92 +69,71 @@ GEM faraday-net_http_persistent (1.1.0) faraday_middleware (1.0.0) faraday (~> 1.0) - ffi (1.11.1) - formatador (0.2.5) - fuubar (2.4.1) + ffi (1.15.3) + fuubar (2.5.1) rspec-core (~> 3.0) ruby-progressbar (~> 1.4) - gitlab (4.12.0) - httparty (~> 0.14, >= 0.14.0) + gitlab (4.17.0) + httparty (~> 0.18) terminal-table (~> 1.5, >= 1.5.1) - guard (2.15.1) - formatador (>= 0.2.4) - listen (>= 2.7, < 4.0) - lumberjack (>= 1.0.12, < 2.0) - nenv (~> 0.1) - notiffany (~> 0.0) - pry (>= 0.9.12) - shellany (~> 0.0) - thor (>= 0.18.1) - guard-compat (1.2.1) - guard-rspec (4.7.3) - guard (~> 2.1) - guard-compat (~> 1.1) - rspec (>= 2.99.0, < 4.0) - guard-rubocop (1.3.0) - guard (~> 2.0) - rubocop (~> 0.20) - hashdiff (1.0.0) - httparty (0.17.1) + hashdiff (1.0.1) + httparty (0.18.1) mime-types (~> 3.0) multi_xml (>= 0.5.2) - i18n (1.7.0) + i18n (1.8.10) concurrent-ruby (~> 1.0) - jaro_winkler (1.5.3) - json (2.2.0) json-schema (2.8.1) addressable (>= 2.4) json-schema-rspec (0.0.4) json-schema (~> 2.5) rspec - listen (3.2.0) + listen (3.5.1) rb-fsevent (~> 0.10, >= 0.10.3) rb-inotify (~> 0.9, >= 0.9.10) - loofah (2.3.0) + loofah (2.10.0) crass (~> 1.0.2) nokogiri (>= 1.5.9) - lumberjack (1.0.13) macaddr (1.7.2) systemu (~> 2.6.5) - method_source (0.9.2) - mime-types (3.3) + method_source (1.0.0) + mime-types (3.3.1) mime-types-data (~> 3.2015) - mime-types-data (3.2019.1009) - mini_portile2 (2.4.0) - minitest (5.12.2) + mime-types-data (3.2021.0225) + mini_portile2 (2.5.3) + minitest (5.14.4) multi_xml (0.6.0) multipart-post (2.1.1) - nenv (0.3.0) - nokogiri (1.10.4) - mini_portile2 (~> 2.4.0) - notiffany (0.1.3) - nenv (~> 0.1) - shellany (~> 0.0) + nokogiri (1.11.7) + mini_portile2 (~> 2.5.0) + racc (~> 1.4) nyan-cat-formatter (0.12.0) rspec (>= 2.99, >= 2.14.2, < 4) - octokit (4.14.0) + octokit (4.21.0) + faraday (>= 0.9) sawyer (~> 0.8.0, >= 0.5.3) - parallel (1.18.0) - parser (2.6.5.0) - ast (~> 2.4.0) - pronto (0.10.0) - gitlab (~> 4.0, >= 4.0.0) + parallel (1.20.1) + parser (3.0.1.1) + ast (~> 2.4.1) + pronto (0.11.0) + gitlab (~> 4.4, >= 4.4.0) httparty (>= 0.13.7) octokit (~> 4.7, >= 4.7.0) rainbow (>= 2.2, < 4.0) - rugged (~> 0.24, >= 0.23.0) - thor (~> 0.20.0) - pronto-rubocop (0.10.0) - pronto (~> 0.10.0) - rubocop (~> 0.50, >= 0.49.1) - pry (0.12.2) - coderay (~> 1.1.0) - method_source (~> 0.9.0) - pry-byebug (3.7.0) + rexml (~> 3.2) + rugged (>= 0.23.0, < 1.1.0) + thor (>= 0.20.3, < 2.0) + pronto-rubocop (0.11.1) + pronto (~> 0.11.0) + rubocop (>= 0.63.1, < 2.0) + pry (0.13.1) + coderay (~> 1.1) + method_source (~> 1.0) + pry-byebug (3.9.0) byebug (~> 11.0) - pry (~> 0.10) - public_suffix (4.0.1) - rack (2.0.7) + pry (~> 0.13.0) + public_suffix (4.0.6) + racc (1.5.2) + rack (2.2.3) rack-test (1.1.0) rack (>= 1.0, < 3) rails-dom-testing (2.0.3) @@ -162,85 +141,90 @@ GEM nokogiri (>= 1.6) rails-html-sanitizer (1.3.0) loofah (~> 2.3) - railties (6.0.0) - actionpack (= 6.0.0) - activesupport (= 6.0.0) + railties (6.1.4) + actionpack (= 6.1.4) + activesupport (= 6.1.4) method_source - rake (>= 0.8.7) - thor (>= 0.20.3, < 2.0) + rake (>= 0.13) + thor (~> 1.0) rainbow (3.0.0) - rake (13.0.0) - rb-fsevent (0.10.3) - rb-inotify (0.10.0) + rake (13.0.3) + rb-fsevent (0.11.0) + rb-inotify (0.10.1) ffi (~> 1.0) - rspec (3.9.0) - rspec-core (~> 3.9.0) - rspec-expectations (~> 3.9.0) - rspec-mocks (~> 3.9.0) + regexp_parser (2.1.1) + rexml (3.2.5) + rspec (3.10.0) + rspec-core (~> 3.10.0) + rspec-expectations (~> 3.10.0) + rspec-mocks (~> 3.10.0) rspec-collection_matchers (1.2.0) rspec-expectations (>= 2.99.0.beta1) - rspec-core (3.9.0) - rspec-support (~> 3.9.0) - rspec-expectations (3.9.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.9.0) + rspec-support (~> 3.10.0) rspec-json_expectations (2.2.0) - rspec-mocks (3.9.0) + rspec-mocks (3.10.2) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.9.0) - rspec-rails (3.9.0) - actionpack (>= 3.0) - activesupport (>= 3.0) - railties (>= 3.0) - rspec-core (~> 3.9.0) - rspec-expectations (~> 3.9.0) - rspec-mocks (~> 3.9.0) - rspec-support (~> 3.9.0) - rspec-support (3.9.0) - rubocop (0.75.1) - jaro_winkler (~> 1.5.1) + rspec-support (~> 3.10.0) + rspec-rails (5.0.1) + actionpack (>= 5.2) + activesupport (>= 5.2) + railties (>= 5.2) + rspec-core (~> 3.10) + rspec-expectations (~> 3.10) + rspec-mocks (~> 3.10) + rspec-support (~> 3.10) + rspec-support (3.10.2) + rubocop (1.18.0) parallel (~> 1.10) - parser (>= 2.6) + parser (>= 3.0.0.0) rainbow (>= 2.2.2, < 4.0) + regexp_parser (>= 1.8, < 3.0) + rexml + rubocop-ast (>= 1.7.0, < 2.0) ruby-progressbar (~> 1.7) - unicode-display_width (>= 1.4.0, < 1.7) - rubocop-rails (2.3.2) + unicode-display_width (>= 1.4.0, < 3.0) + rubocop-ast (1.7.0) + parser (>= 3.0.1.1) + rubocop-rails (2.11.1) + activesupport (>= 4.2.0) rack (>= 1.1) - rubocop (>= 0.72.0) - ruby-progressbar (1.10.1) + rubocop (>= 1.7.0, < 2.0) + ruby-progressbar (1.11.0) ruby2_keywords (0.0.4) - rugged (0.28.3.1) - safe_yaml (1.0.5) + rugged (1.0.1) sawyer (0.8.2) addressable (>= 2.3.5) faraday (> 0.8, < 2.0) - shellany (0.0.1) - simplecov (0.17.1) + simplecov (0.21.2) docile (~> 1.1) - json (>= 1.8, < 3) - simplecov-html (~> 0.10.0) - simplecov-html (0.10.2) + simplecov-html (~> 0.11) + simplecov_json_formatter (~> 0.1) + simplecov-html (0.12.3) simplecov-rcov (0.2.3) simplecov (>= 0.4.1) + simplecov_json_formatter (0.1.3) systemu (2.6.5) terminal-table (1.8.0) unicode-display_width (~> 1.1, >= 1.1.1) - thor (0.20.3) - thread_safe (0.3.6) + thor (1.1.0) typhoeus (1.4.0) ethon (>= 0.9.0) - tzinfo (1.2.5) - thread_safe (~> 0.1) - unicode-display_width (1.6.0) + tzinfo (2.0.4) + concurrent-ruby (~> 1.0) + unicode-display_width (1.7.0) uuid (2.3.9) macaddr (~> 1.0) valid (1.2.0) - webmock (3.7.6) + webmock (3.13.0) addressable (>= 2.3.6) crack (>= 0.3.2) hashdiff (>= 0.4.0, < 2.0.0) - yard (0.9.20) - zeitwerk (2.2.0) + yard (0.9.26) + zeitwerk (2.4.2) PLATFORMS ruby @@ -250,26 +234,25 @@ DEPENDENCIES diaspora_federation-json_schema! diaspora_federation-rails! diaspora_federation-test! - fuubar (= 2.4.1) - guard-rspec - guard-rubocop + fuubar (= 2.5.1) json-schema-rspec (= 0.0.4) + listen nyan-cat-formatter - pronto (= 0.10.0) - pronto-rubocop (= 0.10.0) + pronto (= 0.11.0) + pronto-rubocop (= 0.11.1) pry pry-byebug rake - rspec (~> 3.9.0) + rspec (~> 3.10.0) rspec-collection_matchers (~> 1.2.0) rspec-json_expectations (~> 2.1) - rspec-rails (~> 3.9.0) - rubocop (= 0.75.1) - rubocop-rails (= 2.3.2) - simplecov (= 0.17.1) + rspec-rails (~> 5.0.1) + rubocop (= 1.18.0) + rubocop-rails (= 2.11.1) + simplecov (= 0.21.2) simplecov-rcov (= 0.2.3) webmock (~> 3.0) yard BUNDLED WITH - 2.1.4 + 2.2.21 diff --git a/Guardfile b/Guardfile deleted file mode 100644 index d0f3e68..0000000 --- a/Guardfile +++ /dev/null @@ -1,30 +0,0 @@ -# frozen_string_literal: true - -guard :rspec, cmd: "NO_COVERAGE=true bin/rspec" do - require "guard/rspec/dsl" - dsl = Guard::RSpec::Dsl.new(self) - - # RSpec files - rspec = dsl.rspec - watch(rspec.spec_helper) { rspec.spec_dir } - watch(rspec.spec_support) { rspec.spec_dir } - watch(rspec.spec_files) - - # Ruby files - ruby = dsl.ruby - dsl.watch_spec_files_for(ruby.lib_files) - - # Rails files - rails = dsl.rails - dsl.watch_spec_files_for(rails.app_files) - - # Rails config changes - rails.app_controller = "app/controllers/diaspora_federation/application_controller.rb" - watch(rails.app_controller) { "#{rspec.spec_dir}/controllers" } - watch(rails.routes) { "#{rspec.spec_dir}/routing" } -end - -guard :rubocop do - watch(/.+\.rb$/) - watch(/\.rubocop\.yml$/) {|m| File.dirname(m[0]) } -end diff --git a/bin/guard b/bin/guard deleted file mode 100755 index 3df2151..0000000 --- a/bin/guard +++ /dev/null @@ -1,17 +0,0 @@ -#!/usr/bin/env ruby -# frozen_string_literal: true -# -# This file was generated by Bundler. -# -# The application 'guard' is installed as part of a gem, and -# this file is here to facilitate running it. -# - -require "pathname" -ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile", - Pathname.new(__FILE__).realpath) - -require "rubygems" -require "bundler/setup" - -load Gem.bin_path("guard", "guard") diff --git a/bin/rails b/bin/rails index 4595731..6b5ee87 100755 --- a/bin/rails +++ b/bin/rails @@ -1,12 +1,14 @@ #!/usr/bin/env ruby -# This command will automatically be run when you run "rails" with Rails 4 gems installed from the root of your application. +# This command will automatically be run when you run "rails" with Rails gems +# installed from the root of your application. -ENGINE_ROOT = File.expand_path('../..', __FILE__) -ENGINE_PATH = File.expand_path('../../lib/diaspora_federation/engine', __FILE__) +ENGINE_ROOT = File.expand_path('..', __dir__) +ENGINE_PATH = File.expand_path('../lib/diaspora_federation/engine', __dir__) +APP_PATH = File.expand_path('../test/dummy/config/application', __dir__) # Set up gems listed in the Gemfile. -ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) -require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE']) +ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__) +require "bundler/setup" if File.exist?(ENV["BUNDLE_GEMFILE"]) -require 'rails/all' -require 'rails/engine/commands' +require "rails/all" +require "rails/engine/commands" diff --git a/diaspora_federation-json_schema.gemspec b/diaspora_federation-json_schema.gemspec index 5cae269..4f782b8 100644 --- a/diaspora_federation-json_schema.gemspec +++ b/diaspora_federation-json_schema.gemspec @@ -18,4 +18,6 @@ Gem::Specification.new do |s| s.license = "AGPL-3.0" s.files = Dir["lib/diaspora_federation/schemas.rb", "lib/diaspora_federation/schemas/*.json"] + + s.required_ruby_version = ">= 2.5" end diff --git a/diaspora_federation-rails.gemspec b/diaspora_federation-rails.gemspec index 625372d..223b0e5 100644 --- a/diaspora_federation-rails.gemspec +++ b/diaspora_federation-rails.gemspec @@ -19,9 +19,9 @@ Gem::Specification.new do |s| s.files = Dir["app/**/*", "config/routes.rb", "config/initializers/*", "lib/diaspora_federation/{engine,rails}.rb", "LICENSE", "README.md", "Changelog.md"] - s.required_ruby_version = "~> 2.5" + s.required_ruby_version = ">= 2.5" - s.add_dependency "actionpack", ">= 5", "< 7" + s.add_dependency "actionpack", ">= 5.2", "< 7" s.add_dependency "diaspora_federation", DiasporaFederation::VERSION end diff --git a/diaspora_federation-test.gemspec b/diaspora_federation-test.gemspec index 40a0da8..de886bd 100644 --- a/diaspora_federation-test.gemspec +++ b/diaspora_federation-test.gemspec @@ -19,7 +19,7 @@ Gem::Specification.new do |s| s.files = Dir["lib/diaspora_federation/test.rb", "lib/diaspora_federation/test/*"] - s.required_ruby_version = "~> 2.5" + s.required_ruby_version = ">= 2.5" s.add_dependency "diaspora_federation", DiasporaFederation::VERSION s.add_dependency "fabrication", "~> 2.16" diff --git a/diaspora_federation.gemspec b/diaspora_federation.gemspec index ee0fb02..8e8cc0d 100644 --- a/diaspora_federation.gemspec +++ b/diaspora_federation.gemspec @@ -24,7 +24,7 @@ Gem::Specification.new do |s| "lib/diaspora_federation/test/*", "lib/tasks/*.rake"] - s.required_ruby_version = "~> 2.5" + s.required_ruby_version = ">= 2.5" s.add_dependency "faraday", "~> 1.0" s.add_dependency "faraday_middleware", "~> 1.0" diff --git a/lib/diaspora_federation/discovery/discovery.rb b/lib/diaspora_federation/discovery/discovery.rb index 23f2ea0..ac637af 100644 --- a/lib/diaspora_federation/discovery/discovery.rb +++ b/lib/diaspora_federation/discovery/discovery.rb @@ -46,7 +46,7 @@ module DiasporaFederation diaspora_id.strip.sub("acct:", "").to_s.downcase end - def get(url, http_fallback=false) + def get(url, http_fallback: false) logger.info "Fetching #{url} for #{diaspora_id}" response = HttpClient.get(url) raise "Failed to fetch #{url}: #{response.status}" unless response.success? @@ -69,7 +69,7 @@ module DiasporaFederation def legacy_webfinger_url_from_host_meta # This tries the xrd url with https first, then falls back to http. - host_meta = HostMeta.from_xml(get("https://#{domain}/.well-known/host-meta", true)) + host_meta = HostMeta.from_xml(get("https://#{domain}/.well-known/host-meta", http_fallback: true)) host_meta.webfinger_template_url.gsub("{uri}", acct_parameter) end @@ -79,7 +79,7 @@ module DiasporaFederation webfinger_url = "https://#{domain}/.well-known/webfinger?resource=#{acct_parameter}" # This tries the WebFinger URL with https first, then falls back to http if webfinger_http_fallback is enabled. - @webfinger = WebFinger.from_json(get(webfinger_url, DiasporaFederation.webfinger_http_fallback)) + @webfinger = WebFinger.from_json(get(webfinger_url, http_fallback: DiasporaFederation.webfinger_http_fallback)) rescue => e # rubocop:disable Style/RescueStandardError logger.warn "WebFinger failed, retrying with legacy WebFinger for #{diaspora_id}: #{e.class}: #{e.message}" @webfinger = WebFinger.from_xml(get(legacy_webfinger_url_from_host_meta)) diff --git a/lib/diaspora_federation/discovery/host_meta.rb b/lib/diaspora_federation/discovery/host_meta.rb index cc15da0..80de836 100644 --- a/lib/diaspora_federation/discovery/host_meta.rb +++ b/lib/diaspora_federation/discovery/host_meta.rb @@ -77,7 +77,7 @@ module DiasporaFederation # @param [String] url validation subject # @return [Boolean] validation result private_class_method def self.webfinger_url_valid?(url) - !url.nil? && url.instance_of?(String) && url =~ %r{\Ahttps?:\/\/.*\/.*\{uri\}.*}i + !url.nil? && url.instance_of?(String) && url =~ %r{\Ahttps?://.*/.*\{uri\}.*}i end # Gets the webfinger url from an XRD data structure diff --git a/lib/diaspora_federation/discovery/xrd_document.rb b/lib/diaspora_federation/discovery/xrd_document.rb index 6a3bb21..eecab2e 100644 --- a/lib/diaspora_federation/discovery/xrd_document.rb +++ b/lib/diaspora_federation/discovery/xrd_document.rb @@ -89,7 +89,7 @@ module DiasporaFederation aliases: (aliases if aliases.any?), properties: (properties if properties.any?), links: (links if links.any?) - }.reject {|_, v| v.nil? } + }.compact end # Parse the XRD document from the given string and create a hash containing @@ -132,7 +132,7 @@ module DiasporaFederation aliases: json_hash["aliases"], properties: json_hash["properties"], links: symbolize_keys_for_links(json_hash["links"]) - }.reject {|_, v| v.nil? } + }.compact rescue JSON::JSONError => e raise InvalidDocument, "Not a JRD document: #{e.class}: #{e.message[0..255].encode(Encoding.default_external, undef: :replace)}" @@ -140,8 +140,10 @@ module DiasporaFederation private + # rubocop:disable Layout/EmptyLinesAroundAttributeAccessor Style/AccessorGrouping attr_reader :expires attr_reader :subject + # rubocop:enable Layout/EmptyLinesAroundAttributeAccessor Style/AccessorGrouping NS = {xrd: XMLNS}.freeze diff --git a/lib/diaspora_federation/entities/signable.rb b/lib/diaspora_federation/entities/signable.rb index 1301f17..031d25a 100644 --- a/lib/diaspora_federation/entities/signable.rb +++ b/lib/diaspora_federation/entities/signable.rb @@ -7,7 +7,7 @@ module DiasporaFederation include Logging # Digest instance used for signing - DIGEST = OpenSSL::Digest::SHA256.new + DIGEST = OpenSSL::Digest.new("SHA256") # Sign the data with the key # diff --git a/lib/diaspora_federation/entity.rb b/lib/diaspora_federation/entity.rb index 3aa042b..6990616 100644 --- a/lib/diaspora_federation/entity.rb +++ b/lib/diaspora_federation/entity.rb @@ -321,7 +321,7 @@ module DiasporaFederation # Generates a hash with entity properties which is put to the "entity_data" # field of a JSON serialized object. # @return [Hash] object properties in JSON format - def json_data + def json_data # rubocop:disable Metrics/PerceivedComplexity enriched_properties.map {|key, value| type = self.class.class_props[key] next if optional_nil_value?(key, value) @@ -330,7 +330,7 @@ module DiasporaFederation entity_data = value.to_json [key, entity_data] unless entity_data.nil? elsif type.instance_of?(Array) - entity_data = value.nil? ? nil : value.map(&:to_json) + entity_data = value&.map(&:to_json) [key, entity_data] unless entity_data.nil? else [key, value] diff --git a/lib/diaspora_federation/logging.rb b/lib/diaspora_federation/logging.rb index 29fb7b2..ab73376 100644 --- a/lib/diaspora_federation/logging.rb +++ b/lib/diaspora_federation/logging.rb @@ -17,15 +17,15 @@ module DiasporaFederation # # Use the logging-gem if available, else use a default logger. def logger - @logger ||= begin + @logger ||= if defined?(::Logging::Logger) # Use logging-gem if available - return ::Logging::Logger[self] if defined?(::Logging::Logger) - + ::Logging::Logger[self] + elsif defined?(::Rails) # Use rails logger if running in rails and no logging-gem is available - return ::Rails.logger if defined?(::Rails) - + ::Rails.logger + else # fallback logger - @logger = Logger.new(STDOUT) + @logger = Logger.new($stdout) @logger.level = Logger::INFO @logger end diff --git a/lib/diaspora_federation/properties_dsl.rb b/lib/diaspora_federation/properties_dsl.rb index b420c14..715573a 100644 --- a/lib/diaspora_federation/properties_dsl.rb +++ b/lib/diaspora_federation/properties_dsl.rb @@ -57,9 +57,9 @@ module DiasporaFederation # resolved on each call # @return [Hash] default values def default_values - optional_props.map {|name| [name, nil] }.to_h.merge(default_props).map {|name, prop| - [name, prop.respond_to?(:call) ? prop.call : prop] - }.to_h + optional_props.map {|name| [name, nil] }.to_h.merge(default_props).transform_values {|prop| + prop.respond_to?(:call) ? prop.call : prop + } end # @param [Hash] data entity data diff --git a/lib/diaspora_federation/salmon/aes.rb b/lib/diaspora_federation/salmon/aes.rb index cc55e28..dffd706 100644 --- a/lib/diaspora_federation/salmon/aes.rb +++ b/lib/diaspora_federation/salmon/aes.rb @@ -21,7 +21,7 @@ module DiasporaFederation # @param [String] iv AES initialization vector # @return [String] base64 encoded ciphertext # @raise [ArgumentError] if any of the arguments is missing or not the correct type - def self.encrypt(data, key, iv) # rubocop:disable Naming/UncommunicativeMethodParamName + def self.encrypt(data, key, iv) # rubocop:disable Naming/MethodParameterName raise ArgumentError unless data.instance_of?(String) && key.instance_of?(String) && iv.instance_of?(String) @@ -43,7 +43,7 @@ module DiasporaFederation # @param [String] iv AES initialization vector # @return [String] decrypted plain message # @raise [ArgumentError] if any of the arguments is missing or not the correct type - def self.decrypt(ciphertext, key, iv) # rubocop:disable Naming/UncommunicativeMethodParamName + def self.decrypt(ciphertext, key, iv) # rubocop:disable Naming/MethodParameterName raise ArgumentError unless ciphertext.instance_of?(String) && key.instance_of?(String) && iv.instance_of?(String) diff --git a/lib/diaspora_federation/salmon/encrypted_magic_envelope.rb b/lib/diaspora_federation/salmon/encrypted_magic_envelope.rb index 83b585d..df9c044 100644 --- a/lib/diaspora_federation/salmon/encrypted_magic_envelope.rb +++ b/lib/diaspora_federation/salmon/encrypted_magic_envelope.rb @@ -38,7 +38,7 @@ module DiasporaFederation key = AES.generate_key_and_iv encrypted_env = AES.encrypt(magic_env.to_xml, key[:key], key[:iv]) - encoded_key = key.map {|k, v| [k, Base64.strict_encode64(v)] }.to_h + encoded_key = key.transform_values {|v| Base64.strict_encode64(v) } encrypted_key = Base64.strict_encode64(pubkey.public_encrypt(JSON.generate(encoded_key))) JSON.generate(aes_key: encrypted_key, encrypted_magic_envelope: encrypted_env) @@ -53,7 +53,7 @@ module DiasporaFederation encrypted_json = JSON.parse(encrypted_env) encoded_key = JSON.parse(privkey.private_decrypt(Base64.decode64(encrypted_json["aes_key"]))) - key = encoded_key.map {|k, v| [k, Base64.decode64(v)] }.to_h + key = encoded_key.transform_values {|v| Base64.decode64(v) } xml = AES.decrypt(encrypted_json["encrypted_magic_envelope"], key["key"], key["iv"]) Nokogiri::XML(xml).root diff --git a/lib/diaspora_federation/salmon/magic_envelope.rb b/lib/diaspora_federation/salmon/magic_envelope.rb index fafa1cd..042a34f 100644 --- a/lib/diaspora_federation/salmon/magic_envelope.rb +++ b/lib/diaspora_federation/salmon/magic_envelope.rb @@ -35,7 +35,7 @@ module DiasporaFederation DATA_TYPE = "application/xml" # Digest instance used for signing - DIGEST = OpenSSL::Digest::SHA256.new + DIGEST = OpenSSL::Digest.new("SHA256") # XML namespace url XMLNS = "http://salmon-protocol.org/ns/magic-env" @@ -137,10 +137,8 @@ module DiasporaFederation # @yield [xml] Invokes the block with the # {http://www.rubydoc.info/gems/nokogiri/Nokogiri/XML/Builder Nokogiri::XML::Builder} # @return [Nokogiri::XML::Element] XML root node - def build_xml - Nokogiri::XML::Builder.new(encoding: "UTF-8") {|xml| - yield xml - }.doc + def build_xml(&block) + Nokogiri::XML::Builder.new(encoding: "UTF-8", &block).doc end # Creates the signature for all fields according to specification diff --git a/lib/diaspora_federation/test/entity_generator.rb b/lib/diaspora_federation/test/entity_generator.rb index 9e610c0..24a7e63 100644 --- a/lib/diaspora_federation/test/entity_generator.rb +++ b/lib/diaspora_federation/test/entity_generator.rb @@ -14,9 +14,7 @@ module DiasporaFederation def to_hash(attributes=[], _callbacks=[]) process_attributes(attributes) - _attributes.each_with_object({}) do |(name, value), hash| - hash[name.to_sym] = value - end + _attributes.transform_keys(&:to_sym) end end diff --git a/lib/diaspora_federation/validators/rules/birthday.rb b/lib/diaspora_federation/validators/rules/birthday.rb index 21c28a0..751357e 100644 --- a/lib/diaspora_federation/validators/rules/birthday.rb +++ b/lib/diaspora_federation/validators/rules/birthday.rb @@ -22,7 +22,7 @@ module Validation return true if value.nil? || (value.is_a?(String) && value.empty?) return true if value.is_a? Date - if value.is_a?(String) && value.match?(/[0-9]{4}\-[0-9]{2}\-[0-9]{2}/) + if value.is_a?(String) && value.match?(/[0-9]{4}-[0-9]{2}-[0-9]{2}/) date_field = value.split("-").map(&:to_i) return Date.valid_civil?(date_field[0], date_field[1], date_field[2]) end diff --git a/lib/diaspora_federation/validators/rules/boolean.rb b/lib/diaspora_federation/validators/rules/boolean.rb index 01f0e30..6be0c6c 100644 --- a/lib/diaspora_federation/validators/rules/boolean.rb +++ b/lib/diaspora_federation/validators/rules/boolean.rb @@ -19,14 +19,13 @@ module Validation def valid_value?(value) return false if value.nil? - if value.is_a?(String) + case value + when String true if value =~ /\A(true|false|t|f|yes|no|y|n|1|0)\z/i - elsif value.is_a?(Integer) + when Integer true if [1, 0].include?(value) - elsif [true, false].include?(value) - true else - false + [true, false].include?(value) end end diff --git a/lib/tasks/gemfiles.rake b/lib/tasks/gemfiles.rake index 3500bdd..582dd7e 100644 --- a/lib/tasks/gemfiles.rake +++ b/lib/tasks/gemfiles.rake @@ -17,7 +17,7 @@ namespace :gemfiles do no_rails_path = "test/gemfiles/no-rails.Gemfile" File.write(no_rails_path, no_rails_gemfile) - Bundler.with_clean_env do + Bundler.with_unbundled_env do system("BUNDLE_GEMFILE=#{no_rails_path} bundle install") end end diff --git a/spec/controllers/diaspora_federation/webfinger_controller_spec.rb b/spec/controllers/diaspora_federation/webfinger_controller_spec.rb index c1a4fa1..1e0af9d 100644 --- a/spec/controllers/diaspora_federation/webfinger_controller_spec.rb +++ b/spec/controllers/diaspora_federation/webfinger_controller_spec.rb @@ -78,7 +78,7 @@ module DiasporaFederation it "raises when the resource parameter is missing" do expect { get :webfinger, format: :json - }.to raise_error ActionController::ParameterMissing, "param is missing or the value is empty: resource" + }.to raise_error ActionController::ParameterMissing, /param is missing or the value is empty: resource/ end it "calls the fetch_person_for_webfinger callback" do diff --git a/spec/lib/diaspora_federation/callbacks_spec.rb b/spec/lib/diaspora_federation/callbacks_spec.rb index 80e0ff3..41e4872 100644 --- a/spec/lib/diaspora_federation/callbacks_spec.rb +++ b/spec/lib/diaspora_federation/callbacks_spec.rb @@ -1,5 +1,6 @@ # frozen_string_literal: true +# rubocop:disable Lint/EmptyBlock module DiasporaFederation describe Callbacks do subject(:callbacks) { Callbacks.new %i[some_event another_event] } @@ -74,3 +75,4 @@ module DiasporaFederation end end end +# rubocop:enable Lint/EmptyBlock diff --git a/spec/lib/diaspora_federation/discovery/h_card_spec.rb b/spec/lib/diaspora_federation/discovery/h_card_spec.rb index 5c2da01..3c548c3 100644 --- a/spec/lib/diaspora_federation/discovery/h_card_spec.rb +++ b/spec/lib/diaspora_federation/discovery/h_card_spec.rb @@ -25,10 +25,9 @@ module DiasporaFederation let(:html) { <<~HTML } - + - - + #{person.full_name} @@ -87,19 +86,19 @@ module DiasporaFederation
Photo
- +
Photo_medium
- +
Photo_small
- +
diff --git a/spec/lib/diaspora_federation/salmon/encrypted_magic_envelope_spec.rb b/spec/lib/diaspora_federation/salmon/encrypted_magic_envelope_spec.rb index de6d97a..60114c8 100644 --- a/spec/lib/diaspora_federation/salmon/encrypted_magic_envelope_spec.rb +++ b/spec/lib/diaspora_federation/salmon/encrypted_magic_envelope_spec.rb @@ -30,7 +30,7 @@ module DiasporaFederation json = JSON.parse(encrypted) aes_key = JSON.parse(privkey.private_decrypt(Base64.decode64(json["aes_key"]))) - key = aes_key.map {|k, v| [k, Base64.decode64(v)] }.to_h + key = aes_key.transform_values {|v| Base64.decode64(v) } xml = Salmon::AES.decrypt(json["encrypted_magic_envelope"], key["key"], key["iv"]) diff --git a/spec/lib/diaspora_federation/salmon/magic_envelope_spec.rb b/spec/lib/diaspora_federation/salmon/magic_envelope_spec.rb index 7a9faf1..c28de1f 100644 --- a/spec/lib/diaspora_federation/salmon/magic_envelope_spec.rb +++ b/spec/lib/diaspora_federation/salmon/magic_envelope_spec.rb @@ -86,7 +86,7 @@ module DiasporaFederation subj = sig_subj(env_xml) sig = Base64.urlsafe_decode64(env_xml.at_xpath("me:env/me:sig").content) - expect(privkey.public_key.verify(OpenSSL::Digest::SHA256.new, sig, subj)).to be_truthy + expect(privkey.public_key.verify(OpenSSL::Digest.new("SHA256"), sig, subj)).to be_truthy end end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index f20a729..2515a28 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -19,7 +19,7 @@ dummy_app_path = File.join(File.dirname(__FILE__), "..", "test", "dummy") begin require "rails" # try to load rails rescue LoadError - Dir["#{File.join(dummy_app_path, 'app', 'models')}/*.rb"].each {|f| require f } + Dir["#{File.join(dummy_app_path, 'app', 'models')}/*.rb"].sort.each {|f| require f } require File.join(dummy_app_path, "config", "initializers", "diaspora_federation") else ENV["RAILS_ENV"] ||= "test" @@ -42,7 +42,7 @@ require "entities" # Requires supporting files with custom matchers and macros, etc, # in ./support/ and its subdirectories. -Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f } +Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].sort.each {|f| require f } RSpec.configure do |config| config.include JSON::SchemaMatchers diff --git a/spec/support/helper_methods.rb b/spec/support/helper_methods.rb index 69f1f67..ee413a2 100644 --- a/spec/support/helper_methods.rb +++ b/spec/support/helper_methods.rb @@ -21,11 +21,11 @@ def add_signatures(hash, klass=described_class) end def sign_with_key(privkey, signature_data) - Base64.strict_encode64(privkey.sign(OpenSSL::Digest::SHA256.new, signature_data)) + Base64.strict_encode64(privkey.sign(OpenSSL::Digest.new("SHA256"), signature_data)) end def verify_signature(pubkey, signature, signed_string) - pubkey.verify(OpenSSL::Digest::SHA256.new, Base64.decode64(signature), signed_string) + pubkey.verify(OpenSSL::Digest.new("SHA256"), Base64.decode64(signature), signed_string) end # time helper diff --git a/spec/support/shared_entity_specs.rb b/spec/support/shared_entity_specs.rb index 3ce2f69..2317879 100644 --- a/spec/support/shared_entity_specs.rb +++ b/spec/support/shared_entity_specs.rb @@ -1,17 +1,17 @@ # frozen_string_literal: true def entity_hash_from(hash) - hash.map {|key, value| + hash.transform_values {|value| if [String, TrueClass, FalseClass, Integer, NilClass].any? {|c| value.is_a? c } - [key, value] + value elsif value.is_a? Time - [key, value.iso8601] + value.iso8601 elsif value.instance_of?(Array) - [key, value.map(&:to_h)] + value.map(&:to_h) else - [key, value.to_h] + value.to_h end - }.to_h + } end shared_examples "an Entity subclass" do @@ -104,7 +104,7 @@ shared_examples "a relayable Entity" do context "signatures generation" do def verify_signature(pubkey, signature, signed_string) - pubkey.verify(OpenSSL::Digest::SHA256.new, Base64.decode64(signature), signed_string) + pubkey.verify(OpenSSL::Digest.new("SHA256"), Base64.decode64(signature), signed_string) end it "computes correct author_signature for the entity" do @@ -135,7 +135,7 @@ shared_examples "a JSON Entity" do entity_data.delete(:parent) nested_elements, simple_props = entity_data.partition {|_key, value| value.is_a?(Array) || value.is_a?(Hash) } - expect(to_json_output).to include_json(entity_data: simple_props.reject {|_key, value| value.nil? }.to_h) + expect(to_json_output).to include_json(entity_data: simple_props.to_h.compact) nested_elements.each {|key, value| type = described_class.class_props[key] diff --git a/test/dummy/bin/rails b/test/dummy/bin/rails index 0739660..6fb4e40 100755 --- a/test/dummy/bin/rails +++ b/test/dummy/bin/rails @@ -1,4 +1,4 @@ #!/usr/bin/env ruby APP_PATH = File.expand_path('../config/application', __dir__) -require_relative '../config/boot' -require 'rails/commands' +require_relative "../config/boot" +require "rails/commands" diff --git a/test/dummy/bin/rake b/test/dummy/bin/rake new file mode 100755 index 0000000..4fbf10b --- /dev/null +++ b/test/dummy/bin/rake @@ -0,0 +1,4 @@ +#!/usr/bin/env ruby +require_relative "../config/boot" +require "rake" +Rake.application.run diff --git a/test/dummy/bin/setup b/test/dummy/bin/setup new file mode 100755 index 0000000..bf08171 --- /dev/null +++ b/test/dummy/bin/setup @@ -0,0 +1,25 @@ +#!/usr/bin/env ruby +require "fileutils" + +# path to your application root. +APP_ROOT = File.expand_path('..', __dir__) + +def system!(*args) + system(*args) || abort("\n== Command #{args} failed ==") +end + +FileUtils.chdir APP_ROOT do + # This script is a way to set up or update your development environment automatically. + # This script is idempotent, so that you can run it at any time and get an expectable outcome. + # Add necessary setup steps to this file. + + puts '== Installing dependencies ==' + system! 'gem install bundler --conservative' + system('bundle check') || system!('bundle install') + + puts "\n== Removing old logs and tempfiles ==" + system! 'bin/rails log:clear tmp:clear' + + puts "\n== Restarting application server ==" + system! 'bin/rails restart' +end diff --git a/test/dummy/config.ru b/test/dummy/config.ru index 097cb7b..2e03084 100644 --- a/test/dummy/config.ru +++ b/test/dummy/config.ru @@ -2,5 +2,7 @@ # This file is used by Rack-based servers to start the application. -require ::File.expand_path("../config/environment", __FILE__) +require_relative "config/environment" + run Rails.application +Rails.application.load_server diff --git a/test/dummy/config/application.rb b/test/dummy/config/application.rb index dccc66d..f7d2554 100644 --- a/test/dummy/config/application.rb +++ b/test/dummy/config/application.rb @@ -27,9 +27,12 @@ module Dummy # Initialize configuration defaults for originally generated Rails version. config.load_defaults 5.0 - # Settings in config/environments/* take precedence over those specified here. - # Application configuration can go into files in config/initializers - # -- all .rb files in that directory are automatically loaded after loading - # the framework and any gems in your application. + # Configuration for the application, engines, and railties goes here. + # + # These settings can be overridden in specific environments using the files + # in config/environments, which are processed later. + # + # config.time_zone = "Central Time (US & Canada)" + # config.eager_load_paths << Rails.root.join("extras") end end diff --git a/test/dummy/config/boot.rb b/test/dummy/config/boot.rb index 55bd95c..593ee1f 100644 --- a/test/dummy/config/boot.rb +++ b/test/dummy/config/boot.rb @@ -2,6 +2,5 @@ # Set up gems listed in the Gemfile. ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../../Gemfile", __dir__) -require "bundler/setup" if File.exist?(ENV["BUNDLE_GEMFILE"]) -$LOAD_PATH.unshift File.expand_path("../../../lib", __dir__) +require "bundler/setup" # Set up gems listed in the Gemfile. diff --git a/test/dummy/config/environments/development.rb b/test/dummy/config/environments/development.rb index d1a500a..70df74b 100644 --- a/test/dummy/config/environments/development.rb +++ b/test/dummy/config/environments/development.rb @@ -1,10 +1,12 @@ # frozen_string_literal: true +require "active_support/core_ext/integer/time" + Rails.application.configure do # Settings specified here will take precedence over those in config/application.rb. - # In the development environment your application's code is reloaded on - # every request. This slows down response time but is perfect for development + # In the development environment your application's code is reloaded any time + # it changes. This slows down response time but is perfect for development # since you don't have to restart the web server when you make code changes. config.cache_classes = false @@ -16,7 +18,7 @@ Rails.application.configure do # Enable/disable caching. By default caching is disabled. # Run rails dev:cache to toggle caching. - if Rails.root.join("tmp", "caching-dev.txt").exist? + if Rails.root.join("tmp/caching-dev.txt").exist? config.action_controller.perform_caching = true config.action_controller.enable_fragment_cache_logging = true @@ -33,8 +35,17 @@ Rails.application.configure do # Print deprecation notices to the Rails logger. config.active_support.deprecation = :log + # Raise exceptions for disallowed deprecations. + config.active_support.disallowed_deprecation = :raise + + # Tell Active Support which deprecation messages to disallow. + config.active_support.disallowed_deprecation_warnings = [] + # Raises error for missing translations. - # config.action_view.raise_on_missing_translations = true + # config.i18n.raise_on_missing_translations = true + + # Annotate rendered view with file names. + # config.action_view.annotate_rendered_view_with_filenames = true # Use an evented file watcher to asynchronously detect changes in source code, # routes, locales, etc. This feature depends on the listen gem. @@ -45,4 +56,7 @@ Rails.application.configure do # Show the logging configuration on STDOUT config.show_log_configuration = true + + # Uncomment if you wish to allow Action Cable access from any origin. + # config.action_cable.disable_request_forgery_protection = true end diff --git a/test/dummy/config/environments/production.rb b/test/dummy/config/environments/production.rb index f7d9dab..35b3954 100644 --- a/test/dummy/config/environments/production.rb +++ b/test/dummy/config/environments/production.rb @@ -1,5 +1,7 @@ # frozen_string_literal: true +require "active_support/core_ext/integer/time" + Rails.application.configure do # Settings specified here will take precedence over those in config/application.rb. @@ -25,7 +27,7 @@ Rails.application.configure do config.public_file_server.enabled = ENV["RAILS_SERVE_STATIC_FILES"].present? # Enable serving of images, stylesheets, and JavaScripts from an asset server. - # config.action_controller.asset_host = 'http://assets.example.com' + # config.asset_host = 'http://assets.example.com' # Specifies the header that your server uses for sending files. # config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache @@ -34,15 +36,9 @@ Rails.application.configure do # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. # config.force_ssl = true - # Use the lowest log level to ensure availability of diagnostic information - # when problems arise. - config.log_level = :debug - - # Set the logging destination(s) - config.log_to = %w[file] - - # Show the logging configuration on STDOUT - config.show_log_configuration = false + # Include generic and useful information about system operation, but avoid logging too much + # information to avoid inadvertent exposure of personally identifiable information (PII). + config.log_level = :info # Prepend all log lines with the following tags. config.log_tags = [:request_id] @@ -61,15 +57,21 @@ Rails.application.configure do # Send deprecation notices to registered listeners. config.active_support.deprecation = :notify + # Log disallowed deprecations. + config.active_support.disallowed_deprecation = :log + + # Tell Active Support which deprecation messages to disallow. + config.active_support.disallowed_deprecation_warnings = [] + # Use default logging formatter so that PID and timestamp are not suppressed. config.log_formatter = ::Logger::Formatter.new # Use a different logger for distributed setups. - # require 'syslog/logger' + # require "syslog/logger" # config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name') if ENV["RAILS_LOG_TO_STDOUT"].present? - logger = ActiveSupport::Logger.new(STDOUT) + logger = ActiveSupport::Logger.new($stdout) logger.formatter = config.log_formatter config.logger = ActiveSupport::TaggedLogging.new(logger) end diff --git a/test/dummy/config/environments/test.rb b/test/dummy/config/environments/test.rb index bae3b39..18e193d 100644 --- a/test/dummy/config/environments/test.rb +++ b/test/dummy/config/environments/test.rb @@ -1,5 +1,7 @@ # frozen_string_literal: true +require "active_support/core_ext/integer/time" + # The test environment is used exclusively to run your application's # test suite. You never need to work with it otherwise. Remember that # your test database is "scratch space" for the test suite and is wiped @@ -8,7 +10,7 @@ Rails.application.configure do # Settings specified here will take precedence over those in config/application.rb. - config.cache_classes = false + config.cache_classes = true # Do not eager load code on boot. This avoids loading your whole application # just for the purpose of running a single test. If you are using a tool that @@ -35,6 +37,15 @@ Rails.application.configure do # Print deprecation notices to the stderr. config.active_support.deprecation = :stderr + # Raise exceptions for disallowed deprecations. + config.active_support.disallowed_deprecation = :raise + + # Tell Active Support which deprecation messages to disallow. + config.active_support.disallowed_deprecation_warnings = [] + # Raises error for missing translations. - # config.action_view.raise_on_missing_translations = true + # config.i18n.raise_on_missing_translations = true + + # Annotate rendered view with file names. + # config.action_view.annotate_rendered_view_with_filenames = true end diff --git a/test/dummy/config/initializers/diaspora_federation.rb b/test/dummy/config/initializers/diaspora_federation.rb index 09eed96..4847a80 100644 --- a/test/dummy/config/initializers/diaspora_federation.rb +++ b/test/dummy/config/initializers/diaspora_federation.rb @@ -56,6 +56,7 @@ DiasporaFederation.configure do |config| end on :save_person_after_webfinger do + # ignore end on :fetch_private_key do |diaspora_id| @@ -80,9 +81,11 @@ DiasporaFederation.configure do |config| end on :queue_public_receive do + # ignore end on :queue_private_receive do + # ignore true end @@ -100,6 +103,7 @@ DiasporaFederation.configure do |config| end on :update_pod do + # ignore end end end diff --git a/test/dummy/config/initializers/filter_parameter_logging.rb b/test/dummy/config/initializers/filter_parameter_logging.rb index 7a4f47b..3babc73 100644 --- a/test/dummy/config/initializers/filter_parameter_logging.rb +++ b/test/dummy/config/initializers/filter_parameter_logging.rb @@ -3,4 +3,6 @@ # Be sure to restart your server when you modify this file. # Configure sensitive parameters which will be filtered from the log file. -Rails.application.config.filter_parameters += [:password] +Rails.application.config.filter_parameters += %i[ + passw secret token _key crypt salt certificate otp ssn +] diff --git a/test/gemfiles/no-rails.Gemfile b/test/gemfiles/no-rails.Gemfile index cd31967..dc888da 100644 --- a/test/gemfiles/no-rails.Gemfile +++ b/test/gemfiles/no-rails.Gemfile @@ -19,11 +19,11 @@ end group :test do # rspec formatter - gem "fuubar", "2.4.1", require: false + gem "fuubar", "2.5.1", require: false gem "nyan-cat-formatter", require: false # test coverage - gem "simplecov", "0.17.1", require: false + gem "simplecov", "0.21.2", require: false gem "simplecov-rcov", "0.2.3", require: false # test helpers @@ -37,5 +37,5 @@ group :development, :test do gem "rake" # unit tests - gem "rspec", "~> 3.9.0" + gem "rspec", "~> 3.10.0" end diff --git a/test/gemfiles/no-rails.Gemfile.lock b/test/gemfiles/no-rails.Gemfile.lock index a269781..5062514 100644 --- a/test/gemfiles/no-rails.Gemfile.lock +++ b/test/gemfiles/no-rails.Gemfile.lock @@ -18,14 +18,14 @@ GEM specs: addressable (2.7.0) public_suffix (>= 2.0.2, < 5.0) - crack (0.4.3) - safe_yaml (~> 1.0.0) - diff-lcs (1.3) - docile (1.3.2) - ethon (0.12.0) - ffi (>= 1.3.0) - fabrication (2.20.2) - faraday (1.4.2) + crack (0.4.5) + rexml + diff-lcs (1.4.4) + docile (1.4.0) + ethon (0.14.0) + ffi (>= 1.15.0) + fabrication (2.22.0) + faraday (1.4.3) faraday-em_http (~> 1.0) faraday-em_synchrony (~> 1.0) faraday-excon (~> 1.1) @@ -40,12 +40,11 @@ GEM faraday-net_http_persistent (1.1.0) faraday_middleware (1.0.0) faraday (~> 1.0) - ffi (1.11.1) - fuubar (2.4.1) + ffi (1.15.3) + fuubar (2.5.1) rspec-core (~> 3.0) ruby-progressbar (~> 1.4) - hashdiff (1.0.0) - json (2.2.0) + hashdiff (1.0.1) json-schema (2.8.1) addressable (>= 2.4) json-schema-rspec (0.0.4) @@ -53,68 +52,69 @@ GEM rspec macaddr (1.7.2) systemu (~> 2.6.5) - mini_portile2 (2.4.0) multipart-post (2.1.1) - nokogiri (1.10.4) - mini_portile2 (~> 2.4.0) + nokogiri (1.11.7-x86_64-linux) + racc (~> 1.4) nyan-cat-formatter (0.12.0) rspec (>= 2.99, >= 2.14.2, < 4) - public_suffix (4.0.1) - rake (13.0.0) - rspec (3.9.0) - rspec-core (~> 3.9.0) - rspec-expectations (~> 3.9.0) - rspec-mocks (~> 3.9.0) + public_suffix (4.0.6) + racc (1.5.2) + rake (13.0.3) + rexml (3.2.5) + rspec (3.10.0) + rspec-core (~> 3.10.0) + rspec-expectations (~> 3.10.0) + rspec-mocks (~> 3.10.0) rspec-collection_matchers (1.2.0) rspec-expectations (>= 2.99.0.beta1) - rspec-core (3.9.0) - rspec-support (~> 3.9.0) - rspec-expectations (3.9.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.9.0) + rspec-support (~> 3.10.0) rspec-json_expectations (2.2.0) - rspec-mocks (3.9.0) + rspec-mocks (3.10.2) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.9.0) - rspec-support (3.9.0) - ruby-progressbar (1.10.1) + rspec-support (~> 3.10.0) + rspec-support (3.10.2) + ruby-progressbar (1.11.0) ruby2_keywords (0.0.4) - safe_yaml (1.0.5) - simplecov (0.17.1) + simplecov (0.21.2) docile (~> 1.1) - json (>= 1.8, < 3) - simplecov-html (~> 0.10.0) - simplecov-html (0.10.2) + simplecov-html (~> 0.11) + simplecov_json_formatter (~> 0.1) + simplecov-html (0.12.3) simplecov-rcov (0.2.3) simplecov (>= 0.4.1) + simplecov_json_formatter (0.1.3) systemu (2.6.5) typhoeus (1.4.0) ethon (>= 0.9.0) uuid (2.3.9) macaddr (~> 1.0) valid (1.2.0) - webmock (3.7.6) + webmock (3.13.0) addressable (>= 2.3.6) crack (>= 0.3.2) hashdiff (>= 0.4.0, < 2.0.0) PLATFORMS - ruby + x86_64-linux DEPENDENCIES diaspora_federation! diaspora_federation-json_schema! diaspora_federation-test! - fuubar (= 2.4.1) + fuubar (= 2.5.1) json-schema-rspec (= 0.0.4) nyan-cat-formatter rake - rspec (~> 3.9.0) + rspec (~> 3.10.0) rspec-collection_matchers (~> 1.2.0) rspec-json_expectations (~> 2.1) - simplecov (= 0.17.1) + simplecov (= 0.21.2) simplecov-rcov (= 0.2.3) webmock (~> 3.0) BUNDLED WITH - 2.1.4 + 2.2.21