diff --git a/Gemfile b/Gemfile index 5a2160831..eaa85cbfd 100644 --- a/Gemfile +++ b/Gemfile @@ -1,6 +1,6 @@ source "https://rubygems.org" -gem "rails", "7.0.8" +gem "rails", "7.1.3.2" gem "activejob-retry" gem "addressable" diff --git a/Gemfile.lock b/Gemfile.lock index 1141e6cb8..2db0d52d5 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,73 +1,82 @@ GEM remote: https://rubygems.org/ specs: - actioncable (7.0.8) - actionpack (= 7.0.8) - activesupport (= 7.0.8) + actioncable (7.1.3.2) + actionpack (= 7.1.3.2) + activesupport (= 7.1.3.2) nio4r (~> 2.0) websocket-driver (>= 0.6.1) - actionmailbox (7.0.8) - actionpack (= 7.0.8) - activejob (= 7.0.8) - activerecord (= 7.0.8) - activestorage (= 7.0.8) - activesupport (= 7.0.8) + zeitwerk (~> 2.6) + actionmailbox (7.1.3.2) + actionpack (= 7.1.3.2) + activejob (= 7.1.3.2) + activerecord (= 7.1.3.2) + activestorage (= 7.1.3.2) + activesupport (= 7.1.3.2) mail (>= 2.7.1) net-imap net-pop net-smtp - actionmailer (7.0.8) - actionpack (= 7.0.8) - actionview (= 7.0.8) - activejob (= 7.0.8) - activesupport (= 7.0.8) + actionmailer (7.1.3.2) + actionpack (= 7.1.3.2) + actionview (= 7.1.3.2) + activejob (= 7.1.3.2) + activesupport (= 7.1.3.2) mail (~> 2.5, >= 2.5.4) net-imap net-pop net-smtp - rails-dom-testing (~> 2.0) - actionpack (7.0.8) - actionview (= 7.0.8) - activesupport (= 7.0.8) - rack (~> 2.0, >= 2.2.4) + rails-dom-testing (~> 2.2) + actionpack (7.1.3.2) + actionview (= 7.1.3.2) + activesupport (= 7.1.3.2) + nokogiri (>= 1.8.5) + racc + rack (>= 2.2.4) + rack-session (>= 1.0.1) rack-test (>= 0.6.3) - rails-dom-testing (~> 2.0) - rails-html-sanitizer (~> 1.0, >= 1.2.0) - actiontext (7.0.8) - actionpack (= 7.0.8) - activerecord (= 7.0.8) - activestorage (= 7.0.8) - activesupport (= 7.0.8) + rails-dom-testing (~> 2.2) + rails-html-sanitizer (~> 1.6) + actiontext (7.1.3.2) + actionpack (= 7.1.3.2) + activerecord (= 7.1.3.2) + activestorage (= 7.1.3.2) + activesupport (= 7.1.3.2) globalid (>= 0.6.0) nokogiri (>= 1.8.5) - actionview (7.0.8) - activesupport (= 7.0.8) + actionview (7.1.3.2) + activesupport (= 7.1.3.2) builder (~> 3.1) - erubi (~> 1.4) - rails-dom-testing (~> 2.0) - rails-html-sanitizer (~> 1.1, >= 1.2.0) - activejob (7.0.8) - activesupport (= 7.0.8) + erubi (~> 1.11) + rails-dom-testing (~> 2.2) + rails-html-sanitizer (~> 1.6) + activejob (7.1.3.2) + activesupport (= 7.1.3.2) globalid (>= 0.3.6) activejob-retry (0.6.3) activejob (>= 4.2) activesupport (>= 4.2) - activemodel (7.0.8) - activesupport (= 7.0.8) - activerecord (7.0.8) - activemodel (= 7.0.8) - activesupport (= 7.0.8) - activestorage (7.0.8) - actionpack (= 7.0.8) - activejob (= 7.0.8) - activerecord (= 7.0.8) - activesupport (= 7.0.8) + activemodel (7.1.3.2) + activesupport (= 7.1.3.2) + activerecord (7.1.3.2) + activemodel (= 7.1.3.2) + activesupport (= 7.1.3.2) + timeout (>= 0.4.0) + activestorage (7.1.3.2) + actionpack (= 7.1.3.2) + activejob (= 7.1.3.2) + activerecord (= 7.1.3.2) + activesupport (= 7.1.3.2) marcel (~> 1.0) - mini_mime (>= 1.1.0) - activesupport (7.0.8) + activesupport (7.1.3.2) + base64 + bigdecimal concurrent-ruby (~> 1.0, >= 1.0.2) + connection_pool (>= 2.2.5) + drb i18n (>= 1.6, < 2) minitest (>= 5.1) + mutex_m tzinfo (~> 2.0) addressable (2.8.6) public_suffix (>= 2.0.2, < 6.0) @@ -135,6 +144,8 @@ GEM domain_name (0.6.20240107) doorkeeper (5.6.9) railties (>= 5) + drb (2.2.0) + ruby2_keywords erubi (1.12.0) execjs (2.9.1) factory_bot (6.4.6) @@ -207,6 +218,10 @@ GEM http-form_data (2.3.0) i18n (1.14.1) concurrent-ruby (~> 1.0) + io-console (0.7.2) + irb (1.11.2) + rdoc + reline (>= 0.4.2) json (2.7.1) jsonpath (1.1.5) multi_json @@ -272,6 +287,7 @@ GEM ruby2_keywords (>= 0.0.5) msgpack (1.7.2) multi_json (1.15.0) + mutex_m (0.2.0) mysql2 (0.5.6) net-imap (0.4.10) date @@ -504,6 +520,8 @@ GEM pry-byebug (3.10.1) byebug (~> 11.0) pry (>= 0.13, < 0.15) + psych (5.1.2) + stringio public_suffix (5.0.4) puma (6.4.2) nio4r (~> 2.0) @@ -515,22 +533,27 @@ GEM rack (>= 1.0, < 4) rack-proxy (0.7.7) rack + rack-session (1.0.2) + rack (< 3) rack-test (2.1.0) rack (>= 1.3) - rails (7.0.8) - actioncable (= 7.0.8) - actionmailbox (= 7.0.8) - actionmailer (= 7.0.8) - actionpack (= 7.0.8) - actiontext (= 7.0.8) - actionview (= 7.0.8) - activejob (= 7.0.8) - activemodel (= 7.0.8) - activerecord (= 7.0.8) - activestorage (= 7.0.8) - activesupport (= 7.0.8) + rackup (1.0.0) + rack (< 3) + webrick + rails (7.1.3.2) + actioncable (= 7.1.3.2) + actionmailbox (= 7.1.3.2) + actionmailer (= 7.1.3.2) + actionpack (= 7.1.3.2) + actiontext (= 7.1.3.2) + actionview (= 7.1.3.2) + activejob (= 7.1.3.2) + activemodel (= 7.1.3.2) + activerecord (= 7.1.3.2) + activestorage (= 7.1.3.2) + activesupport (= 7.1.3.2) bundler (>= 1.15.0) - railties (= 7.0.8) + railties (= 7.1.3.2) rails-controller-testing (1.0.5) actionpack (>= 5.0.1.rc1) actionview (>= 5.0.1.rc1) @@ -542,23 +565,28 @@ GEM rails-html-sanitizer (1.6.0) loofah (~> 2.21) nokogiri (~> 1.14) - railties (7.0.8) - actionpack (= 7.0.8) - activesupport (= 7.0.8) - method_source + railties (7.1.3.2) + actionpack (= 7.1.3.2) + activesupport (= 7.1.3.2) + irb + rackup (>= 1.0.0) rake (>= 12.2) - thor (~> 1.0) - zeitwerk (~> 2.5) + thor (~> 1.0, >= 1.2.2) + zeitwerk (~> 2.6) rainbow (3.1.1) rake (13.1.0) rb-fsevent (0.11.2) rb-inotify (0.10.1) ffi (~> 1.0) + rdoc (6.6.2) + psych (>= 4.0.0) recursive-open-struct (1.1.3) redis (4.8.1) redis-namespace (1.11.0) redis (>= 4) regexp_parser (2.9.0) + reline (0.4.3) + io-console (~> 0.5) request_store (1.6.0) rack (>= 1.4) responders (3.1.1) @@ -654,6 +682,7 @@ GEM activesupport (>= 5.2) sprockets (>= 3.0.0) statsd-ruby (1.5.0) + stringio (3.1.0) systemu (2.6.5) thor (1.3.0) timecop (0.9.8) @@ -725,7 +754,7 @@ DEPENDENCIES pry-byebug pundit rack-attack - rails (= 7.0.8) + rails (= 7.1.3.2) rails-controller-testing rails-html-sanitizer rake diff --git a/app/models/batch_invitation.rb b/app/models/batch_invitation.rb index 29cc916f1..39674bfb6 100644 --- a/app/models/batch_invitation.rb +++ b/app/models/batch_invitation.rb @@ -5,7 +5,7 @@ class BatchInvitation < ApplicationRecord has_many :batch_invitation_application_permissions, inverse_of: :batch_invitation has_many :supported_permissions, through: :batch_invitation_application_permissions - serialize :applications_and_permissions, Hash + serialize :applications_and_permissions, type: Hash, coder: YAML attr_accessor :user_names_and_emails diff --git a/bin/setup b/bin/setup index ec47b79b3..3cd5a9d78 100755 --- a/bin/setup +++ b/bin/setup @@ -5,7 +5,7 @@ require "fileutils" APP_ROOT = File.expand_path("..", __dir__) def system!(*args) - system(*args) || abort("\n== Command #{args} failed ==") + system(*args, exception: true) end FileUtils.chdir APP_ROOT do diff --git a/config/application.rb b/config/application.rb index 7c5c6d8eb..1f854327f 100644 --- a/config/application.rb +++ b/config/application.rb @@ -21,19 +21,32 @@ module Signon class Application < Rails::Application # Initialize configuration defaults for originally generated Rails version. - config.load_defaults 7.0 + config.load_defaults 7.1 config.active_record.belongs_to_required_by_default = false - config.active_record.encryption.key_derivation_salt = Rails.application.secrets.active_record_encryption[:key_derivation_salt] - config.active_record.encryption.primary_key = Rails.application.secrets.active_record_encryption[:primary_key] + # Rails 7 has begun to deprecate Rails.application.credentials in favour + # of Rails.application.credentials, but that adds the burden of master key + # administration without giving us any benefit (because our production + # secrets are handled as env vars, not committed to our repo. Here we + # loads the config/secrets.YML values into Rails.application.credentials, + # retaining the existing behaviour while dropping deprecated references. + Rails.application.credentials.merge!(Rails.application.config_for(:secrets)) + + config.active_record.encryption.key_derivation_salt = Rails.application.credentials.dig(:active_record_encryption, :key_derivation_salt) + config.active_record.encryption.primary_key = Rails.application.credentials.dig(:active_record_encryption, :primary_key) + + # Please, add to the `ignore` list any other `lib` subdirectories that do + # not contain `.rb` files, or that should not be reloaded or eager loaded. + # Common ones are `templates`, `generators`, or `middleware`, for example. + config.autoload_lib(ignore: %w[assets tasks]) # 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 config.action_mailer.notify_settings = { - api_key: Rails.application.secrets.notify_api_key || "fake-test-api-key", + api_key: Rails.application.credentials.notify_api_key || "fake-test-api-key", } # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone. @@ -78,6 +91,16 @@ class Application < Rails::Application # https://github.com/alphagov/govuk-frontend/issues/1350 config.assets.css_compressor = nil + # 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") + config.show_user_research_recruitment_banner = false + + config.add_autoload_paths_to_load_path = true + + config.active_record.encryption.support_sha1_for_non_deterministic_encryption = true end end diff --git a/config/environments/development.rb b/config/environments/development.rb index 022ae9048..1e5ba52b2 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -6,7 +6,7 @@ # 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 + config.enable_reloading = true # Do not eager load code on boot. config.eager_load = false @@ -60,6 +60,9 @@ # Highlight code that triggered database queries in logs. config.active_record.verbose_query_logs = true + # Highlight code that enqueued background job in logs. + config.active_job.verbose_enqueue_logs = true + # Suppress logger output for asset requests. config.assets.quiet = true @@ -84,4 +87,7 @@ # Uncomment if you wish to allow Action Cable access from any origin. # config.action_cable.disable_request_forgery_protection = true + + # Raise error when a before_action's only/except options reference missing actions + config.action_controller.raise_on_missing_callback_actions = true end diff --git a/config/environments/production.rb b/config/environments/production.rb index f21523cf0..ae26639f4 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -4,7 +4,7 @@ # Settings specified here will take precedence over those in config/application.rb. # Code is not reloaded between requests. - config.cache_classes = true + config.enable_reloading = false # Eager load code on boot. This eager loads most of Rails and # your application in memory, allowing both threaded web servers @@ -13,21 +13,20 @@ config.eager_load = true # Full error reports are disabled and caching is turned on. - config.consider_all_requests_local = false + 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). + # Ensures that a master key has been made available in ENV["RAILS_MASTER_KEY"], config/master.key, or an environment + # key such as config/credentials/production.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. + # Disable serving static files from `public/`, relying on NGINX/Apache to do so instead. config.public_file_server.enabled = ENV["RAILS_SERVE_STATIC_FILES"].present? # Compress CSS using a preprocessor. # config.assets.css_compressor = :sass - # Do not fallback to assets pipeline if a precompiled asset is missed. + # Do not fall back to assets pipeline if a precompiled asset is missed. config.assets.compile = false # Enable serving of images, stylesheets, and JavaScripts from an asset server. @@ -43,21 +42,26 @@ # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for Apache # config.action_dispatch.x_sendfile_header = "X-Accel-Redirect" # for NGINX + # Assume all access to the app is happening through a SSL-terminating reverse proxy. + # Can be used together with config.force_ssl for Strict-Transport-Security and secure cookies. + # config.assume_ssl = true + # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. # config.force_ssl = true - # 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 = ENV.fetch("RAILS_LOG_LEVEL", :info) - # Prepend all log lines with the following tags. config.log_tags = [:request_id] + # "info" includes generic and useful information about system operation, but avoids logging too much + # information to avoid inadvertent exposure of personally identifiable information (PII). If you + # want to log everything, set the level to "debug". + config.log_level = ENV.fetch("RAILS_LOG_LEVEL", "info") + # 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_adapter = :resque # config.active_job.queue_name_prefix = "signon_production" config.action_mailer.perform_caching = false @@ -87,11 +91,19 @@ # 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) + config.logger = ActiveSupport::Logger.new($stdout) + .tap { |logger| logger.formatter = ::Logger::Formatter.new } + .then { |logger| ActiveSupport::TaggedLogging.new(logger) } end # Do not dump schema after migrations. config.active_record.dump_schema_after_migration = false + + # Enable DNS rebinding protection and other `Host` header attacks. + # config.hosts = [ + # "example.com", # Allow requests from example.com + # /.*\.example\.com/ # Allow requests from subdomains like `www.example.com` + # ] + # Skip DNS rebinding protection for the default health check endpoint. + # config.host_authorization = { exclude: ->(request) { request.path == "/up" } } end diff --git a/config/environments/test.rb b/config/environments/test.rb index a60b470d0..d400a2758 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -8,12 +8,13 @@ Rails.application.configure do # Settings specified here will take precedence over those in config/application.rb. - # Turn false under Spring and add config.action_view.cache_template_loading = true. - config.cache_classes = true + # While tests run files are not watched, reloading is not necessary. + config.enable_reloading = false - # Eager loading loads your whole application. When running a single test locally, - # this probably isn't necessary. It's a good idea to do in a continuous integration - # system, or in some way before deploying your code. + # Eager loading loads your entire application. When running a single test locally, + # this is usually not necessary, and can slow down your test suite. However, it's + # recommended that you enable it in continuous integration systems to ensure eager + # loading is working properly before deploying your code. config.eager_load = ENV["CI"].present? # Configure public file server for tests with Cache-Control for performance. @@ -23,12 +24,12 @@ } # Show full error reports and disable caching. - config.consider_all_requests_local = true + 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 + # Render exception templates for rescuable exceptions and raise for other exceptions. + config.action_dispatch.show_exceptions = :none # Disable request forgery protection in test environment. config.action_controller.allow_forgery_protection = false @@ -47,8 +48,6 @@ # Raise exceptions for disallowed deprecations. config.active_support.disallowed_deprecation = :raise - config.active_support.test_order = :random - config.active_job.queue_adapter = :test # Tell Active Support which deprecation messages to disallow. @@ -66,5 +65,8 @@ config.logger = Logger.new($stdout) config.log_level = :fatal + # Raise error when a before_action's only/except options reference missing actions + config.action_controller.raise_on_missing_callback_actions = true + config.show_user_research_recruitment_banner = true end diff --git a/config/initializers/filter_parameter_logging.rb b/config/initializers/filter_parameter_logging.rb index 166997c5a..262e86202 100644 --- a/config/initializers/filter_parameter_logging.rb +++ b/config/initializers/filter_parameter_logging.rb @@ -1,8 +1,8 @@ # Be sure to restart your server when you modify this file. -# Configure parameters to be filtered from the log file. Use this to limit dissemination of -# sensitive information. See the ActiveSupport::ParameterFilter documentation for supported -# notations and behaviors. +# Configure parameters to be partially matched (e.g. passw matches password) and filtered from the log file. +# Use this to limit dissemination of sensitive information. +# See the ActiveSupport::ParameterFilter documentation for supported notations and behaviors. Rails.application.config.filter_parameters += %i[ passw secret token _key crypt salt certificate otp ssn ] diff --git a/config/initializers/permissions_policy.rb b/config/initializers/permissions_policy.rb index 00f64d71b..7db3b9577 100644 --- a/config/initializers/permissions_policy.rb +++ b/config/initializers/permissions_policy.rb @@ -1,11 +1,13 @@ +# Be sure to restart your server when you modify this file. + # Define an application-wide HTTP permissions policy. For further -# information see https://developers.google.com/web/updates/2018/06/feature-policy -# -# Rails.application.config.permissions_policy do |f| -# f.camera :none -# f.gyroscope :none -# f.microphone :none -# f.usb :none -# f.fullscreen :self -# f.payment :self, "https://secure.example.com" +# information see: https://developers.google.com/web/updates/2018/06/feature-policy + +# Rails.application.config.permissions_policy do |policy| +# policy.camera :none +# policy.gyroscope :none +# policy.microphone :none +# policy.usb :none +# policy.fullscreen :self +# policy.payment :self, "https://secure.example.com" # end diff --git a/db/migrate/20230126115902_add_reason_for_2sv_exemption_to_user.rb b/db/migrate/20230126115902_add_reason_for_2sv_exemption_to_user.rb deleted file mode 100644 index 274512d54..000000000 --- a/db/migrate/20230126115902_add_reason_for_2sv_exemption_to_user.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddReasonFor2svExemptionToUser < ActiveRecord::Migration[7.0] - def change - add_column :users, :reason_for_2sv_exemption, :string - end -end diff --git a/db/migrate/20230206131707_add_require2sv_to_organisations.rb b/db/migrate/20230206131707_add_require2sv_to_organisations.rb deleted file mode 100644 index 32d06216f..000000000 --- a/db/migrate/20230206131707_add_require2sv_to_organisations.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddRequire2svToOrganisations < ActiveRecord::Migration[7.0] - def change - add_column :organisations, :require_2sv, :boolean, null: false, default: false - end -end diff --git a/db/migrate/20230209131935_add2_sv_exemption_expiry_date_to_users.rb b/db/migrate/20230209131935_add2_sv_exemption_expiry_date_to_users.rb deleted file mode 100644 index 4002e4069..000000000 --- a/db/migrate/20230209131935_add2_sv_exemption_expiry_date_to_users.rb +++ /dev/null @@ -1,5 +0,0 @@ -class Add2SvExemptionExpiryDateToUsers < ActiveRecord::Migration[7.0] - def change - add_column :users, :expiry_date_for_2sv_exemption, :date - end -end diff --git a/db/migrate/20230613153019_add_foreign_key_constraint_to_application_id_on_oauth_access_tokens.rb b/db/migrate/20230613153019_add_foreign_key_constraint_to_application_id_on_oauth_access_tokens.rb deleted file mode 100644 index 199409c47..000000000 --- a/db/migrate/20230613153019_add_foreign_key_constraint_to_application_id_on_oauth_access_tokens.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddForeignKeyConstraintToApplicationIdOnOauthAccessTokens < ActiveRecord::Migration[7.0] - def change - add_foreign_key :oauth_access_tokens, :oauth_applications, column: :application_id - end -end diff --git a/db/migrate/20230622122857_add_missing_application_created_at_timestamps.rb b/db/migrate/20230622122857_add_missing_application_created_at_timestamps.rb deleted file mode 100644 index 7acbea24b..000000000 --- a/db/migrate/20230622122857_add_missing_application_created_at_timestamps.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddMissingApplicationCreatedAtTimestamps < ActiveRecord::Migration[7.0] - def up - Doorkeeper::Application.where(created_at: nil).update_all(created_at: Date.parse("2012-01-01")) - end -end diff --git a/db/migrate/20230629083629_update_sso_push_user_name.rb b/db/migrate/20230629083629_update_sso_push_user_name.rb deleted file mode 100644 index b8aa279d6..000000000 --- a/db/migrate/20230629083629_update_sso_push_user_name.rb +++ /dev/null @@ -1,13 +0,0 @@ -class UpdateSSOPushUserName < ActiveRecord::Migration[7.0] - OLD_USER_NAME = "Signonotron API Client (permission and suspension updater)".freeze - NEW_USER_NAME = "Signon API Client (permission and suspension updater)".freeze - USER_EMAIL = "signon+permissions@alphagov.co.uk".freeze - - def up - update "UPDATE users SET name = '#{NEW_USER_NAME}' WHERE email = '#{USER_EMAIL}'" - end - - def down - update "UPDATE users SET name = '#{OLD_USER_NAME}' WHERE email = '#{USER_EMAIL}'" - end -end diff --git a/db/migrate/20230629103443_change_batch_invitation_users_to_use_utf8mb3_charset.rb b/db/migrate/20230629103443_change_batch_invitation_users_to_use_utf8mb3_charset.rb deleted file mode 100644 index 30900cb27..000000000 --- a/db/migrate/20230629103443_change_batch_invitation_users_to_use_utf8mb3_charset.rb +++ /dev/null @@ -1,9 +0,0 @@ -class ChangeBatchInvitationUsersToUseUtf8mb3Charset < ActiveRecord::Migration[7.0] - def up - execute "ALTER TABLE `batch_invitation_users` DEFAULT CHARACTER SET = utf8mb3;" - execute "ALTER TABLE `batch_invitation_users` MODIFY COLUMN `name` varchar(255) CHARACTER SET utf8mb3;" - execute "ALTER TABLE `batch_invitation_users` MODIFY COLUMN `email` varchar(255) CHARACTER SET utf8mb3;" - execute "ALTER TABLE `batch_invitation_users` MODIFY COLUMN `outcome` varchar(255) CHARACTER SET utf8mb3;" - execute "ALTER TABLE `batch_invitation_users` MODIFY COLUMN `organisation_slug` varchar(255) CHARACTER SET utf8mb3;" - end -end diff --git a/db/migrate/20230801131609_change_event_logs_trailing_message_column.rb b/db/migrate/20230801131609_change_event_logs_trailing_message_column.rb deleted file mode 100644 index f27b5a5e1..000000000 --- a/db/migrate/20230801131609_change_event_logs_trailing_message_column.rb +++ /dev/null @@ -1,9 +0,0 @@ -class ChangeEventLogsTrailingMessageColumn < ActiveRecord::Migration[7.0] - def up - change_column :event_logs, :trailing_message, :text - end - - def down - change_column :event_logs, :trailing_message, :string - end -end diff --git a/db/migrate/20230802095323_strip_whitespace_from_users_names.rb b/db/migrate/20230802095323_strip_whitespace_from_users_names.rb deleted file mode 100644 index bbf8cae91..000000000 --- a/db/migrate/20230802095323_strip_whitespace_from_users_names.rb +++ /dev/null @@ -1,11 +0,0 @@ -class StripWhitespaceFromUsersNames < ActiveRecord::Migration[7.0] - NAME_HAS_LEADING_OR_TRAILING_SPACE = "name REGEXP('^\s+') OR name REGEXP('\s+$')".freeze - - def up - User.where(NAME_HAS_LEADING_OR_TRAILING_SPACE).find_each(&:save!) - - BatchInvitationUser.where(NAME_HAS_LEADING_OR_TRAILING_SPACE).find_each(&:save!) - end - - def down; end -end diff --git a/db/migrate/20230804094159_add_user_research_recruitment_banner_hidden_to_users.rb b/db/migrate/20230804094159_add_user_research_recruitment_banner_hidden_to_users.rb deleted file mode 100644 index fa15027a5..000000000 --- a/db/migrate/20230804094159_add_user_research_recruitment_banner_hidden_to_users.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddUserResearchRecruitmentBannerHiddenToUsers < ActiveRecord::Migration[7.0] - def change - add_column :users, :user_research_recruitment_banner_hidden, :boolean, default: false - end -end diff --git a/db/migrate/20230814160809_enable_pkce.rb b/db/migrate/20230814160809_enable_pkce.rb deleted file mode 100644 index d286ef897..000000000 --- a/db/migrate/20230814160809_enable_pkce.rb +++ /dev/null @@ -1,10 +0,0 @@ -# frozen_string_literal: true - -class EnablePkce < ActiveRecord::Migration[7.0] - def change - change_table :oauth_access_grants, bulk: true do |t| - t.column :code_challenge, :string, null: true - t.column :code_challenge_method, :string, null: true - end - end -end diff --git a/db/migrate/20230816164936_revoke_access_tokens_for_suspended_users.rb b/db/migrate/20230816164936_revoke_access_tokens_for_suspended_users.rb deleted file mode 100644 index 251e71a98..000000000 --- a/db/migrate/20230816164936_revoke_access_tokens_for_suspended_users.rb +++ /dev/null @@ -1,8 +0,0 @@ -class RevokeAccessTokensForSuspendedUsers < ActiveRecord::Migration[7.0] - def up - User.with_status(User::USER_STATUS_SUSPENDED) - .find_each(&:revoke_all_authorisations) - end - - def down; end -end diff --git a/db/migrate/20230911092404_strip_whitespace_from_organisation_names.rb b/db/migrate/20230911092404_strip_whitespace_from_organisation_names.rb deleted file mode 100644 index 85a6530f1..000000000 --- a/db/migrate/20230911092404_strip_whitespace_from_organisation_names.rb +++ /dev/null @@ -1,9 +0,0 @@ -class StripWhitespaceFromOrganisationNames < ActiveRecord::Migration[7.0] - NAME_HAS_LEADING_OR_TRAILING_SPACE = "name REGEXP('^\s+') OR name REGEXP('\s+$')".freeze - - def up - Organisation.where(NAME_HAS_LEADING_OR_TRAILING_SPACE).find_each(&:save!) - end - - def down; end -end diff --git a/db/migrate/20230918141453_drop_bulk_grant_permission_sets_et_al.rb b/db/migrate/20230918141453_drop_bulk_grant_permission_sets_et_al.rb deleted file mode 100644 index 9004e3f9d..000000000 --- a/db/migrate/20230918141453_drop_bulk_grant_permission_sets_et_al.rb +++ /dev/null @@ -1,27 +0,0 @@ -class DropBulkGrantPermissionSetsEtAl < ActiveRecord::Migration[7.0] - def change - drop_table :bulk_grant_permission_set_application_permissions do |t| - t.belongs_to :bulk_grant_permission_set, - null: false, - index: { name: "index_bulk_grant_permissions_on_bulk_grant_permission_set_id" } - t.belongs_to :supported_permission, - null: false, - index: { name: "index_bulk_grant_permissions_on_permission_id" } - - t.timestamps - - t.index %i[bulk_grant_permission_set_id supported_permission_id], - name: "index_bulk_grant_permissions_on_permission_id_and_bulk_grant_id", - unique: true - end - - drop_table :bulk_grant_permission_sets do |t| - t.belongs_to :user - t.string :outcome - t.integer :processed_users, default: 0, null: false - t.integer :total_users, default: 0, null: false - - t.timestamps - end - end -end diff --git a/db/migrate/20230925093142_strip_whitespace_from_batch_invitation_user_email.rb b/db/migrate/20230925093142_strip_whitespace_from_batch_invitation_user_email.rb deleted file mode 100644 index e53ca2200..000000000 --- a/db/migrate/20230925093142_strip_whitespace_from_batch_invitation_user_email.rb +++ /dev/null @@ -1,7 +0,0 @@ -class StripWhitespaceFromBatchInvitationUserEmail < ActiveRecord::Migration[7.0] - def change - BatchInvitationUser.where("email REGEXP ? OR email REGEXP ?", "^\\s+", "\\s+$").find_each do |biu| - biu.update_attribute(:email, biu.email&.strip) # rubocop:disable Rails/SkipsModelValidations - end - end -end diff --git a/db/migrate/20230925093143_strip_whitespace_from_batch_invitation_user_organisation_slug.rb b/db/migrate/20230925093143_strip_whitespace_from_batch_invitation_user_organisation_slug.rb deleted file mode 100644 index cdadea6ca..000000000 --- a/db/migrate/20230925093143_strip_whitespace_from_batch_invitation_user_organisation_slug.rb +++ /dev/null @@ -1,7 +0,0 @@ -class StripWhitespaceFromBatchInvitationUserOrganisationSlug < ActiveRecord::Migration[7.0] - def change - BatchInvitationUser.where("organisation_slug REGEXP ? OR organisation_slug REGEXP ?", "^\\s+", "\\s+$").find_each do |biu| - biu.update_attribute(:organisation_slug, biu.organisation_slug&.strip) # rubocop:disable Rails/SkipsModelValidations - end - end -end diff --git a/db/migrate/20230925104847_strip_whitespace_from_user_name.rb b/db/migrate/20230925104847_strip_whitespace_from_user_name.rb deleted file mode 100644 index 74c26c1ff..000000000 --- a/db/migrate/20230925104847_strip_whitespace_from_user_name.rb +++ /dev/null @@ -1,7 +0,0 @@ -class StripWhitespaceFromUserName < ActiveRecord::Migration[7.0] - def change - User.where("name REGEXP ? OR name REGEXP ?", "^\\s+", "\\s+$").find_each do |u| - u.update_attribute(:name, u.name&.strip) # rubocop:disable Rails/SkipsModelValidations - end - end -end diff --git a/db/migrate/20230925104848_strip_whitespace_from_batch_invitation_user_name.rb b/db/migrate/20230925104848_strip_whitespace_from_batch_invitation_user_name.rb deleted file mode 100644 index 63e686659..000000000 --- a/db/migrate/20230925104848_strip_whitespace_from_batch_invitation_user_name.rb +++ /dev/null @@ -1,7 +0,0 @@ -class StripWhitespaceFromBatchInvitationUserName < ActiveRecord::Migration[7.0] - def change - BatchInvitationUser.where("name REGEXP ? OR name REGEXP ?", "^\\s+", "\\s+$").find_each do |u| - u.update_attribute(:name, u.name&.strip) # rubocop:disable Rails/SkipsModelValidations - end - end -end diff --git a/db/migrate/20230925104849_strip_whitespace_from_organisation_name.rb b/db/migrate/20230925104849_strip_whitespace_from_organisation_name.rb deleted file mode 100644 index c8053ac96..000000000 --- a/db/migrate/20230925104849_strip_whitespace_from_organisation_name.rb +++ /dev/null @@ -1,7 +0,0 @@ -class StripWhitespaceFromOrganisationName < ActiveRecord::Migration[7.0] - def change - Organisation.where("name REGEXP ? OR name REGEXP ?", "^\\s+", "\\s+$").find_each do |o| - o.update_attribute(:name, o.name&.strip) # rubocop:disable Rails/SkipsModelValidations - end - end -end diff --git a/db/migrate/20231017152747_add_foreign_key_constraint_for_user_application_permissions_application_id.rb b/db/migrate/20231017152747_add_foreign_key_constraint_for_user_application_permissions_application_id.rb deleted file mode 100644 index 4eeb1aa18..000000000 --- a/db/migrate/20231017152747_add_foreign_key_constraint_for_user_application_permissions_application_id.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddForeignKeyConstraintForUserApplicationPermissionsApplicationId < ActiveRecord::Migration[7.0] - def change - add_foreign_key :user_application_permissions, :oauth_applications, column: :application_id - end -end diff --git a/db/migrate/20231017153040_add_not_null_constraint_for_supported_permissions_application_id.rb b/db/migrate/20231017153040_add_not_null_constraint_for_supported_permissions_application_id.rb deleted file mode 100644 index cef3990d5..000000000 --- a/db/migrate/20231017153040_add_not_null_constraint_for_supported_permissions_application_id.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddNotNullConstraintForSupportedPermissionsApplicationId < ActiveRecord::Migration[7.0] - def change - change_column_null :supported_permissions, :application_id, false - end -end diff --git a/db/migrate/20231017153357_add_foreign_key_constraint_for_supported_permissions_application_id.rb b/db/migrate/20231017153357_add_foreign_key_constraint_for_supported_permissions_application_id.rb deleted file mode 100644 index 1a56a5579..000000000 --- a/db/migrate/20231017153357_add_foreign_key_constraint_for_supported_permissions_application_id.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddForeignKeyConstraintForSupportedPermissionsApplicationId < ActiveRecord::Migration[7.0] - def change - add_foreign_key :supported_permissions, :oauth_applications, column: :application_id - end -end diff --git a/db/migrate/20231018141956_add_not_null_constraint_to_oauth_applications_retired.rb b/db/migrate/20231018141956_add_not_null_constraint_to_oauth_applications_retired.rb deleted file mode 100644 index 625474cab..000000000 --- a/db/migrate/20231018141956_add_not_null_constraint_to_oauth_applications_retired.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddNotNullConstraintToOauthApplicationsRetired < ActiveRecord::Migration[7.0] - def change - change_column_null :oauth_applications, :retired, false, false - end -end diff --git a/db/migrate/20231019080657_replace_oauth_applications_show_on_dashboard_with_api_only.rb b/db/migrate/20231019080657_replace_oauth_applications_show_on_dashboard_with_api_only.rb deleted file mode 100644 index ed06ac680..000000000 --- a/db/migrate/20231019080657_replace_oauth_applications_show_on_dashboard_with_api_only.rb +++ /dev/null @@ -1,17 +0,0 @@ -class ReplaceOauthApplicationsShowOnDashboardWithApiOnly < ActiveRecord::Migration[7.0] - def up - add_column :oauth_applications, :api_only, :boolean, default: false, null: false - - update "UPDATE oauth_applications SET api_only = !show_on_dashboard" - - remove_column :oauth_applications, :show_on_dashboard - end - - def down - add_column :oauth_applications, :show_on_dashboard, :boolean, default: true, null: false - - update "UPDATE oauth_applications SET show_on_dashboard = !api_only" - - remove_column :oauth_applications, :api_only - end -end diff --git a/test/models/batch_invitation_user_test.rb b/test/models/batch_invitation_user_test.rb index 1eaf229e5..ed403a918 100644 --- a/test/models/batch_invitation_user_test.rb +++ b/test/models/batch_invitation_user_test.rb @@ -68,15 +68,13 @@ class BatchInvitationUserTest < ActiveSupport::TestCase should "store invitation attributes against a user" do user = create(:batch_invitation_user, batch_invitation: @batch_invitation) - # the attributes that're passed to User#invite! should be a permitted - # params object - invitation_attributes = ActionController::Parameters.new( - name: user.name, - email: user.email, - organisation_id: user.organisation_id, - supported_permission_ids: [1, 2, 3], - require_2sv: false, - ) + invitation_attributes = { + "name" => user.name, + "email" => user.email, + "organisation_id" => user.organisation_id, + "require_2sv" => false, + "supported_permission_ids" => [1, 2, 3], + } User.expects(:invite!).with(invitation_attributes, @inviting_user) user.invite(@inviting_user, [1, 2, 3])