From 0df99e91ac47c0038e772f71cc12040320533249 Mon Sep 17 00:00:00 2001 From: Waldo Fouche Date: Wed, 23 Feb 2022 11:55:23 +0800 Subject: [PATCH 01/17] Upgrade to rails `6.1.4.4` Latest rails 6 releases --- Gemfile | 2 +- Gemfile.lock | 258 ++++++++++++++++++++++++++++----------------------- 2 files changed, 141 insertions(+), 119 deletions(-) diff --git a/Gemfile b/Gemfile index 7ca0a4dc..08a8de25 100644 --- a/Gemfile +++ b/Gemfile @@ -2,7 +2,7 @@ source 'https://rubygems.org' -gem 'rails', '>= 5', '< 6' +gem 'rails', '6.1.4.4' gem 'sass-rails' gem 'jbuilder' diff --git a/Gemfile.lock b/Gemfile.lock index 76cbeb2d..8e088931 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -11,70 +11,88 @@ GEM tilt will_paginate accession (1.0.0) - actioncable (5.2.6) - actionpack (= 5.2.6) + actioncable (6.1.4.4) + actionpack (= 6.1.4.4) + activesupport (= 6.1.4.4) nio4r (~> 2.0) websocket-driver (>= 0.6.1) - actionmailer (5.2.6) - actionpack (= 5.2.6) - actionview (= 5.2.6) - activejob (= 5.2.6) + actionmailbox (6.1.4.4) + actionpack (= 6.1.4.4) + activejob (= 6.1.4.4) + activerecord (= 6.1.4.4) + activestorage (= 6.1.4.4) + activesupport (= 6.1.4.4) + mail (>= 2.7.1) + actionmailer (6.1.4.4) + actionpack (= 6.1.4.4) + actionview (= 6.1.4.4) + activejob (= 6.1.4.4) + activesupport (= 6.1.4.4) mail (~> 2.5, >= 2.5.4) rails-dom-testing (~> 2.0) - actionpack (5.2.6) - actionview (= 5.2.6) - activesupport (= 5.2.6) - rack (~> 2.0, >= 2.0.8) + actionpack (6.1.4.4) + actionview (= 6.1.4.4) + activesupport (= 6.1.4.4) + rack (~> 2.0, >= 2.0.9) rack-test (>= 0.6.3) rails-dom-testing (~> 2.0) - rails-html-sanitizer (~> 1.0, >= 1.0.2) - actionview (5.2.6) - activesupport (= 5.2.6) + rails-html-sanitizer (~> 1.0, >= 1.2.0) + actiontext (6.1.4.4) + actionpack (= 6.1.4.4) + activerecord (= 6.1.4.4) + activestorage (= 6.1.4.4) + activesupport (= 6.1.4.4) + nokogiri (>= 1.8.5) + actionview (6.1.4.4) + activesupport (= 6.1.4.4) builder (~> 3.1) erubi (~> 1.4) rails-dom-testing (~> 2.0) - rails-html-sanitizer (~> 1.0, >= 1.0.3) - activejob (5.2.6) - activesupport (= 5.2.6) + rails-html-sanitizer (~> 1.1, >= 1.2.0) + activejob (6.1.4.4) + activesupport (= 6.1.4.4) globalid (>= 0.3.6) - activemodel (5.2.6) - activesupport (= 5.2.6) - activerecord (5.2.6) - activemodel (= 5.2.6) - activesupport (= 5.2.6) - arel (>= 9.0) - activestorage (5.2.6) - actionpack (= 5.2.6) - activerecord (= 5.2.6) + activemodel (6.1.4.4) + activesupport (= 6.1.4.4) + activerecord (6.1.4.4) + activemodel (= 6.1.4.4) + activesupport (= 6.1.4.4) + activestorage (6.1.4.4) + actionpack (= 6.1.4.4) + activejob (= 6.1.4.4) + activerecord (= 6.1.4.4) + activesupport (= 6.1.4.4) marcel (~> 1.0.0) - activesupport (5.2.6) + mini_mime (>= 1.1.0) + activesupport (6.1.4.4) concurrent-ruby (~> 1.0, >= 1.0.2) - i18n (>= 0.7, < 2) - minitest (~> 5.1) - tzinfo (~> 1.1) + i18n (>= 1.6, < 2) + minitest (>= 5.1) + tzinfo (~> 2.0) + zeitwerk (~> 2.3) addressable (2.8.0) public_suffix (>= 2.0.2, < 5.0) aes_key_wrap (1.1.0) - arel (9.0.0) ast (2.4.2) aws-eventstream (1.2.0) - aws-partitions (1.523.0) - aws-sdk-core (3.121.6) + aws-partitions (1.557.0) + aws-sdk-core (3.126.2) aws-eventstream (~> 1, >= 1.0.2) - aws-partitions (~> 1, >= 1.520.1) + aws-partitions (~> 1, >= 1.525.0) aws-sigv4 (~> 1.1) jmespath (~> 1.0) - aws-sdk-sqs (1.44.0) - aws-sdk-core (~> 3, >= 3.120.0) + aws-sdk-sqs (1.50.0) + aws-sdk-core (~> 3, >= 3.126.0) aws-sigv4 (~> 1.1) aws-sigv4 (1.4.0) aws-eventstream (~> 1, >= 1.0.2) bindata (2.4.10) - brakeman (5.1.1) + brakeman (5.2.1) builder (3.2.4) byebug (11.1.3) - capybara (3.35.3) + capybara (3.36.0) addressable + matrix mini_mime (>= 0.1.3) nokogiri (~> 1.8) rack (>= 1.6.0) @@ -93,23 +111,23 @@ GEM activerecord (>= 5.a) database_cleaner-core (~> 2.0.0) database_cleaner-core (2.0.1) - diff-lcs (1.4.4) + diff-lcs (1.5.0) docile (1.4.0) erubi (1.10.0) erubis (2.7.0) - execjs (2.7.0) + execjs (2.8.1) factory_bot (4.11.1) activesupport (>= 3.0.0) factory_bot_rails (4.11.1) factory_bot (~> 4.11.1) railties (>= 3.0.0) - faker (2.18.0) + faker (2.19.0) i18n (>= 1.6, < 2) fakeredis (0.8.0) redis (~> 4.1) - ffi (1.15.3) - formatador (0.3.0) - globalid (0.5.2) + ffi (1.15.5) + formatador (1.1.0) + globalid (1.0.0) activesupport (>= 5.0) god (0.13.7) guard (2.18.0) @@ -134,18 +152,19 @@ GEM guard (~> 2.1) guard-compat (~> 1.1) rspec (>= 2.99.0, < 4.0) - guard-rubocop (1.4.0) + guard-rubocop (1.5.0) guard (~> 2.0) rubocop (< 2.0) guard-unicorn (0.2.0) guard (>= 1.1) hashdiff (1.0.1) - i18n (1.8.10) + i18n (1.10.0) concurrent-ruby (~> 1.0) implicit-schema (0.0.1) - jbuilder (2.11.2) + jbuilder (2.11.5) + actionview (>= 5.0.0) activesupport (>= 5.0.0) - jmespath (1.4.0) + jmespath (1.6.0) json-jwt (1.13.0) activesupport (>= 4.2) aes_key_wrap @@ -156,33 +175,34 @@ GEM launchy (2.5.0) addressable (~> 2.7) libv8 (3.16.14.19) - listen (3.6.0) + listen (3.7.1) rb-fsevent (~> 0.10, >= 0.10.3) rb-inotify (~> 0.9, >= 0.9.10) - loofah (2.12.0) + loofah (2.14.0) crass (~> 1.0.2) nokogiri (>= 1.5.9) lumberjack (1.2.8) mail (2.7.1) mini_mime (>= 0.1.1) - marcel (1.0.1) + marcel (1.0.2) + matrix (0.4.2) method_source (1.0.0) - mini_mime (1.1.0) - mini_portile2 (2.6.1) - minitest (5.14.4) + mini_mime (1.1.2) + mini_portile2 (2.8.0) + minitest (5.15.0) mysql2 (0.5.3) nenv (0.3.0) nio4r (2.5.8) - nokogiri (1.12.5) - mini_portile2 (~> 2.6.1) + nokogiri (1.13.3) + mini_portile2 (~> 2.8.0) racc (~> 1.4) - nokogiri (1.12.5-x86_64-darwin) + nokogiri (1.13.3-x86_64-darwin) racc (~> 1.4) notiffany (0.1.3) nenv (~> 0.1) shellany (~> 0.0) - parallel (1.20.1) - parser (3.0.2.0) + parallel (1.21.0) + parser (3.1.1.0) ast (~> 2.4.1) poltergeist (1.18.1) capybara (>= 2.1, < 4) @@ -194,22 +214,24 @@ GEM public_suffix (4.0.6) puma (5.6.2) nio4r (~> 2.0) - racc (1.5.2) + racc (1.6.0) rack (2.2.3) rack-test (1.1.0) rack (>= 1.0, < 3) - rails (5.2.6) - actioncable (= 5.2.6) - actionmailer (= 5.2.6) - actionpack (= 5.2.6) - actionview (= 5.2.6) - activejob (= 5.2.6) - activemodel (= 5.2.6) - activerecord (= 5.2.6) - activestorage (= 5.2.6) - activesupport (= 5.2.6) - bundler (>= 1.3.0) - railties (= 5.2.6) + rails (6.1.4.4) + actioncable (= 6.1.4.4) + actionmailbox (= 6.1.4.4) + actionmailer (= 6.1.4.4) + actionpack (= 6.1.4.4) + actiontext (= 6.1.4.4) + actionview (= 6.1.4.4) + activejob (= 6.1.4.4) + activemodel (= 6.1.4.4) + activerecord (= 6.1.4.4) + activestorage (= 6.1.4.4) + activesupport (= 6.1.4.4) + bundler (>= 1.15.0) + railties (= 6.1.4.4) sprockets-rails (>= 2.0.0) rails-controller-testing (1.0.5) actionpack (>= 5.0.1.rc1) @@ -218,56 +240,56 @@ GEM rails-dom-testing (2.0.3) activesupport (>= 4.2.0) nokogiri (>= 1.6) - rails-html-sanitizer (1.3.0) + rails-html-sanitizer (1.4.2) loofah (~> 2.3) - railties (5.2.6) - actionpack (= 5.2.6) - activesupport (= 5.2.6) + railties (6.1.4.4) + actionpack (= 6.1.4.4) + activesupport (= 6.1.4.4) method_source - rake (>= 0.8.7) - thor (>= 0.19.0, < 2.0) - rainbow (3.0.0) - raindrops (0.19.2) + rake (>= 0.13) + thor (~> 1.0) + rainbow (3.1.1) + raindrops (0.20.0) rake (13.0.6) rapid-rack (0.3.0) json-jwt - rb-fsevent (0.11.0) + rb-fsevent (0.11.1) rb-inotify (0.10.1) ffi (~> 1.0) - redis (4.4.0) - redis-actionpack (5.2.0) - actionpack (>= 5, < 7) + redis (4.6.0) + redis-actionpack (5.3.0) + actionpack (>= 5, < 8) redis-rack (>= 2.1.0, < 3) redis-store (>= 1.1.0, < 2) - redis-activesupport (5.2.1) - activesupport (>= 3, < 7) + redis-activesupport (5.3.0) + activesupport (>= 3, < 8) redis-store (>= 1.3, < 2) - redis-rack (2.1.3) + redis-rack (2.1.4) rack (>= 2.0.8, < 3) redis-store (>= 1.2, < 2) redis-rails (5.0.2) redis-actionpack (>= 5.0, < 6) redis-activesupport (>= 5.0, < 6) redis-store (>= 1.2, < 2) - redis-store (1.9.0) + redis-store (1.9.1) redis (>= 4, < 5) ref (2.0.0) - regexp_parser (2.1.1) + regexp_parser (2.2.1) rexml (3.2.5) rmagick (2.16.0) - rspec (3.10.0) - rspec-core (~> 3.10.0) - rspec-expectations (~> 3.10.0) - rspec-mocks (~> 3.10.0) - rspec-core (3.10.1) - rspec-support (~> 3.10.0) - rspec-expectations (3.10.1) + rspec (3.11.0) + rspec-core (~> 3.11.0) + rspec-expectations (~> 3.11.0) + rspec-mocks (~> 3.11.0) + rspec-core (3.11.0) + rspec-support (~> 3.11.0) + rspec-expectations (3.11.0) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.10.0) - rspec-mocks (3.10.2) + rspec-support (~> 3.11.0) + rspec-mocks (3.11.0) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.10.0) - rspec-rails (5.0.2) + rspec-support (~> 3.11.0) + rspec-rails (5.1.0) actionpack (>= 5.2) activesupport (>= 5.2) railties (>= 5.2) @@ -275,19 +297,19 @@ GEM rspec-expectations (~> 3.10) rspec-mocks (~> 3.10) rspec-support (~> 3.10) - rspec-support (3.10.2) - rubocop (1.19.0) + rspec-support (3.11.0) + rubocop (1.25.1) parallel (~> 1.10) - parser (>= 3.0.0.0) + parser (>= 3.1.0.0) rainbow (>= 2.2.2, < 4.0) regexp_parser (>= 1.8, < 3.0) rexml - rubocop-ast (>= 1.9.1, < 2.0) + rubocop-ast (>= 1.15.1, < 2.0) ruby-progressbar (~> 1.7) unicode-display_width (>= 1.4.0, < 3.0) - rubocop-ast (1.10.0) - parser (>= 3.0.1.1) - rubocop-rails (2.11.3) + rubocop-ast (1.16.0) + parser (>= 3.1.1.0) + rubocop-rails (2.13.2) activesupport (>= 4.2.0) rack (>= 1.1) rubocop (>= 1.7.0, < 2.0) @@ -303,31 +325,30 @@ GEM sprockets-rails tilt shellany (0.0.1) - shoulda-matchers (5.0.0) + shoulda-matchers (5.1.0) activesupport (>= 5.2.0) simplecov (0.21.2) docile (~> 1.1) simplecov-html (~> 0.11) simplecov_json_formatter (~> 0.1) simplecov-html (0.12.3) - simplecov_json_formatter (0.1.3) + simplecov_json_formatter (0.1.4) slim (4.1.0) temple (>= 0.7.6, < 0.9) tilt (>= 2.0.6, < 2.1) sprockets (3.7.2) concurrent-ruby (~> 1.0) rack (> 1, < 3) - sprockets-rails (3.2.2) - actionpack (>= 4.0) - activesupport (>= 4.0) + sprockets-rails (3.4.2) + actionpack (>= 5.2) + activesupport (>= 5.2) sprockets (>= 3.0.0) temple (0.8.2) terminal-notifier-guard (1.7.0) therubyracer (0.12.3) libv8 (~> 3.16.14.15) ref - thor (1.1.0) - thread_safe (0.3.6) + thor (1.2.1) tilt (2.0.10) timecop (0.9.4) torba (1.1.0) @@ -335,12 +356,12 @@ GEM torba-rails (1.0.2) railties (>= 3.2) torba (~> 1.0) - tzinfo (1.2.9) - thread_safe (~> 0.1) + tzinfo (2.0.4) + concurrent-ruby (~> 1.0) uglifier (4.2.0) execjs (>= 0.3.0, < 3) - unicode-display_width (2.0.0) - unicorn (6.0.0) + unicode-display_width (2.1.0) + unicorn (6.1.0) kgio (~> 2.6) raindrops (~> 0.7) valhammer (1.0.0) @@ -356,6 +377,7 @@ GEM will_paginate (3.3.1) xpath (3.2.0) nokogiri (~> 1.8) + zeitwerk (2.5.4) PLATFORMS ruby @@ -389,7 +411,7 @@ DEPENDENCIES poltergeist pry puma - rails (>= 5, < 6) + rails (= 6.1.4.4) rails-controller-testing rapid-rack redis From 58317078ff6f66dd3047e20cf1d19c5d182bf523 Mon Sep 17 00:00:00 2001 From: Waldo Fouche Date: Wed, 23 Feb 2022 11:58:58 +0800 Subject: [PATCH 02/17] Address rubocop violations (Automatic) --- app/controllers/api/api_controller.rb | 2 +- app/jobs/process_incoming_f_ticks_events.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/api/api_controller.rb b/app/controllers/api/api_controller.rb index 56371811..53397361 100644 --- a/app/controllers/api/api_controller.rb +++ b/app/controllers/api/api_controller.rb @@ -38,7 +38,7 @@ def x509_cn x509_dn_parsed = OpenSSL::X509::Name.parse(x509_dn) x509_dn_hash = - x509_dn_parsed.to_a.map { |components| components[0..1] }.to_h + x509_dn_parsed.to_a.to_h { |components| components[0..1] } x509_dn_hash['CN'] || raise(Unauthorized, 'Subject CN invalid') rescue OpenSSL::X509::NameError diff --git a/app/jobs/process_incoming_f_ticks_events.rb b/app/jobs/process_incoming_f_ticks_events.rb index df4f9021..cba7dfd3 100644 --- a/app/jobs/process_incoming_f_ticks_events.rb +++ b/app/jobs/process_incoming_f_ticks_events.rb @@ -4,7 +4,7 @@ class ProcessIncomingFTicksEvents def perform FederatedLoginEvent.transaction do incoming_events.find_each do |event| - create_instance(event) && event.destroy! || event.discard! + (create_instance(event) && event.destroy!) || event.discard! end end end From f5629ab81ea0e4bcb6fd6c41da44e86996bb0d1e Mon Sep 17 00:00:00 2001 From: Waldo Fouche Date: Wed, 23 Feb 2022 11:59:58 +0800 Subject: [PATCH 03/17] Address rubocop violation `Style/OpenStructUse` Avoid using OpenStruct; use Struct, Hash, a class or test doubles instead. --- config/initializers/app_config.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config/initializers/app_config.rb b/config/initializers/app_config.rb index f4b7e06f..e53f1339 100644 --- a/config/initializers/app_config.rb +++ b/config/initializers/app_config.rb @@ -6,7 +6,7 @@ Rails.application.configure do app_config_file = Rails.root.join('config', 'reporting_service.yml') app_config = YAML.safe_load(app_config_file.read) - config.reporting_service = OpenStruct.new(app_config.deep_symbolize_keys) + config.reporting_service = Struct.new(app_config.deep_symbolize_keys) mail_config = config.reporting_service.mail Mail.defaults { delivery_method :smtp, mail_config } @@ -44,7 +44,7 @@ config.reporting_service.url_options = { base_url: 'example.com' } Aws.config.update(stub_responses: true) - config.reporting_service.mail = OpenStruct.new(from: 'noreply@example.com') + config.reporting_service.mail = Struct.new(from: 'noreply@example.com') config.reporting_service.environment_string = 'Test' Mail.defaults { delivery_method :test } From 721093cf33636cf71567e0fc2b0c7c6431a0af46 Mon Sep 17 00:00:00 2001 From: Waldo Fouche Date: Wed, 23 Feb 2022 12:19:43 +0800 Subject: [PATCH 04/17] Remove broken `ensure_activerecord_databases` check gumboot/strap.rb:28:in `ensure_database': Only supports mysql2 adapter --- bin/setup | 1 - 1 file changed, 1 deletion(-) diff --git a/bin/setup b/bin/setup index c30bb534..865fc13c 100755 --- a/bin/setup +++ b/bin/setup @@ -21,7 +21,6 @@ update_local_configuration %w[reporting_service.yml] puts "\n== Loading Rails environment ==" require_relative '../config/environment' -ensure_activerecord_databases(%w[test development]) maintain_activerecord_schema clean_logs clean_tempfiles From eb552e4156753e430685e67c6c4b86488d8cae0b Mon Sep 17 00:00:00 2001 From: Waldo Fouche Date: Wed, 23 Feb 2022 12:22:53 +0800 Subject: [PATCH 05/17] Suppress `Style/OpenStructUse` violation Implementing the fix causes errors, instead, suppressing the check --- config/initializers/app_config.rb | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/config/initializers/app_config.rb b/config/initializers/app_config.rb index e53f1339..3315c294 100644 --- a/config/initializers/app_config.rb +++ b/config/initializers/app_config.rb @@ -2,11 +2,11 @@ require 'mail' require 'aws-sdk-sqs' - +# rubocop:disable Style/OpenStructUse Rails.application.configure do app_config_file = Rails.root.join('config', 'reporting_service.yml') app_config = YAML.safe_load(app_config_file.read) - config.reporting_service = Struct.new(app_config.deep_symbolize_keys) + config.reporting_service = OpenStruct.new(app_config.deep_symbolize_keys) mail_config = config.reporting_service.mail Mail.defaults { delivery_method :smtp, mail_config } @@ -44,7 +44,7 @@ config.reporting_service.url_options = { base_url: 'example.com' } Aws.config.update(stub_responses: true) - config.reporting_service.mail = Struct.new(from: 'noreply@example.com') + config.reporting_service.mail = OpenStruct.new(from: 'noreply@example.com') config.reporting_service.environment_string = 'Test' Mail.defaults { delivery_method :test } @@ -65,3 +65,5 @@ end end end + +# rubocop:enable Style/OpenStructUse From 04da39d265a75959ca670eb805ac5b4a4e42a7fc Mon Sep 17 00:00:00 2001 From: Waldo Fouche Date: Tue, 1 Mar 2022 09:37:12 +0800 Subject: [PATCH 06/17] Revert to rails `6.0.4.4` As suggested in: https://github.com/ausaccessfed/reporting-service/pull/249#issuecomment-1054775520 --- Gemfile | 2 +- Gemfile.lock | 143 ++++++++++++++++++++++++--------------------------- db/schema.rb | 10 ++-- 3 files changed, 73 insertions(+), 82 deletions(-) diff --git a/Gemfile b/Gemfile index 08a8de25..f7eda04f 100644 --- a/Gemfile +++ b/Gemfile @@ -2,7 +2,7 @@ source 'https://rubygems.org' -gem 'rails', '6.1.4.4' +gem 'rails', '6.0.4.4' gem 'sass-rails' gem 'jbuilder' diff --git a/Gemfile.lock b/Gemfile.lock index 8e088931..cac51067 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -11,78 +11,74 @@ GEM tilt will_paginate accession (1.0.0) - actioncable (6.1.4.4) - actionpack (= 6.1.4.4) - activesupport (= 6.1.4.4) + actioncable (6.0.4.4) + actionpack (= 6.0.4.4) nio4r (~> 2.0) websocket-driver (>= 0.6.1) - actionmailbox (6.1.4.4) - actionpack (= 6.1.4.4) - activejob (= 6.1.4.4) - activerecord (= 6.1.4.4) - activestorage (= 6.1.4.4) - activesupport (= 6.1.4.4) + actionmailbox (6.0.4.4) + actionpack (= 6.0.4.4) + activejob (= 6.0.4.4) + activerecord (= 6.0.4.4) + activestorage (= 6.0.4.4) + activesupport (= 6.0.4.4) mail (>= 2.7.1) - actionmailer (6.1.4.4) - actionpack (= 6.1.4.4) - actionview (= 6.1.4.4) - activejob (= 6.1.4.4) - activesupport (= 6.1.4.4) + actionmailer (6.0.4.4) + actionpack (= 6.0.4.4) + actionview (= 6.0.4.4) + activejob (= 6.0.4.4) mail (~> 2.5, >= 2.5.4) rails-dom-testing (~> 2.0) - actionpack (6.1.4.4) - actionview (= 6.1.4.4) - activesupport (= 6.1.4.4) - rack (~> 2.0, >= 2.0.9) + actionpack (6.0.4.4) + actionview (= 6.0.4.4) + activesupport (= 6.0.4.4) + rack (~> 2.0, >= 2.0.8) rack-test (>= 0.6.3) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.2.0) - actiontext (6.1.4.4) - actionpack (= 6.1.4.4) - activerecord (= 6.1.4.4) - activestorage (= 6.1.4.4) - activesupport (= 6.1.4.4) + actiontext (6.0.4.4) + actionpack (= 6.0.4.4) + activerecord (= 6.0.4.4) + activestorage (= 6.0.4.4) + activesupport (= 6.0.4.4) nokogiri (>= 1.8.5) - actionview (6.1.4.4) - activesupport (= 6.1.4.4) + actionview (6.0.4.4) + activesupport (= 6.0.4.4) builder (~> 3.1) erubi (~> 1.4) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.1, >= 1.2.0) - activejob (6.1.4.4) - activesupport (= 6.1.4.4) + activejob (6.0.4.4) + activesupport (= 6.0.4.4) globalid (>= 0.3.6) - activemodel (6.1.4.4) - activesupport (= 6.1.4.4) - activerecord (6.1.4.4) - activemodel (= 6.1.4.4) - activesupport (= 6.1.4.4) - activestorage (6.1.4.4) - actionpack (= 6.1.4.4) - activejob (= 6.1.4.4) - activerecord (= 6.1.4.4) - activesupport (= 6.1.4.4) + activemodel (6.0.4.4) + activesupport (= 6.0.4.4) + activerecord (6.0.4.4) + activemodel (= 6.0.4.4) + activesupport (= 6.0.4.4) + activestorage (6.0.4.4) + actionpack (= 6.0.4.4) + activejob (= 6.0.4.4) + activerecord (= 6.0.4.4) marcel (~> 1.0.0) - mini_mime (>= 1.1.0) - activesupport (6.1.4.4) + activesupport (6.0.4.4) concurrent-ruby (~> 1.0, >= 1.0.2) - i18n (>= 1.6, < 2) - minitest (>= 5.1) - tzinfo (~> 2.0) - zeitwerk (~> 2.3) + i18n (>= 0.7, < 2) + minitest (~> 5.1) + tzinfo (~> 1.1) + zeitwerk (~> 2.2, >= 2.2.2) addressable (2.8.0) public_suffix (>= 2.0.2, < 5.0) aes_key_wrap (1.1.0) ast (2.4.2) aws-eventstream (1.2.0) - aws-partitions (1.557.0) - aws-sdk-core (3.126.2) + aws-partitions (1.560.0) + aws-sdk-core (3.127.0) aws-eventstream (~> 1, >= 1.0.2) aws-partitions (~> 1, >= 1.525.0) aws-sigv4 (~> 1.1) jmespath (~> 1.0) - aws-sdk-sqs (1.50.0) - aws-sdk-core (~> 3, >= 3.126.0) + aws-sdk-sqs (1.51.0) + aws-sdk-core (~> 3, >= 3.127.0) aws-sigv4 (~> 1.1) aws-sigv4 (1.4.0) aws-eventstream (~> 1, >= 1.0.2) @@ -188,14 +184,10 @@ GEM matrix (0.4.2) method_source (1.0.0) mini_mime (1.1.2) - mini_portile2 (2.8.0) minitest (5.15.0) mysql2 (0.5.3) nenv (0.3.0) nio4r (2.5.8) - nokogiri (1.13.3) - mini_portile2 (~> 2.8.0) - racc (~> 1.4) nokogiri (1.13.3-x86_64-darwin) racc (~> 1.4) notiffany (0.1.3) @@ -218,20 +210,20 @@ GEM rack (2.2.3) rack-test (1.1.0) rack (>= 1.0, < 3) - rails (6.1.4.4) - actioncable (= 6.1.4.4) - actionmailbox (= 6.1.4.4) - actionmailer (= 6.1.4.4) - actionpack (= 6.1.4.4) - actiontext (= 6.1.4.4) - actionview (= 6.1.4.4) - activejob (= 6.1.4.4) - activemodel (= 6.1.4.4) - activerecord (= 6.1.4.4) - activestorage (= 6.1.4.4) - activesupport (= 6.1.4.4) - bundler (>= 1.15.0) - railties (= 6.1.4.4) + rails (6.0.4.4) + actioncable (= 6.0.4.4) + actionmailbox (= 6.0.4.4) + actionmailer (= 6.0.4.4) + actionpack (= 6.0.4.4) + actiontext (= 6.0.4.4) + actionview (= 6.0.4.4) + activejob (= 6.0.4.4) + activemodel (= 6.0.4.4) + activerecord (= 6.0.4.4) + activestorage (= 6.0.4.4) + activesupport (= 6.0.4.4) + bundler (>= 1.3.0) + railties (= 6.0.4.4) sprockets-rails (>= 2.0.0) rails-controller-testing (1.0.5) actionpack (>= 5.0.1.rc1) @@ -242,12 +234,12 @@ GEM nokogiri (>= 1.6) rails-html-sanitizer (1.4.2) loofah (~> 2.3) - railties (6.1.4.4) - actionpack (= 6.1.4.4) - activesupport (= 6.1.4.4) + railties (6.0.4.4) + actionpack (= 6.0.4.4) + activesupport (= 6.0.4.4) method_source - rake (>= 0.13) - thor (~> 1.0) + rake (>= 0.8.7) + thor (>= 0.20.3, < 2.0) rainbow (3.1.1) raindrops (0.20.0) rake (13.0.6) @@ -349,6 +341,7 @@ GEM libv8 (~> 3.16.14.15) ref thor (1.2.1) + thread_safe (0.3.6) tilt (2.0.10) timecop (0.9.4) torba (1.1.0) @@ -356,8 +349,8 @@ GEM torba-rails (1.0.2) railties (>= 3.2) torba (~> 1.0) - tzinfo (2.0.4) - concurrent-ruby (~> 1.0) + tzinfo (1.2.9) + thread_safe (~> 0.1) uglifier (4.2.0) execjs (>= 0.3.0, < 3) unicode-display_width (2.1.0) @@ -380,8 +373,6 @@ GEM zeitwerk (2.5.4) PLATFORMS - ruby - x86_64-darwin-19 x86_64-darwin-20 DEPENDENCIES @@ -411,7 +402,7 @@ DEPENDENCIES poltergeist pry puma - rails (= 6.1.4.4) + rails (= 6.0.4.4) rails-controller-testing rapid-rack redis @@ -434,4 +425,4 @@ DEPENDENCIES webmock BUNDLED WITH - 2.1.4 + 2.2.26 diff --git a/db/schema.rb b/db/schema.rb index 33a902cd..d2a37f8f 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -2,11 +2,11 @@ # of editing this file, please use the migrations feature of Active Record to # incrementally modify your database, and then regenerate this schema definition. # -# Note that this schema.rb definition is the authoritative source for your -# database schema. If you need to create the application database on another -# system, you should be using db:schema:load, not running all the migrations -# from scratch. The latter is a flawed and unsustainable approach (the more migrations -# you'll amass, the slower it'll run and the greater likelihood for issues). +# This file is the source Rails uses to define your schema when running `rails +# db:schema:load`. When creating a new database, `rails db:schema:load` tends to +# be faster and is potentially less error prone than running all of your +# migrations from scratch. Old migrations may fail to apply correctly if those +# migrations use external dependencies or application code. # # It's strongly recommended that you check this file into your version control system. From 16d7e37a7f174153a6bf850e11e1854f222670a6 Mon Sep 17 00:00:00 2001 From: Waldo Fouche Date: Tue, 1 Mar 2022 10:24:14 +0800 Subject: [PATCH 07/17] Update using `Rails app:update` Manually checked the changes and applied relevant ones --- bin/setup | 43 ++++++---- config/environment.rb | 6 +- config/environments/development.rb | 48 +++++++++-- config/environments/production.rb | 83 +++++++++++++++++-- config/environments/test.rb | 23 +++-- config/initializers/backtrace_silencers.rb | 8 +- config/initializers/cookies_serializer.rb | 4 +- .../initializers/filter_parameter_logging.rb | 3 +- 8 files changed, 175 insertions(+), 43 deletions(-) diff --git a/bin/setup b/bin/setup index 865fc13c..0e39e8cb 100755 --- a/bin/setup +++ b/bin/setup @@ -1,26 +1,33 @@ #!/usr/bin/env ruby -# frozen_string_literal: true +require 'fileutils' -Dir.chdir File.expand_path('..', File.dirname(__FILE__)) +# path to your application root. +APP_ROOT = File.expand_path('..', __dir__) -puts '== Installing dependencies ==' -system 'gem install bundler --conservative' -system 'bundle check || bundle install' -system 'bundle exec torba pack' +def system!(*args) + system(*args) || abort("\n== Command #{args} failed ==") +end -require 'bundler/setup' -require 'gumboot/strap' +FileUtils.chdir APP_ROOT do + # This script is a way to setup or update your development environment automatically. + # This script is idempotent, so that you can run it at anytime and get an expectable outcome. + # Add necessary setup steps to this file. -include Gumboot::Strap + puts '== Installing dependencies ==' + system! 'gem install bundler --conservative' + system('bundle check') || system!('bundle install') -puts "\n== Installing configuration files ==" -link_global_configuration %w[rapidconnect.yml api-client.crt api-client.key - event_encryption_key.pem] -update_local_configuration %w[reporting_service.yml] + # puts "\n== Copying sample files ==" + # unless File.exist?('config/database.yml') + # FileUtils.cp 'config/database.yml.sample', 'config/database.yml' + # end -puts "\n== Loading Rails environment ==" -require_relative '../config/environment' + puts "\n== Preparing database ==" + system! 'bin/rails db:prepare' -maintain_activerecord_schema -clean_logs -clean_tempfiles + 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/config/environment.rb b/config/environment.rb index eb669856..426333bb 100644 --- a/config/environment.rb +++ b/config/environment.rb @@ -1,5 +1,5 @@ -# frozen_string_literal: true - -require File.expand_path('application', __dir__) +# Load the Rails application. +require_relative 'application' +# Initialize the Rails application. Rails.application.initialize! diff --git a/config/environments/development.rb b/config/environments/development.rb index 8245998e..5ad2164f 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -1,20 +1,54 @@ -# frozen_string_literal: true - 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 + # since you don't have to restart the web server when you make code changes. config.cache_classes = false + # Do not eager load code on boot. config.eager_load = false - config.consider_all_requests_local = true - config.action_controller.perform_caching = false + # Show full error reports. + config.consider_all_requests_local = true + + # Enable/disable caching. By default caching is disabled. + # Run rails dev:cache to toggle caching. + if Rails.root.join('tmp', 'caching-dev.txt').exist? + config.action_controller.perform_caching = true + config.action_controller.enable_fragment_cache_logging = true + + config.cache_store = :memory_store + config.public_file_server.headers = { + 'Cache-Control' => "public, max-age=#{2.days.to_i}" + } + else + config.action_controller.perform_caching = false - # config.action_mailer.raise_delivery_errors = false + config.cache_store = :null_store + end + # Print deprecation notices to the Rails logger. config.active_support.deprecation = :log + # Raise an error on page load if there are pending migrations. config.active_record.migration_error = :page_load + # Highlight code that triggered database queries in logs. + config.active_record.verbose_query_logs = true + + # Debug mode disables concatenation and preprocessing of assets. + # This option may cause significant delays in view rendering with a large + # number of complex assets. config.assets.debug = true - config.assets.digest = true - config.assets.raise_runtime_errors = true + + # Suppress logger output for asset requests. + config.assets.quiet = true + + # Raises error for missing translations. + # config.action_view.raise_on_missing_translations = true + + # Use an evented file watcher to asynchronously detect changes in source code, + # routes, locales, etc. This feature depends on the listen gem. + config.file_watcher = ActiveSupport::EventedFileUpdateChecker end diff --git a/config/environments/production.rb b/config/environments/production.rb index 2d9cbacf..d73aaa83 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -1,29 +1,98 @@ -# frozen_string_literal: true - Rails.application.configure do + # Settings specified here will take precedence over those in config/application.rb. + + # Code is not reloaded between requests. config.cache_classes = true + # Eager load code on boot. This eager loads most of Rails and + # your application in memory, allowing both threaded web servers + # and those relying on copy on write to perform better. + # Rake tasks automatically ignore this option for performance. config.eager_load = true + # Full error reports are disabled and caching is turned on. config.consider_all_requests_local = false config.action_controller.perform_caching = true + # Ensures that a master key has been made available in either ENV["RAILS_MASTER_KEY"] + # or in config/master.key. This key is used to decrypt credentials (and other encrypted files). + # config.require_master_key = true + + # Disable serving static files from the `/public` folder by default since + # Apache or NGINX already handles this. config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present? - config.public_file_server.headers = { - 'Cache-Control' => 'public, max-age=3600' - } - config.assets.js_compressor = :uglifier + # Compress CSS using a preprocessor. + # config.assets.css_compressor = :sass + + # Do not fallback to assets pipeline if a precompiled asset is missed. config.assets.compile = false - config.assets.digest = true + # Enable serving of images, stylesheets, and JavaScripts from an asset server. + # config.action_controller.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 + # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX + + # 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 + # Prepend all log lines with the following tags. + config.log_tags = [ :request_id ] + + # Use a different cache store in production. + # config.cache_store = :mem_cache_store + + # Use a real queuing backend for Active Job (and separate queues per environment). + # config.active_job.queue_adapter = :resque + # config.active_job.queue_name_prefix = "reporting_service_production" + + # Enable locale fallbacks for I18n (makes lookups for any locale fall back to + # the I18n.default_locale when a translation cannot be found). config.i18n.fallbacks = true + # Send deprecation notices to registered listeners. config.active_support.deprecation = :notify + # 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' + # config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name') + + if ENV["RAILS_LOG_TO_STDOUT"].present? + logger = ActiveSupport::Logger.new(STDOUT) + logger.formatter = config.log_formatter + config.logger = ActiveSupport::TaggedLogging.new(logger) + end + + # Do not dump schema after migrations. config.active_record.dump_schema_after_migration = false + + # Inserts middleware to perform automatic connection switching. + # The `database_selector` hash is used to pass options to the DatabaseSelector + # middleware. The `delay` is used to determine how long to wait after a write + # to send a subsequent read to the primary. + # + # The `database_resolver` class is used by the middleware to determine which + # database is appropriate to use based on the time delay. + # + # The `database_resolver_context` class is used by the middleware to set + # timestamps for the last write to the primary. The resolver uses the context + # class timestamps to determine how long to wait before reading from the + # replica. + # + # By default Rails will store a last write timestamp in the session. The + # DatabaseSelector middleware is designed as such you can define your own + # strategy for connection switching and pass that into the middleware through + # these configuration options. + # config.active_record.database_selector = { delay: 2.seconds } + # config.active_record.database_resolver = ActiveRecord::Middleware::DatabaseSelector::Resolver + # config.active_record.database_resolver_context = ActiveRecord::Middleware::DatabaseSelector::Resolver::Session end diff --git a/config/environments/test.rb b/config/environments/test.rb index d59b33f4..06aef36d 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -1,25 +1,38 @@ -# frozen_string_literal: true +# 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 +# and recreated between test runs. Don't rely on the data there! Rails.application.configure do + # Settings specified here will take precedence over those in config/application.rb. + 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 + # preloads Rails for running tests, you may have to set it to true. config.eager_load = false + # Configure public file server for tests with Cache-Control for performance. config.public_file_server.enabled = true config.public_file_server.headers = { - 'Cache-Control' => 'public, max-age=3600' + 'Cache-Control' => "public, max-age=#{1.hour.to_i}" } + # Show full error reports and disable caching. config.consider_all_requests_local = true config.action_controller.perform_caching = false + config.cache_store = :null_store + # Raise exceptions instead of rendering exception templates. config.action_dispatch.show_exceptions = false + # Disable request forgery protection in test environment. config.action_controller.allow_forgery_protection = false - config.active_support.test_order = :random - + # Print deprecation notices to the stderr. config.active_support.deprecation = :stderr - config.rapid_rack.test_mode = true + # Raises error for missing translations. + # config.action_view.raise_on_missing_translations = true end diff --git a/config/initializers/backtrace_silencers.rb b/config/initializers/backtrace_silencers.rb index 8e9b8f90..59385cdf 100644 --- a/config/initializers/backtrace_silencers.rb +++ b/config/initializers/backtrace_silencers.rb @@ -1 +1,7 @@ -# frozen_string_literal: true +# Be sure to restart your server when you modify this file. + +# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces. +# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ } + +# You can also remove all the silencers if you're trying to debug a problem that might stem from framework code. +# Rails.backtrace_cleaner.remove_silencers! diff --git a/config/initializers/cookies_serializer.rb b/config/initializers/cookies_serializer.rb index 22762bd0..5a6a32d3 100644 --- a/config/initializers/cookies_serializer.rb +++ b/config/initializers/cookies_serializer.rb @@ -1,3 +1,5 @@ -# frozen_string_literal: true +# Be sure to restart your server when you modify this file. +# Specify a serializer for the signed and encrypted cookie jars. +# Valid options are :json, :marshal, and :hybrid. Rails.application.config.action_dispatch.cookies_serializer = :json diff --git a/config/initializers/filter_parameter_logging.rb b/config/initializers/filter_parameter_logging.rb index e25c8cc5..4a994e1e 100644 --- a/config/initializers/filter_parameter_logging.rb +++ b/config/initializers/filter_parameter_logging.rb @@ -1,3 +1,4 @@ -# frozen_string_literal: true +# 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] From 48be674b8b08f8aaa3193583395ffde422772816 Mon Sep 17 00:00:00 2001 From: Waldo Fouche Date: Tue, 1 Mar 2022 10:26:09 +0800 Subject: [PATCH 08/17] Fix `bin/setup` --- bin/setup | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/bin/setup b/bin/setup index 0e39e8cb..4d672700 100755 --- a/bin/setup +++ b/bin/setup @@ -1,5 +1,9 @@ #!/usr/bin/env ruby require 'fileutils' +require 'gumboot/strap' + +include Gumboot::Strap + # path to your application root. APP_ROOT = File.expand_path('..', __dir__) @@ -17,10 +21,11 @@ FileUtils.chdir APP_ROOT do system! 'gem install bundler --conservative' system('bundle check') || system!('bundle install') - # puts "\n== Copying sample files ==" - # unless File.exist?('config/database.yml') - # FileUtils.cp 'config/database.yml.sample', 'config/database.yml' - # end + + puts "\n== Installing configuration files ==" + link_global_configuration %w[rapidconnect.yml api-client.crt api-client.key + event_encryption_key.pem] + update_local_configuration %w[reporting_service.yml] puts "\n== Preparing database ==" system! 'bin/rails db:prepare' From f20add739e7aeb419eb6fbefa4726d57e5877be8 Mon Sep 17 00:00:00 2001 From: Waldo Fouche Date: Tue, 1 Mar 2022 10:37:51 +0800 Subject: [PATCH 09/17] Enable `zietwerk` auto loader --- config/application.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/config/application.rb b/config/application.rb index de1c136c..70dd6e62 100644 --- a/config/application.rb +++ b/config/application.rb @@ -19,6 +19,8 @@ class Application < Rails::Application File.join(config.root, 'app', 'jobs', 'concerns') ] + config.autoloader = :zeitwerk + config.assets.precompile += %w[render_report.js] config.rapid_rack.receiver = 'Authentication::SubjectReceiver' From dba95e025693bf82372c84c43f6c151cfee842a2 Mon Sep 17 00:00:00 2001 From: Waldo Fouche Date: Tue, 1 Mar 2022 12:22:33 +0800 Subject: [PATCH 10/17] Fix `test` configuration --- config/environments/test.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/config/environments/test.rb b/config/environments/test.rb index 06aef36d..6fa04800 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -35,4 +35,7 @@ # Raises error for missing translations. # config.action_view.raise_on_missing_translations = true + + config.active_support.test_order = :random + config.rapid_rack.test_mode = true end From 4ee6c8bb01cd191d7aa79c95e3b84578582bbbcf Mon Sep 17 00:00:00 2001 From: Waldo Fouche Date: Tue, 1 Mar 2022 15:54:42 +0800 Subject: [PATCH 11/17] Add `rubocop-rspec` Used to fix: DEPRECATION WARNING: Static attributes will be removed in FactoryBot 5.0. Please use dynamic attributes instead by wrapping the attribute value in a block: --- Gemfile | 2 ++ Gemfile.lock | 3 +++ 2 files changed, 5 insertions(+) diff --git a/Gemfile b/Gemfile index f7eda04f..bc1b8caf 100644 --- a/Gemfile +++ b/Gemfile @@ -65,3 +65,5 @@ group :development, :test do gem 'terminal-notifier-guard', require: false end # rubocop:enable Metrics/BlockLength + +gem "rubocop-rspec", "~> 2.9" diff --git a/Gemfile.lock b/Gemfile.lock index cac51067..0d286186 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -305,6 +305,8 @@ GEM activesupport (>= 4.2.0) rack (>= 1.1) rubocop (>= 1.7.0, < 2.0) + rubocop-rspec (2.9.0) + rubocop (~> 1.19) ruby-progressbar (1.11.0) sass-rails (6.0.0) sassc-rails (~> 2.1, >= 2.1.1) @@ -411,6 +413,7 @@ DEPENDENCIES rspec-rails rubocop rubocop-rails + rubocop-rspec (~> 2.9) sass-rails shoulda-matchers simplecov From 7e3b216cbf603ab97a47e7d4816be87391521379 Mon Sep 17 00:00:00 2001 From: Waldo Fouche Date: Tue, 1 Mar 2022 15:55:45 +0800 Subject: [PATCH 12/17] Address RSpec `DEPRECATIONS` --- spec/factories/api_subject.rb | 2 +- spec/factories/automated_report.rb | 4 ++-- spec/factories/jwt.rb | 8 ++++---- spec/factories/saml_attribute.rb | 2 +- spec/factories/subject.rb | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/spec/factories/api_subject.rb b/spec/factories/api_subject.rb index ca7d507f..d73631c8 100644 --- a/spec/factories/api_subject.rb +++ b/spec/factories/api_subject.rb @@ -8,7 +8,7 @@ description { Faker::Lorem.sentence } trait :authorized do - transient { permission '*' } + transient { permission { '*' } } after(:create) do |user, attrs| role = create(:permission, value: attrs.permission).role diff --git a/spec/factories/automated_report.rb b/spec/factories/automated_report.rb index d136692c..1f8f9f2a 100644 --- a/spec/factories/automated_report.rb +++ b/spec/factories/automated_report.rb @@ -2,7 +2,7 @@ FactoryBot.define do factory :automated_report do - report_class 'FederationGrowthReport' - interval 'monthly' + report_class { 'FederationGrowthReport' } + interval { 'monthly' } end end diff --git a/spec/factories/jwt.rb b/spec/factories/jwt.rb index 4a2617cf..c5fa88ee 100644 --- a/spec/factories/jwt.rb +++ b/spec/factories/jwt.rb @@ -27,14 +27,14 @@ iat { Time.zone.now.to_i } nbf { 30.seconds.ago.to_i } exp { 30.seconds.from_now.to_i } - typ 'authnresponse' + typ { 'authnresponse' } jti { SecureRandom.hex } config = Rails.configuration.rapid_rack - iss config.issuer - aud config.audience + iss { config.issuer } + aud { config.audience } transient do - secret(config.secret) + secret { config.secret } association :aaf_attributes end diff --git a/spec/factories/saml_attribute.rb b/spec/factories/saml_attribute.rb index 1a65ccdb..e2ea3c76 100644 --- a/spec/factories/saml_attribute.rb +++ b/spec/factories/saml_attribute.rb @@ -7,7 +7,7 @@ core { false } trait :core_attribute do - core true + core { true } end end end diff --git a/spec/factories/subject.rb b/spec/factories/subject.rb index 30a3db28..4c774120 100644 --- a/spec/factories/subject.rb +++ b/spec/factories/subject.rb @@ -13,7 +13,7 @@ mail { Faker::Internet.email(name: name) } trait :authorized do - transient { permission '*' } + transient { permission { '*' } } after(:create) do |user, attrs| role = create(:permission, value: attrs.permission).role From cb5bc1b30c07ad64891411c4253cd306d33d94bd Mon Sep 17 00:00:00 2001 From: Waldo Fouche Date: Tue, 1 Mar 2022 16:04:43 +0800 Subject: [PATCH 13/17] Address Rubocop Violations (Automatic) --- Gemfile | 2 +- config/environment.rb | 2 ++ config/environments/development.rb | 2 ++ config/environments/production.rb | 8 +++++--- config/environments/test.rb | 2 ++ config/initializers/backtrace_silencers.rb | 1 + config/initializers/cookies_serializer.rb | 2 ++ config/initializers/filter_parameter_logging.rb | 2 ++ 8 files changed, 17 insertions(+), 4 deletions(-) diff --git a/Gemfile b/Gemfile index bc1b8caf..ac55df32 100644 --- a/Gemfile +++ b/Gemfile @@ -66,4 +66,4 @@ group :development, :test do end # rubocop:enable Metrics/BlockLength -gem "rubocop-rspec", "~> 2.9" +gem 'rubocop-rspec', '~> 2.9' diff --git a/config/environment.rb b/config/environment.rb index 426333bb..d5abe558 100644 --- a/config/environment.rb +++ b/config/environment.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # Load the Rails application. require_relative 'application' diff --git a/config/environments/development.rb b/config/environments/development.rb index 5ad2164f..6b78294d 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + Rails.application.configure do # Settings specified here will take precedence over those in config/application.rb. diff --git a/config/environments/production.rb b/config/environments/production.rb index d73aaa83..08cd23bb 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + Rails.application.configure do # Settings specified here will take precedence over those in config/application.rb. @@ -43,7 +45,7 @@ config.log_level = :debug # Prepend all log lines with the following tags. - config.log_tags = [ :request_id ] + config.log_tags = [:request_id] # Use a different cache store in production. # config.cache_store = :mem_cache_store @@ -66,8 +68,8 @@ # 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) + if ENV['RAILS_LOG_TO_STDOUT'].present? + logger = ActiveSupport::Logger.new($stdout) logger.formatter = config.log_formatter config.logger = ActiveSupport::TaggedLogging.new(logger) end diff --git a/config/environments/test.rb b/config/environments/test.rb index 6fa04800..d559cca0 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # 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 diff --git a/config/initializers/backtrace_silencers.rb b/config/initializers/backtrace_silencers.rb index 59385cdf..d0f0d3b5 100644 --- a/config/initializers/backtrace_silencers.rb +++ b/config/initializers/backtrace_silencers.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true # Be sure to restart your server when you modify this file. # You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces. diff --git a/config/initializers/cookies_serializer.rb b/config/initializers/cookies_serializer.rb index 5a6a32d3..ee8dff9c 100644 --- a/config/initializers/cookies_serializer.rb +++ b/config/initializers/cookies_serializer.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # Be sure to restart your server when you modify this file. # Specify a serializer for the signed and encrypted cookie jars. diff --git a/config/initializers/filter_parameter_logging.rb b/config/initializers/filter_parameter_logging.rb index 4a994e1e..7a4f47b4 100644 --- a/config/initializers/filter_parameter_logging.rb +++ b/config/initializers/filter_parameter_logging.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # Be sure to restart your server when you modify this file. # Configure sensitive parameters which will be filtered from the log file. From c8ad62be4c01bce074fcfbd238761d68b5b14be8 Mon Sep 17 00:00:00 2001 From: Matthew Puku Date: Wed, 2 Mar 2022 08:42:44 +1000 Subject: [PATCH 14/17] Revert cache configuration for tests --- config/environments/test.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/config/environments/test.rb b/config/environments/test.rb index d559cca0..6363b294 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -24,7 +24,6 @@ # Show full error reports and disable caching. config.consider_all_requests_local = true config.action_controller.perform_caching = false - config.cache_store = :null_store # Raise exceptions instead of rendering exception templates. config.action_dispatch.show_exceptions = false From 8d2a9aae92e1b4e740e0daf6de01edbe4cf33acf Mon Sep 17 00:00:00 2001 From: Waldo Fouche Date: Wed, 2 Mar 2022 09:13:28 +0800 Subject: [PATCH 15/17] Remove `rubocop-rspec` gem No longer required --- Gemfile | 2 -- 1 file changed, 2 deletions(-) diff --git a/Gemfile b/Gemfile index ac55df32..f7eda04f 100644 --- a/Gemfile +++ b/Gemfile @@ -65,5 +65,3 @@ group :development, :test do gem 'terminal-notifier-guard', require: false end # rubocop:enable Metrics/BlockLength - -gem 'rubocop-rspec', '~> 2.9' From 131479bdaa4ad709fb2d781e7db3826b07e2b334 Mon Sep 17 00:00:00 2001 From: Waldo Fouche Date: Wed, 2 Mar 2022 10:01:12 +0800 Subject: [PATCH 16/17] Restore `torba pack` --- bin/setup | 1 + 1 file changed, 1 insertion(+) diff --git a/bin/setup b/bin/setup index 4d672700..75b2f149 100755 --- a/bin/setup +++ b/bin/setup @@ -20,6 +20,7 @@ FileUtils.chdir APP_ROOT do puts '== Installing dependencies ==' system! 'gem install bundler --conservative' system('bundle check') || system!('bundle install') + system 'bundle exec torba pack' puts "\n== Installing configuration files ==" From a55c10d6bfbc134ceb525865cae3e3052c63724b Mon Sep 17 00:00:00 2001 From: Waldo Fouche Date: Wed, 2 Mar 2022 10:01:51 +0800 Subject: [PATCH 17/17] Restore some previous configurations for prod --- config/environments/production.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/config/environments/production.rb b/config/environments/production.rb index 08cd23bb..337c02bb 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -23,12 +23,16 @@ # Disable serving static files from the `/public` folder by default since # Apache or NGINX already handles this. config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present? + config.public_file_server.headers = { + 'Cache-Control' => "public, max-age=#{1.day.to_i}" + } # Compress CSS using a preprocessor. - # config.assets.css_compressor = :sass + config.assets.js_compressor = :uglifier # Do not fallback to assets pipeline if a precompiled asset is missed. config.assets.compile = false + config.assets.digest = true # Enable serving of images, stylesheets, and JavaScripts from an asset server. # config.action_controller.asset_host = 'http://assets.example.com'