From 2ea036c3bb0a506ea5b9a9359f8bbc7f2766618e Mon Sep 17 00:00:00 2001 From: Patrick Cherry Date: Tue, 2 Jul 2024 16:52:48 +0100 Subject: [PATCH 01/13] Add test route thing --- config/routes.rb | 4 +++ gemfiles/rails_6.1.gemfile.lock | 23 ++++++++-------- gemfiles/rails_7.0.gemfile.lock | 10 +++---- gemfiles/rails_7.1.gemfile.lock | 27 ++++++++++--------- lib/rpi_auth/engine.rb | 1 + spec/dummy/spec/requests/auth_request_spec.rb | 2 +- spec/dummy/spec/requests/home_request_spec.rb | 2 +- 7 files changed, 39 insertions(+), 30 deletions(-) diff --git a/config/routes.rb b/config/routes.rb index 85e0585..6f16593 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -9,4 +9,8 @@ get RpiAuth::Engine::CALLBACK_PATH, to: 'rpi_auth/auth#callback', as: 'rpi_auth_callback' get RpiAuth::Engine::LOGOUT_PATH, to: 'rpi_auth/auth#destroy', as: 'rpi_auth_logout' + + # This route can be used in testing to log in, avoiding the need to interact + # with shadow root in the RPF global nav. + get RpiAuth::Engine::TEST_PATH, to: 'rpi_auth/test#show', as: 'rpi_auth_test' unless Rails.env.production? end diff --git a/gemfiles/rails_6.1.gemfile.lock b/gemfiles/rails_6.1.gemfile.lock index 8191b28..6e90030 100644 --- a/gemfiles/rails_6.1.gemfile.lock +++ b/gemfiles/rails_6.1.gemfile.lock @@ -1,7 +1,7 @@ PATH remote: .. specs: - rpi_auth (3.4.0) + rpi_auth (3.5.0) omniauth-rails_csrf_protection (~> 1.0.0) omniauth_openid_connect (~> 0.7.1) rails (>= 6.1.4) @@ -72,7 +72,7 @@ GEM ast (2.4.2) attr_required (1.0.2) base64 (0.2.0) - bindata (2.4.15) + bindata (2.5.0) builder (3.2.4) byebug (11.1.3) coderay (1.1.3) @@ -84,13 +84,12 @@ GEM email_validator (2.2.4) activemodel erubi (1.12.0) - faraday (2.8.1) - base64 - faraday-net_http (>= 2.0, < 3.1) - ruby2_keywords (>= 0.0.4) + faraday (2.9.2) + faraday-net_http (>= 2.0, < 3.2) faraday-follow_redirects (0.3.0) faraday (>= 1, < 3) - faraday-net_http (3.0.2) + faraday-net_http (3.1.0) + net-http ffi (1.16.3) globalid (1.2.1) activesupport (>= 6.1) @@ -98,7 +97,7 @@ GEM i18n (1.14.1) concurrent-ruby (~> 1.0) json (2.7.1) - json-jwt (1.16.5) + json-jwt (1.16.6) activesupport (>= 4.2) aes_key_wrap base64 @@ -122,6 +121,8 @@ GEM mini_mime (1.1.5) mini_portile2 (2.8.5) minitest (5.21.1) + net-http (0.4.1) + uri net-imap (0.4.9.1) date net-protocol @@ -139,7 +140,7 @@ GEM hashie (>= 3.4.6) rack (>= 2.2.3) rack-protection - omniauth-rails_csrf_protection (1.0.1) + omniauth-rails_csrf_protection (1.0.2) actionpack (>= 4.2) omniauth (~> 2.0) omniauth_openid_connect (0.7.1) @@ -168,7 +169,7 @@ GEM pry-byebug (3.10.1) byebug (~> 11.0) pry (>= 0.13, < 0.15) - public_suffix (5.0.4) + public_suffix (6.0.0) puma (6.4.2) nio4r (~> 2.0) racc (1.7.3) @@ -269,7 +270,6 @@ GEM rubocop-capybara (~> 2.17) rubocop-factory_bot (~> 2.22) ruby-progressbar (1.13.0) - ruby2_keywords (0.0.5) simplecov (0.22.0) docile (~> 1.1) simplecov-html (~> 0.11) @@ -293,6 +293,7 @@ GEM tzinfo (2.0.6) concurrent-ruby (~> 1.0) unicode-display_width (2.5.0) + uri (0.13.0) validate_url (1.0.15) activemodel (>= 3.0.0) public_suffix diff --git a/gemfiles/rails_7.0.gemfile.lock b/gemfiles/rails_7.0.gemfile.lock index 65285d5..fa8cad5 100644 --- a/gemfiles/rails_7.0.gemfile.lock +++ b/gemfiles/rails_7.0.gemfile.lock @@ -1,7 +1,7 @@ PATH remote: .. specs: - rpi_auth (3.4.0) + rpi_auth (3.5.0) omniauth-rails_csrf_protection (~> 1.0.0) omniauth_openid_connect (~> 0.7.1) rails (>= 6.1.4) @@ -78,7 +78,7 @@ GEM ast (2.4.2) attr_required (1.0.2) base64 (0.2.0) - bindata (2.4.15) + bindata (2.5.0) builder (3.2.4) byebug (11.1.3) coderay (1.1.3) @@ -104,7 +104,7 @@ GEM i18n (1.14.1) concurrent-ruby (~> 1.0) json (2.7.1) - json-jwt (1.16.5) + json-jwt (1.16.6) activesupport (>= 4.2) aes_key_wrap base64 @@ -145,7 +145,7 @@ GEM hashie (>= 3.4.6) rack (>= 2.2.3) rack-protection - omniauth-rails_csrf_protection (1.0.1) + omniauth-rails_csrf_protection (1.0.2) actionpack (>= 4.2) omniauth (~> 2.0) omniauth_openid_connect (0.7.1) @@ -174,7 +174,7 @@ GEM pry-byebug (3.10.1) byebug (~> 11.0) pry (>= 0.13, < 0.15) - public_suffix (5.0.4) + public_suffix (5.1.1) puma (6.4.2) nio4r (~> 2.0) racc (1.7.3) diff --git a/gemfiles/rails_7.1.gemfile.lock b/gemfiles/rails_7.1.gemfile.lock index 0725323..a860f19 100644 --- a/gemfiles/rails_7.1.gemfile.lock +++ b/gemfiles/rails_7.1.gemfile.lock @@ -1,7 +1,7 @@ PATH remote: .. specs: - rpi_auth (3.4.0) + rpi_auth (3.5.0) omniauth-rails_csrf_protection (~> 1.0.0) omniauth_openid_connect (~> 0.7.1) rails (>= 6.1.4) @@ -88,7 +88,7 @@ GEM attr_required (1.0.2) base64 (0.2.0) bigdecimal (3.1.5) - bindata (2.4.15) + bindata (2.5.0) builder (3.2.4) byebug (11.1.3) coderay (1.1.3) @@ -103,13 +103,12 @@ GEM email_validator (2.2.4) activemodel erubi (1.12.0) - faraday (2.8.1) - base64 - faraday-net_http (>= 2.0, < 3.1) - ruby2_keywords (>= 0.0.4) + faraday (2.9.2) + faraday-net_http (>= 2.0, < 3.2) faraday-follow_redirects (0.3.0) faraday (>= 1, < 3) - faraday-net_http (3.0.2) + faraday-net_http (3.1.0) + net-http ffi (1.16.3) globalid (1.2.1) activesupport (>= 6.1) @@ -121,7 +120,7 @@ GEM rdoc reline (>= 0.4.2) json (2.7.1) - json-jwt (1.16.5) + json-jwt (1.16.6) activesupport (>= 4.2) aes_key_wrap base64 @@ -146,6 +145,8 @@ GEM mini_portile2 (2.8.5) minitest (5.21.1) mutex_m (0.2.0) + net-http (0.4.1) + uri net-imap (0.4.9.1) date net-protocol @@ -163,7 +164,7 @@ GEM hashie (>= 3.4.6) rack (>= 2.2.3) rack-protection - omniauth-rails_csrf_protection (1.0.1) + omniauth-rails_csrf_protection (1.0.2) actionpack (>= 4.2) omniauth (~> 2.0) omniauth_openid_connect (0.7.1) @@ -194,7 +195,7 @@ GEM pry (>= 0.13, < 0.15) psych (5.1.2) stringio - public_suffix (5.0.4) + public_suffix (6.0.0) puma (6.4.2) nio4r (~> 2.0) racc (1.7.3) @@ -206,8 +207,9 @@ GEM faraday-follow_redirects json-jwt (>= 1.11.0) rack (>= 2.1.0) - rack-protection (3.0.6) - rack + rack-protection (4.0.0) + base64 (>= 0.1.0) + rack (>= 3.0.0, < 4) rack-session (2.0.0) rack (>= 3.0.0) rack-test (2.1.0) @@ -322,6 +324,7 @@ GEM tzinfo (2.0.6) concurrent-ruby (~> 1.0) unicode-display_width (2.5.0) + uri (0.13.0) validate_url (1.0.15) activemodel (>= 3.0.0) public_suffix diff --git a/lib/rpi_auth/engine.rb b/lib/rpi_auth/engine.rb index 927319b..1640633 100644 --- a/lib/rpi_auth/engine.rb +++ b/lib/rpi_auth/engine.rb @@ -12,6 +12,7 @@ class Engine < ::Rails::Engine LOGIN_PATH = '/auth/rpi' CALLBACK_PATH = '/rpi_auth/auth/callback' LOGOUT_PATH = '/rpi_auth/logout' + TEST_PATH = '/rpi_auth/test' initializer 'RpiAuth.set_logger' do OmniAuth.config.logger = Rails.logger diff --git a/spec/dummy/spec/requests/auth_request_spec.rb b/spec/dummy/spec/requests/auth_request_spec.rb index 5eae3b2..c9da849 100644 --- a/spec/dummy/spec/requests/auth_request_spec.rb +++ b/spec/dummy/spec/requests/auth_request_spec.rb @@ -17,7 +17,7 @@ let(:bypass_auth) { false } let(:identity_url) { 'https://my.example.com' } - let(:session_keys_to_persist) {} + let(:session_keys_to_persist) { nil } # We need to make sure we match the hostname Rails uses in test requests # here, otherwise `returnTo` redirects will fail after login/logout. let(:host_url) { 'https://www.example.com' } diff --git a/spec/dummy/spec/requests/home_request_spec.rb b/spec/dummy/spec/requests/home_request_spec.rb index 42c116e..cb04ba7 100644 --- a/spec/dummy/spec/requests/home_request_spec.rb +++ b/spec/dummy/spec/requests/home_request_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe 'Homepage' do +RSpec.describe 'RpiAuth Test page' do let(:user) do User.new(user_id: '3ed9b57a-1eb9-42e1-ae54-9a11c930f035') end From cd0fec21bcefb6463c4546ef7ee0d27bccdf67f5 Mon Sep 17 00:00:00 2001 From: Patrick Cherry Date: Tue, 2 Jul 2024 16:55:41 +0100 Subject: [PATCH 02/13] Add controller and view --- app/controllers/rpi_auth/test_controller.rb | 24 +++++++++++++++++++++ app/views/rpi_auth/test/show.html.erb | 21 ++++++++++++++++++ config/routes.rb | 2 +- lib/rpi_auth/engine.rb | 2 ++ 4 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 app/controllers/rpi_auth/test_controller.rb create mode 100644 app/views/rpi_auth/test/show.html.erb diff --git a/app/controllers/rpi_auth/test_controller.rb b/app/controllers/rpi_auth/test_controller.rb new file mode 100644 index 0000000..077ddd0 --- /dev/null +++ b/app/controllers/rpi_auth/test_controller.rb @@ -0,0 +1,24 @@ +# frozen_string_literal: true + +require 'rpi_auth/controllers/current_user' + +module RpiAuth + class TestController < ActionController::Base + include RpiAuth::Controllers::CurrentUser + include Rails.application.routes.url_helpers + + layout false + + def show + head :not_found if Rails.env.production? + + render locals: { login_params: login_params, logout_params: logout_params } + end + + def login_params + params.permit(:returnTo) + end + + alias logout_params login_params + end +end diff --git a/app/views/rpi_auth/test/show.html.erb b/app/views/rpi_auth/test/show.html.erb new file mode 100644 index 0000000..a91d094 --- /dev/null +++ b/app/views/rpi_auth/test/show.html.erb @@ -0,0 +1,21 @@ + + + + <%= stylesheet_link_tag 'https://static.raspberrypi.org/styles/design-system-core/branches/main/design-system-core.css' %> + <%= csp_meta_tag %> + + + + + diff --git a/config/routes.rb b/config/routes.rb index 6f16593..c08331f 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -12,5 +12,5 @@ # This route can be used in testing to log in, avoiding the need to interact # with shadow root in the RPF global nav. - get RpiAuth::Engine::TEST_PATH, to: 'rpi_auth/test#show', as: 'rpi_auth_test' unless Rails.env.production? + get RpiAuth::Engine::TEST_PATH, to: 'rpi_auth/test#show', as: 'rpi_auth_test' if RpiAuth::Engine::ENABLE_TEST_PATH end diff --git a/lib/rpi_auth/engine.rb b/lib/rpi_auth/engine.rb index 1640633..3201c70 100644 --- a/lib/rpi_auth/engine.rb +++ b/lib/rpi_auth/engine.rb @@ -14,6 +14,8 @@ class Engine < ::Rails::Engine LOGOUT_PATH = '/rpi_auth/logout' TEST_PATH = '/rpi_auth/test' + ENABLE_TEST_PATH = Rails.env.development? || Rails.env.test? + initializer 'RpiAuth.set_logger' do OmniAuth.config.logger = Rails.logger end From 481f62dbbbe4c0d07ec0748e7ceb8f9bf7768c81 Mon Sep 17 00:00:00 2001 From: Patrick Cherry Date: Tue, 2 Jul 2024 18:23:51 +0100 Subject: [PATCH 03/13] Add in more tests --- app/controllers/rpi_auth/test_controller.rb | 4 ++-- app/views/rpi_auth/test/show.html.erb | 4 ++-- gemfiles/rails_7.0.gemfile.lock | 15 ++++++++++++ rpi_auth.gemspec | 1 + spec/dummy/spec/requests/auth_request_spec.rb | 10 ++++---- spec/dummy/spec/requests/home_request_spec.rb | 2 +- spec/dummy/spec/routing/routes_spec.rb | 24 +++++++++++++++++++ spec/spec_helper.rb | 9 +++++++ spec/support/request_helpers.rb | 13 ---------- 9 files changed, 59 insertions(+), 23 deletions(-) diff --git a/app/controllers/rpi_auth/test_controller.rb b/app/controllers/rpi_auth/test_controller.rb index 077ddd0..f95a472 100644 --- a/app/controllers/rpi_auth/test_controller.rb +++ b/app/controllers/rpi_auth/test_controller.rb @@ -10,11 +10,11 @@ class TestController < ActionController::Base layout false def show - head :not_found if Rails.env.production? - render locals: { login_params: login_params, logout_params: logout_params } end + private + def login_params params.permit(:returnTo) end diff --git a/app/views/rpi_auth/test/show.html.erb b/app/views/rpi_auth/test/show.html.erb index a91d094..afa1a9a 100644 --- a/app/views/rpi_auth/test/show.html.erb +++ b/app/views/rpi_auth/test/show.html.erb @@ -1,7 +1,7 @@ - <%= stylesheet_link_tag 'https://static.raspberrypi.org/styles/design-system-core/branches/main/design-system-core.css' %> + <%= stylesheet_link_tag 'https://static.raspberrypi.org/styles/design-system-core/releases/v1.1.0/design-system-core.css' %> <%= csp_meta_tag %> @@ -14,7 +14,7 @@

Log in with your Raspberry Pi account

<%= button_to 'Log in', rpi_auth_login_path, params: login_params, class: "rpf-button" %>

Sign up for a Raspberry Pi account

- <%= button_to 'Log in', rpi_auth_signup_path, params: login_params, class: "rpf-button" %> + <%= button_to 'Sign up', rpi_auth_signup_path, params: login_params, class: "rpf-button" %> <% end %> diff --git a/gemfiles/rails_7.0.gemfile.lock b/gemfiles/rails_7.0.gemfile.lock index fa8cad5..f67edba 100644 --- a/gemfiles/rails_7.0.gemfile.lock +++ b/gemfiles/rails_7.0.gemfile.lock @@ -74,6 +74,8 @@ GEM i18n (>= 1.6, < 2) minitest (>= 5.1) tzinfo (~> 2.0) + addressable (2.8.7) + public_suffix (>= 2.0.2, < 7.0) aes_key_wrap (1.1.0) ast (2.4.2) attr_required (1.0.2) @@ -81,6 +83,15 @@ GEM bindata (2.5.0) builder (3.2.4) byebug (11.1.3) + capybara (3.40.0) + addressable + matrix + mini_mime (>= 0.1.3) + nokogiri (~> 1.11) + rack (>= 1.6.0) + rack-test (>= 0.6.3) + regexp_parser (>= 1.5, < 3.0) + xpath (~> 3.2) coderay (1.1.3) concurrent-ruby (1.2.3) crass (1.0.6) @@ -124,6 +135,7 @@ GEM net-pop net-smtp marcel (1.0.2) + matrix (0.4.2) method_source (1.0.0) mini_mime (1.1.5) mini_portile2 (2.8.5) @@ -302,12 +314,15 @@ GEM websocket-driver (0.7.6) websocket-extensions (>= 0.1.0) websocket-extensions (0.1.5) + xpath (3.2.0) + nokogiri (~> 1.8) zeitwerk (2.6.12) PLATFORMS ruby DEPENDENCIES + capybara listen pry-byebug puma diff --git a/rpi_auth.gemspec b/rpi_auth.gemspec index 43ca26d..4b68211 100644 --- a/rpi_auth.gemspec +++ b/rpi_auth.gemspec @@ -25,6 +25,7 @@ Gem::Specification.new do |spec| spec.add_dependency 'omniauth-rails_csrf_protection', '~> 1.0.0' spec.add_dependency 'rails', '>= 6.1.4' + spec.add_development_dependency 'capybara' spec.add_development_dependency 'listen' spec.add_development_dependency 'pry-byebug' spec.add_development_dependency 'puma' diff --git a/spec/dummy/spec/requests/auth_request_spec.rb b/spec/dummy/spec/requests/auth_request_spec.rb index c9da849..0fd4c4a 100644 --- a/spec/dummy/spec/requests/auth_request_spec.rb +++ b/spec/dummy/spec/requests/auth_request_spec.rb @@ -36,7 +36,7 @@ describe 'GET /rpi_auth/logout' do it 'clears the current session and redirects to profile' do - sign_in(user) + sign_in(user: user) expect(session['current_user']).not_to be_nil previous_id = session.id @@ -51,7 +51,7 @@ let(:return_to) { '/next/page' } it 'redirects to the correct URL' do - sign_in(user) + sign_in(user: user) get '/rpi_auth/logout', params: { returnTo: return_to } @@ -62,7 +62,7 @@ let(:return_to) { 'https://a.bad.actor.com/bad/page' } it 'redirects to the correct URL' do - sign_in(user) + sign_in(user: user) get '/rpi_auth/logout', params: { returnTo: return_to } @@ -92,7 +92,7 @@ let(:return_to) { '/next/page' } it 'redirects to the correct URL' do - sign_in(user) + sign_in(user: user) get '/rpi_auth/logout', params: { returnTo: return_to } @@ -152,7 +152,7 @@ describe 'On successful authentication' do before do - stub_auth_for(user) + stub_auth_for(user: user) end it 'sets the user in the session and redirects to root path' do diff --git a/spec/dummy/spec/requests/home_request_spec.rb b/spec/dummy/spec/requests/home_request_spec.rb index cb04ba7..24c6588 100644 --- a/spec/dummy/spec/requests/home_request_spec.rb +++ b/spec/dummy/spec/requests/home_request_spec.rb @@ -22,7 +22,7 @@ context 'when logged in' do before do - sign_in(user) + sign_in(user: user) end it 'displays the user ID' do diff --git a/spec/dummy/spec/routing/routes_spec.rb b/spec/dummy/spec/routing/routes_spec.rb index 9a9f4cc..e32602c 100644 --- a/spec/dummy/spec/routing/routes_spec.rb +++ b/spec/dummy/spec/routing/routes_spec.rb @@ -24,4 +24,28 @@ it { is_expected.to route_to({ controller: 'rpi_auth/auth', action: 'callback' }) } end + + describe 'test login page' do + subject { { get: '/rpi_auth/test' } } + + let(:enable_test_path) { true } + + before do + stub_const('RpiAuth::Engine::ENABLE_TEST_PATH', enable_test_path) + Rails.application.reload_routes! + end + + after do + stub_const('RpiAuth::Engine::ENABLE_TEST_PATH', true) + Rails.application.reload_routes! + end + + it { is_expected.to route_to({ controller: 'rpi_auth/test', action: 'show' }) } + + context 'when test path is disabled' do + let(:enable_test_path) { false } + + it { is_expected.not_to be_routable } + end + end end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 7f1f32b..730bd4d 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -10,6 +10,7 @@ require_relative './support/omniauth' require_relative './support/request_helpers' +require 'rpi_auth/spec_helpers' ENV['RAILS_ENV'] = 'test' @@ -37,7 +38,11 @@ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration RSpec.configure do |config| config.infer_spec_type_from_file_location! + config.include RequestHelpers, type: :request + config.include RpiAuth::SpecHelpers, type: :request + config.include RpiAuth::SpecHelpers, type: :system + # rspec-expectations config goes here. You can use an alternate # assertion/expectation library such as wrong or the stdlib/minitest # assertions if you prefer. @@ -120,6 +125,10 @@ # as the one that triggered the failure. Kernel.srand config.seed + config.before(type: :system) do |_example| + driven_by :rack_test + end + # Reset the RpiAuth config before each test config.before do RpiAuth.configuration.disable_auth_bypass diff --git a/spec/support/request_helpers.rb b/spec/support/request_helpers.rb index 6356a53..d4fbaa0 100644 --- a/spec/support/request_helpers.rb +++ b/spec/support/request_helpers.rb @@ -1,19 +1,6 @@ # frozen_string_literal: true module RequestHelpers - def stub_auth_for(user) - OmniAuth.config.test_mode = true - OmniAuth.config.add_mock(:rpi, uid: user.user_id, extra: { raw_info: user.serializable_hash(except: :id) }) - end - - # In request specs, we just post directly to `/auth/rpi`, so this can be - # called without any prep. - def sign_in(user) - stub_auth_for(user) - post '/auth/rpi' - follow_redirect! - end - def set_session(vars = {}) post session_path, params: { session_vars: vars } expect(response).to have_http_status(:created) From 021a8e7532c378e0589715144fc409baf03a9caa Mon Sep 17 00:00:00 2001 From: Patrick Cherry Date: Tue, 2 Jul 2024 18:25:14 +0100 Subject: [PATCH 04/13] Add in spec helpers --- lib/rpi_auth/spec_helpers.rb | 40 ++++++++++++ .../requests/rpi_auth_test_request_spec.rb | 35 +++++++++++ spec/dummy/spec/system/login_flow_spec.rb | 63 +++++++++++++++++++ 3 files changed, 138 insertions(+) create mode 100644 lib/rpi_auth/spec_helpers.rb create mode 100644 spec/dummy/spec/requests/rpi_auth_test_request_spec.rb create mode 100644 spec/dummy/spec/system/login_flow_spec.rb diff --git a/lib/rpi_auth/spec_helpers.rb b/lib/rpi_auth/spec_helpers.rb new file mode 100644 index 0000000..d36f233 --- /dev/null +++ b/lib/rpi_auth/spec_helpers.rb @@ -0,0 +1,40 @@ +# frozen_string_literal: true + +module RpiAuth + module SpecHelpers + def stub_auth_for(user:, id_param: :user_id) + OmniAuth.config.test_mode = true + + expires_in = user.respond_to?(:expires_at) ? user.expires_at.to_i - Time.zone.now.to_i : 3600 + token = user.respond_to?(:access_token) ? user.access_token : SecureRandom.hex(16) + refresh_token = user.respond_to?(:refresh_token) ? user.refresh_token : SecureRandom.hex(16) + + OmniAuth.config.add_mock(:rpi, + uid: user.send(id_param), + credentials: { + token: token, refresh_token: refresh_token, expires_in: expires_in + }.compact, + extra: { raw_info: user.serializable_hash(except: id_param) }) + end + + # This method goes through the login process properly. In system specs, you + # need to have visited the page with the "Log in" link before calling this. + # In request specs, we just post directly to `/auth/rpi`, so this can be + # called without any prep. + def sign_in(user:) + stub_auth_for(user: user) + + # This is a bit grotty, but see if we can call `find_link` (from Capybara, + # i.e. system specs) first, and then if that fails fall back to using + # `post` which is available in request specs. + if respond_to?(:click_on) + visit('/rpi_auth/test') + click_on('Log in') + else + post '/auth/rpi' + follow_redirect! + follow_redirect! + end + end + end +end diff --git a/spec/dummy/spec/requests/rpi_auth_test_request_spec.rb b/spec/dummy/spec/requests/rpi_auth_test_request_spec.rb new file mode 100644 index 0000000..aacde98 --- /dev/null +++ b/spec/dummy/spec/requests/rpi_auth_test_request_spec.rb @@ -0,0 +1,35 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe 'Rpi Auth test page' do + let(:user) do + User.new(user_id: '3ed9b57a-1eb9-42e1-ae54-9a11c930f035') + end + + before do + RpiAuth.configuration.user_model = 'User' + end + + describe 'GET /' do + context 'when logged out' do + it 'does not display the user ID' do + get '/rpi_auth/test' + + expect(response.body).not_to include(user.user_id) + end + end + + context 'when logged in' do + before do + sign_in(user: user) + end + + it 'displays the user ID' do + get '/rpi_auth/test' + + expect(response.body).to include(user.user_id) + end + end + end +end diff --git a/spec/dummy/spec/system/login_flow_spec.rb b/spec/dummy/spec/system/login_flow_spec.rb new file mode 100644 index 0000000..341ff7f --- /dev/null +++ b/spec/dummy/spec/system/login_flow_spec.rb @@ -0,0 +1,63 @@ +# frozen_string_literal: true + +require 'spec_helper' +require 'rpi_auth/spec_helpers' + +RSpec.describe 'Login flow' do + include RpiAuth::SpecHelpers + + let(:user) do + User.new( + email: 'person@example.com', + user_id: '3ed9b57a-1eb9-42e1-ae54-9a11c930f035', + country_code: 'GB', + name: 'Sylvester McBean', + nickname: 'Sylvie', + picture: 'https://placecage.com/100/100', + profile: 'https://my.raspberry.pi/profile/edit' + ) + end + + let(:identity_url) { 'https://my.example.com' } + let(:session_keys_to_persist) { nil } + # We need to make sure we match the hostname Rails uses in test requests + # here, otherwise `returnTo` redirects will fail after login/logout. + let(:host_url) { 'https://www.example.com' } + + before do + RpiAuth.configuration.user_model = 'User' + RpiAuth.configuration.identity_url = identity_url + RpiAuth.configuration.host_url = host_url + RpiAuth.configuration.session_keys_to_persist = session_keys_to_persist + OmniAuth.config.test_mode = true + end + + describe 'logging in' do + before do + stub_auth_for(user: user) + end + + it do + visit rpi_auth_test_path(returnTo: rpi_auth_test_path) + expect(page).to have_no_text(user.user_id) + + click_on 'Log in' + expect(page).to have_text(user.user_id) + expect(page).to have_text('Log out') + end + end + + describe 'Logging out' do + before do + sign_in(user: user) + end + + it do + visit rpi_auth_test_path(returnTo: rpi_auth_test_path) + expect(page).to have_text(user.user_id) + click_on 'Log out' + expect(page).to have_no_text(user.user_id) + expect(page).to have_text('Log in') + end + end +end From de17343afdb4a8824cb39a78936e41de008f569f Mon Sep 17 00:00:00 2001 From: Patrick Cherry Date: Tue, 2 Jul 2024 18:27:09 +0100 Subject: [PATCH 05/13] Update gemfiles --- gemfiles/rails_6.1.gemfile.lock | 15 +++++++++++++++ gemfiles/rails_7.1.gemfile.lock | 15 +++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/gemfiles/rails_6.1.gemfile.lock b/gemfiles/rails_6.1.gemfile.lock index 6e90030..9cef973 100644 --- a/gemfiles/rails_6.1.gemfile.lock +++ b/gemfiles/rails_6.1.gemfile.lock @@ -68,6 +68,8 @@ GEM minitest (>= 5.1) tzinfo (~> 2.0) zeitwerk (~> 2.3) + addressable (2.8.7) + public_suffix (>= 2.0.2, < 7.0) aes_key_wrap (1.1.0) ast (2.4.2) attr_required (1.0.2) @@ -75,6 +77,15 @@ GEM bindata (2.5.0) builder (3.2.4) byebug (11.1.3) + capybara (3.40.0) + addressable + matrix + mini_mime (>= 0.1.3) + nokogiri (~> 1.11) + rack (>= 1.6.0) + rack-test (>= 0.6.3) + regexp_parser (>= 1.5, < 3.0) + xpath (~> 3.2) coderay (1.1.3) concurrent-ruby (1.2.3) crass (1.0.6) @@ -117,6 +128,7 @@ GEM net-pop net-smtp marcel (1.0.2) + matrix (0.4.2) method_source (1.0.0) mini_mime (1.1.5) mini_portile2 (2.8.5) @@ -304,12 +316,15 @@ GEM websocket-driver (0.7.6) websocket-extensions (>= 0.1.0) websocket-extensions (0.1.5) + xpath (3.2.0) + nokogiri (~> 1.8) zeitwerk (2.6.12) PLATFORMS ruby DEPENDENCIES + capybara listen pry-byebug puma diff --git a/gemfiles/rails_7.1.gemfile.lock b/gemfiles/rails_7.1.gemfile.lock index a860f19..b41d909 100644 --- a/gemfiles/rails_7.1.gemfile.lock +++ b/gemfiles/rails_7.1.gemfile.lock @@ -83,6 +83,8 @@ GEM minitest (>= 5.1) mutex_m tzinfo (~> 2.0) + addressable (2.8.7) + public_suffix (>= 2.0.2, < 7.0) aes_key_wrap (1.1.0) ast (2.4.2) attr_required (1.0.2) @@ -91,6 +93,15 @@ GEM bindata (2.5.0) builder (3.2.4) byebug (11.1.3) + capybara (3.40.0) + addressable + matrix + mini_mime (>= 0.1.3) + nokogiri (~> 1.11) + rack (>= 1.6.0) + rack-test (>= 0.6.3) + regexp_parser (>= 1.5, < 3.0) + xpath (~> 3.2) coderay (1.1.3) concurrent-ruby (1.2.3) connection_pool (2.4.1) @@ -140,6 +151,7 @@ GEM net-pop net-smtp marcel (1.0.2) + matrix (0.4.2) method_source (1.0.0) mini_mime (1.1.5) mini_portile2 (2.8.5) @@ -336,12 +348,15 @@ GEM websocket-driver (0.7.6) websocket-extensions (>= 0.1.0) websocket-extensions (0.1.5) + xpath (3.2.0) + nokogiri (~> 1.8) zeitwerk (2.6.12) PLATFORMS ruby DEPENDENCIES + capybara listen pry-byebug puma From fe3b20c4206f97f7246e0d35ab5ec44cf485be21 Mon Sep 17 00:00:00 2001 From: Patrick Cherry Date: Tue, 2 Jul 2024 18:30:22 +0100 Subject: [PATCH 06/13] Decrease capybara to 3.39 to accommodate Ruby 2.7 --- gemfiles/rails_6.1.gemfile.lock | 6 +++--- gemfiles/rails_7.0.gemfile.lock | 6 +++--- gemfiles/rails_7.1.gemfile.lock | 6 +++--- rpi_auth.gemspec | 3 ++- 4 files changed, 11 insertions(+), 10 deletions(-) diff --git a/gemfiles/rails_6.1.gemfile.lock b/gemfiles/rails_6.1.gemfile.lock index 9cef973..e7dd8e6 100644 --- a/gemfiles/rails_6.1.gemfile.lock +++ b/gemfiles/rails_6.1.gemfile.lock @@ -77,11 +77,11 @@ GEM bindata (2.5.0) builder (3.2.4) byebug (11.1.3) - capybara (3.40.0) + capybara (3.39.2) addressable matrix mini_mime (>= 0.1.3) - nokogiri (~> 1.11) + nokogiri (~> 1.8) rack (>= 1.6.0) rack-test (>= 0.6.3) regexp_parser (>= 1.5, < 3.0) @@ -324,7 +324,7 @@ PLATFORMS ruby DEPENDENCIES - capybara + capybara (~> 3.39.0) listen pry-byebug puma diff --git a/gemfiles/rails_7.0.gemfile.lock b/gemfiles/rails_7.0.gemfile.lock index f67edba..8e53804 100644 --- a/gemfiles/rails_7.0.gemfile.lock +++ b/gemfiles/rails_7.0.gemfile.lock @@ -83,11 +83,11 @@ GEM bindata (2.5.0) builder (3.2.4) byebug (11.1.3) - capybara (3.40.0) + capybara (3.39.2) addressable matrix mini_mime (>= 0.1.3) - nokogiri (~> 1.11) + nokogiri (~> 1.8) rack (>= 1.6.0) rack-test (>= 0.6.3) regexp_parser (>= 1.5, < 3.0) @@ -322,7 +322,7 @@ PLATFORMS ruby DEPENDENCIES - capybara + capybara (~> 3.39.0) listen pry-byebug puma diff --git a/gemfiles/rails_7.1.gemfile.lock b/gemfiles/rails_7.1.gemfile.lock index b41d909..7137863 100644 --- a/gemfiles/rails_7.1.gemfile.lock +++ b/gemfiles/rails_7.1.gemfile.lock @@ -93,11 +93,11 @@ GEM bindata (2.5.0) builder (3.2.4) byebug (11.1.3) - capybara (3.40.0) + capybara (3.39.2) addressable matrix mini_mime (>= 0.1.3) - nokogiri (~> 1.11) + nokogiri (~> 1.8) rack (>= 1.6.0) rack-test (>= 0.6.3) regexp_parser (>= 1.5, < 3.0) @@ -356,7 +356,7 @@ PLATFORMS ruby DEPENDENCIES - capybara + capybara (~> 3.39.0) listen pry-byebug puma diff --git a/rpi_auth.gemspec b/rpi_auth.gemspec index 4b68211..f5892e7 100644 --- a/rpi_auth.gemspec +++ b/rpi_auth.gemspec @@ -25,7 +25,8 @@ Gem::Specification.new do |spec| spec.add_dependency 'omniauth-rails_csrf_protection', '~> 1.0.0' spec.add_dependency 'rails', '>= 6.1.4' - spec.add_development_dependency 'capybara' + # Capybara 3.40 drops ruby 2.7 support + spec.add_development_dependency 'capybara', '~> 3.39.0' spec.add_development_dependency 'listen' spec.add_development_dependency 'pry-byebug' spec.add_development_dependency 'puma' From 2d1ce63b008681aa92cdf9cdf25d24ae547c5f88 Mon Sep 17 00:00:00 2001 From: Patrick Cherry Date: Tue, 2 Jul 2024 18:35:14 +0100 Subject: [PATCH 07/13] Add docs --- README.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/README.md b/README.md index 741ac8d..1154cc4 100644 --- a/README.md +++ b/README.md @@ -187,6 +187,15 @@ class in `config/application.rb`. config.railties_order = [RpiAuth::Engine, :main_app, :all] ``` +## Test helpers and routes + +There are some standardised test helpers in `RpiAuth::SpecHelpers` that can be used when testing. + +* `stub_auth_for(user:)` enables the Omniauth test mode, and makes sure any auth requests succeed, returning this user. +* `log_in(user:)` goes through the log-in process for that user, either using Capybara-style `click_on` methods, or POST'ing directly to the auth endpoint. + +There is also a page at `/rpi_auth/test` that has log-in and sign-up buttons. + ## Troubleshooting Diagnosing issues with OpenID Connect can be tricky, so here are some things to try. From 3d50efbd8014a46531fa9a6e23629ee58a7e6d39 Mon Sep 17 00:00:00 2001 From: Patrick Cherry Date: Tue, 2 Jul 2024 20:37:47 +0100 Subject: [PATCH 08/13] Fix Gemfiles --- gemfiles/rails_6.1.gemfile.lock | 233 +++++++++++++++--------------- gemfiles/rails_7.0.gemfile.lock | 212 ++++++++++++++-------------- gemfiles/rails_7.1.gemfile.lock | 243 ++++++++++++++++---------------- rpi_auth.gemspec | 3 +- 4 files changed, 337 insertions(+), 354 deletions(-) diff --git a/gemfiles/rails_6.1.gemfile.lock b/gemfiles/rails_6.1.gemfile.lock index e7dd8e6..aa5fa4e 100644 --- a/gemfiles/rails_6.1.gemfile.lock +++ b/gemfiles/rails_6.1.gemfile.lock @@ -9,60 +9,60 @@ PATH GEM remote: https://rubygems.org/ specs: - actioncable (6.1.7.6) - actionpack (= 6.1.7.6) - activesupport (= 6.1.7.6) + actioncable (6.1.7.8) + actionpack (= 6.1.7.8) + activesupport (= 6.1.7.8) nio4r (~> 2.0) websocket-driver (>= 0.6.1) - actionmailbox (6.1.7.6) - actionpack (= 6.1.7.6) - activejob (= 6.1.7.6) - activerecord (= 6.1.7.6) - activestorage (= 6.1.7.6) - activesupport (= 6.1.7.6) + actionmailbox (6.1.7.8) + actionpack (= 6.1.7.8) + activejob (= 6.1.7.8) + activerecord (= 6.1.7.8) + activestorage (= 6.1.7.8) + activesupport (= 6.1.7.8) mail (>= 2.7.1) - actionmailer (6.1.7.6) - actionpack (= 6.1.7.6) - actionview (= 6.1.7.6) - activejob (= 6.1.7.6) - activesupport (= 6.1.7.6) + actionmailer (6.1.7.8) + actionpack (= 6.1.7.8) + actionview (= 6.1.7.8) + activejob (= 6.1.7.8) + activesupport (= 6.1.7.8) mail (~> 2.5, >= 2.5.4) rails-dom-testing (~> 2.0) - actionpack (6.1.7.6) - actionview (= 6.1.7.6) - activesupport (= 6.1.7.6) + actionpack (6.1.7.8) + actionview (= 6.1.7.8) + activesupport (= 6.1.7.8) rack (~> 2.0, >= 2.0.9) rack-test (>= 0.6.3) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.2.0) - actiontext (6.1.7.6) - actionpack (= 6.1.7.6) - activerecord (= 6.1.7.6) - activestorage (= 6.1.7.6) - activesupport (= 6.1.7.6) + actiontext (6.1.7.8) + actionpack (= 6.1.7.8) + activerecord (= 6.1.7.8) + activestorage (= 6.1.7.8) + activesupport (= 6.1.7.8) nokogiri (>= 1.8.5) - actionview (6.1.7.6) - activesupport (= 6.1.7.6) + actionview (6.1.7.8) + activesupport (= 6.1.7.8) builder (~> 3.1) erubi (~> 1.4) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.1, >= 1.2.0) - activejob (6.1.7.6) - activesupport (= 6.1.7.6) + activejob (6.1.7.8) + activesupport (= 6.1.7.8) globalid (>= 0.3.6) - activemodel (6.1.7.6) - activesupport (= 6.1.7.6) - activerecord (6.1.7.6) - activemodel (= 6.1.7.6) - activesupport (= 6.1.7.6) - activestorage (6.1.7.6) - actionpack (= 6.1.7.6) - activejob (= 6.1.7.6) - activerecord (= 6.1.7.6) - activesupport (= 6.1.7.6) + activemodel (6.1.7.8) + activesupport (= 6.1.7.8) + activerecord (6.1.7.8) + activemodel (= 6.1.7.8) + activesupport (= 6.1.7.8) + activestorage (6.1.7.8) + actionpack (= 6.1.7.8) + activejob (= 6.1.7.8) + activerecord (= 6.1.7.8) + activesupport (= 6.1.7.8) marcel (~> 1.0) mini_mime (>= 1.1.0) - activesupport (6.1.7.6) + activesupport (6.1.7.8) concurrent-ruby (~> 1.0, >= 1.0.2) i18n (>= 1.6, < 2) minitest (>= 5.1) @@ -75,7 +75,7 @@ GEM attr_required (1.0.2) base64 (0.2.0) bindata (2.5.0) - builder (3.2.4) + builder (3.3.0) byebug (11.1.3) capybara (3.39.2) addressable @@ -87,27 +87,28 @@ GEM regexp_parser (>= 1.5, < 3.0) xpath (~> 3.2) coderay (1.1.3) - concurrent-ruby (1.2.3) + concurrent-ruby (1.3.3) crass (1.0.6) date (3.3.4) - diff-lcs (1.5.0) + diff-lcs (1.5.1) docile (1.4.0) email_validator (2.2.4) activemodel - erubi (1.12.0) - faraday (2.9.2) - faraday-net_http (>= 2.0, < 3.2) + erubi (1.13.0) + faraday (2.8.1) + base64 + faraday-net_http (>= 2.0, < 3.1) + ruby2_keywords (>= 0.0.4) faraday-follow_redirects (0.3.0) faraday (>= 1, < 3) - faraday-net_http (3.1.0) - net-http - ffi (1.16.3) + faraday-net_http (3.0.2) + ffi (1.17.0) globalid (1.2.1) activesupport (>= 6.1) hashie (5.0.0) - i18n (1.14.1) + i18n (1.14.5) concurrent-ruby (~> 1.0) - json (2.7.1) + json (2.7.2) json-jwt (1.16.6) activesupport (>= 4.2) aes_key_wrap @@ -116,7 +117,7 @@ GEM faraday (~> 2.0) faraday-follow_redirects language_server-protocol (3.17.0.3) - listen (3.8.0) + listen (3.9.0) rb-fsevent (~> 0.10, >= 0.10.3) rb-inotify (~> 0.9, >= 0.9.10) loofah (2.22.0) @@ -127,25 +128,23 @@ GEM net-imap net-pop net-smtp - marcel (1.0.2) + marcel (1.0.4) matrix (0.4.2) - method_source (1.0.0) + method_source (1.1.0) mini_mime (1.1.5) - mini_portile2 (2.8.5) - minitest (5.21.1) - net-http (0.4.1) - uri - net-imap (0.4.9.1) + mini_portile2 (2.8.7) + minitest (5.24.1) + net-imap (0.4.14) date net-protocol net-pop (0.1.2) net-protocol net-protocol (0.2.2) timeout - net-smtp (0.4.0.1) + net-smtp (0.5.0) net-protocol - nio4r (2.7.0) - nokogiri (1.15.5) + nio4r (2.7.3) + nokogiri (1.15.6) mini_portile2 (~> 2.8.2) racc (~> 1.4) omniauth (2.1.2) @@ -171,8 +170,8 @@ GEM tzinfo validate_url webfinger (~> 2.0) - parallel (1.24.0) - parser (3.3.0.4) + parallel (1.25.1) + parser (3.3.3.0) ast (~> 2.4.1) racc pry (0.14.2) @@ -181,11 +180,11 @@ GEM pry-byebug (3.10.1) byebug (~> 11.0) pry (>= 0.13, < 0.15) - public_suffix (6.0.0) + public_suffix (5.1.1) puma (6.4.2) nio4r (~> 2.0) - racc (1.7.3) - rack (2.2.8) + racc (1.8.0) + rack (2.2.9) rack-oauth2 (2.2.1) activesupport attr_required @@ -198,20 +197,20 @@ GEM rack (~> 2.2, >= 2.2.4) rack-test (2.1.0) rack (>= 1.3) - rails (6.1.7.6) - actioncable (= 6.1.7.6) - actionmailbox (= 6.1.7.6) - actionmailer (= 6.1.7.6) - actionpack (= 6.1.7.6) - actiontext (= 6.1.7.6) - actionview (= 6.1.7.6) - activejob (= 6.1.7.6) - activemodel (= 6.1.7.6) - activerecord (= 6.1.7.6) - activestorage (= 6.1.7.6) - activesupport (= 6.1.7.6) + rails (6.1.7.8) + actioncable (= 6.1.7.8) + actionmailbox (= 6.1.7.8) + actionmailer (= 6.1.7.8) + actionpack (= 6.1.7.8) + actiontext (= 6.1.7.8) + actionview (= 6.1.7.8) + activejob (= 6.1.7.8) + activemodel (= 6.1.7.8) + activerecord (= 6.1.7.8) + activestorage (= 6.1.7.8) + activesupport (= 6.1.7.8) bundler (>= 1.15.0) - railties (= 6.1.7.6) + railties (= 6.1.7.8) sprockets-rails (>= 2.0.0) rails-dom-testing (2.2.0) activesupport (>= 5.0.0) @@ -220,39 +219,40 @@ GEM rails-html-sanitizer (1.6.0) loofah (~> 2.21) nokogiri (~> 1.14) - railties (6.1.7.6) - actionpack (= 6.1.7.6) - activesupport (= 6.1.7.6) + railties (6.1.7.8) + actionpack (= 6.1.7.8) + activesupport (= 6.1.7.8) method_source rake (>= 12.2) thor (~> 1.0) rainbow (3.1.1) - rake (13.1.0) + rake (13.2.1) rb-fsevent (0.11.2) - rb-inotify (0.10.1) + rb-inotify (0.11.1) ffi (~> 1.0) - regexp_parser (2.9.0) - rexml (3.2.6) - rspec-core (3.12.2) - rspec-support (~> 3.12.0) - rspec-expectations (3.12.3) + regexp_parser (2.9.2) + rexml (3.3.1) + strscan + rspec-core (3.13.0) + rspec-support (~> 3.13.0) + rspec-expectations (3.13.1) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.12.0) - rspec-mocks (3.12.6) + rspec-support (~> 3.13.0) + rspec-mocks (3.13.1) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.12.0) - rspec-rails (6.1.0) + rspec-support (~> 3.13.0) + rspec-rails (6.1.3) actionpack (>= 6.1) activesupport (>= 6.1) railties (>= 6.1) - rspec-core (~> 3.12) - rspec-expectations (~> 3.12) - rspec-mocks (~> 3.12) - rspec-support (~> 3.12) - rspec-support (3.12.1) + rspec-core (~> 3.13) + rspec-expectations (~> 3.13) + rspec-mocks (~> 3.13) + rspec-support (~> 3.13) + rspec-support (3.13.1) rspec_junit_formatter (0.6.0) rspec-core (>= 2, < 4, != 2.12.0) - rubocop (1.60.0) + rubocop (1.64.1) json (~> 2.3) language_server-protocol (>= 3.17.0) parallel (~> 1.10) @@ -260,28 +260,23 @@ GEM rainbow (>= 2.2.2, < 4.0) regexp_parser (>= 1.8, < 3.0) rexml (>= 3.2.5, < 4.0) - rubocop-ast (>= 1.30.0, < 2.0) + rubocop-ast (>= 1.31.1, < 2.0) ruby-progressbar (~> 1.7) unicode-display_width (>= 2.4.0, < 3.0) - rubocop-ast (1.30.0) - parser (>= 3.2.1.0) - rubocop-capybara (2.20.0) - rubocop (~> 1.41) - rubocop-factory_bot (2.25.1) - rubocop (~> 1.41) - rubocop-performance (1.20.2) + rubocop-ast (1.31.3) + parser (>= 3.3.1.0) + rubocop-performance (1.21.1) rubocop (>= 1.48.1, < 2.0) - rubocop-ast (>= 1.30.0, < 2.0) - rubocop-rails (2.23.1) + rubocop-ast (>= 1.31.1, < 2.0) + rubocop-rails (2.25.1) activesupport (>= 4.2.0) rack (>= 1.1) rubocop (>= 1.33.0, < 2.0) - rubocop-ast (>= 1.30.0, < 2.0) - rubocop-rspec (2.26.1) - rubocop (~> 1.40) - rubocop-capybara (~> 2.17) - rubocop-factory_bot (~> 2.22) + rubocop-ast (>= 1.31.1, < 2.0) + rubocop-rspec (3.0.1) + rubocop (~> 1.61) ruby-progressbar (1.13.0) + ruby2_keywords (0.0.5) simplecov (0.22.0) docile (~> 1.1) simplecov-html (~> 0.11) @@ -291,21 +286,21 @@ GEM sprockets (4.2.1) concurrent-ruby (~> 1.0) rack (>= 2.2.4, < 4) - sprockets-rails (3.4.2) - actionpack (>= 5.2) - activesupport (>= 5.2) + sprockets-rails (3.5.1) + actionpack (>= 6.1) + activesupport (>= 6.1) sprockets (>= 3.0.0) + strscan (3.1.0) swd (2.0.3) activesupport (>= 3) attr_required (>= 0.0.5) faraday (~> 2.0) faraday-follow_redirects - thor (1.3.0) + thor (1.3.1) timeout (0.4.1) tzinfo (2.0.6) concurrent-ruby (~> 1.0) unicode-display_width (2.5.0) - uri (0.13.0) validate_url (1.0.15) activemodel (>= 3.0.0) public_suffix @@ -318,13 +313,13 @@ GEM websocket-extensions (0.1.5) xpath (3.2.0) nokogiri (~> 1.8) - zeitwerk (2.6.12) + zeitwerk (2.6.16) PLATFORMS ruby DEPENDENCIES - capybara (~> 3.39.0) + capybara listen pry-byebug puma diff --git a/gemfiles/rails_7.0.gemfile.lock b/gemfiles/rails_7.0.gemfile.lock index 8e53804..26e5e5d 100644 --- a/gemfiles/rails_7.0.gemfile.lock +++ b/gemfiles/rails_7.0.gemfile.lock @@ -9,67 +9,67 @@ PATH GEM remote: https://rubygems.org/ specs: - actioncable (7.0.8) - actionpack (= 7.0.8) - activesupport (= 7.0.8) + actioncable (7.0.8.4) + actionpack (= 7.0.8.4) + activesupport (= 7.0.8.4) 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) + actionmailbox (7.0.8.4) + actionpack (= 7.0.8.4) + activejob (= 7.0.8.4) + activerecord (= 7.0.8.4) + activestorage (= 7.0.8.4) + activesupport (= 7.0.8.4) 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.0.8.4) + actionpack (= 7.0.8.4) + actionview (= 7.0.8.4) + activejob (= 7.0.8.4) + activesupport (= 7.0.8.4) 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) + actionpack (7.0.8.4) + actionview (= 7.0.8.4) + activesupport (= 7.0.8.4) rack (~> 2.0, >= 2.2.4) 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) + actiontext (7.0.8.4) + actionpack (= 7.0.8.4) + activerecord (= 7.0.8.4) + activestorage (= 7.0.8.4) + activesupport (= 7.0.8.4) globalid (>= 0.6.0) nokogiri (>= 1.8.5) - actionview (7.0.8) - activesupport (= 7.0.8) + actionview (7.0.8.4) + activesupport (= 7.0.8.4) 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) + activejob (7.0.8.4) + activesupport (= 7.0.8.4) globalid (>= 0.3.6) - 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.0.8.4) + activesupport (= 7.0.8.4) + activerecord (7.0.8.4) + activemodel (= 7.0.8.4) + activesupport (= 7.0.8.4) + activestorage (7.0.8.4) + actionpack (= 7.0.8.4) + activejob (= 7.0.8.4) + activerecord (= 7.0.8.4) + activesupport (= 7.0.8.4) marcel (~> 1.0) mini_mime (>= 1.1.0) - activesupport (7.0.8) + activesupport (7.0.8.4) concurrent-ruby (~> 1.0, >= 1.0.2) i18n (>= 1.6, < 2) minitest (>= 5.1) @@ -81,7 +81,7 @@ GEM attr_required (1.0.2) base64 (0.2.0) bindata (2.5.0) - builder (3.2.4) + builder (3.3.0) byebug (11.1.3) capybara (3.39.2) addressable @@ -93,14 +93,14 @@ GEM regexp_parser (>= 1.5, < 3.0) xpath (~> 3.2) coderay (1.1.3) - concurrent-ruby (1.2.3) + concurrent-ruby (1.3.3) crass (1.0.6) date (3.3.4) - diff-lcs (1.5.0) + diff-lcs (1.5.1) docile (1.4.0) email_validator (2.2.4) activemodel - erubi (1.12.0) + erubi (1.13.0) faraday (2.8.1) base64 faraday-net_http (>= 2.0, < 3.1) @@ -108,13 +108,13 @@ GEM faraday-follow_redirects (0.3.0) faraday (>= 1, < 3) faraday-net_http (3.0.2) - ffi (1.16.3) + ffi (1.17.0) globalid (1.2.1) activesupport (>= 6.1) hashie (5.0.0) - i18n (1.14.1) + i18n (1.14.5) concurrent-ruby (~> 1.0) - json (2.7.1) + json (2.7.2) json-jwt (1.16.6) activesupport (>= 4.2) aes_key_wrap @@ -123,7 +123,7 @@ GEM faraday (~> 2.0) faraday-follow_redirects language_server-protocol (3.17.0.3) - listen (3.8.0) + listen (3.9.0) rb-fsevent (~> 0.10, >= 0.10.3) rb-inotify (~> 0.9, >= 0.9.10) loofah (2.22.0) @@ -134,23 +134,23 @@ GEM net-imap net-pop net-smtp - marcel (1.0.2) + marcel (1.0.4) matrix (0.4.2) - method_source (1.0.0) + method_source (1.1.0) mini_mime (1.1.5) - mini_portile2 (2.8.5) - minitest (5.21.1) - net-imap (0.4.9.1) + mini_portile2 (2.8.7) + minitest (5.24.1) + net-imap (0.4.14) date net-protocol net-pop (0.1.2) net-protocol net-protocol (0.2.2) timeout - net-smtp (0.4.0.1) + net-smtp (0.5.0) net-protocol - nio4r (2.7.0) - nokogiri (1.15.5) + nio4r (2.7.3) + nokogiri (1.15.6) mini_portile2 (~> 2.8.2) racc (~> 1.4) omniauth (2.1.2) @@ -176,8 +176,8 @@ GEM tzinfo validate_url webfinger (~> 2.0) - parallel (1.24.0) - parser (3.3.0.4) + parallel (1.25.1) + parser (3.3.3.0) ast (~> 2.4.1) racc pry (0.14.2) @@ -189,8 +189,8 @@ GEM public_suffix (5.1.1) puma (6.4.2) nio4r (~> 2.0) - racc (1.7.3) - rack (2.2.8) + racc (1.8.0) + rack (2.2.9) rack-oauth2 (2.2.1) activesupport attr_required @@ -203,20 +203,20 @@ GEM rack (~> 2.2, >= 2.2.4) 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) + rails (7.0.8.4) + actioncable (= 7.0.8.4) + actionmailbox (= 7.0.8.4) + actionmailer (= 7.0.8.4) + actionpack (= 7.0.8.4) + actiontext (= 7.0.8.4) + actionview (= 7.0.8.4) + activejob (= 7.0.8.4) + activemodel (= 7.0.8.4) + activerecord (= 7.0.8.4) + activestorage (= 7.0.8.4) + activesupport (= 7.0.8.4) bundler (>= 1.15.0) - railties (= 7.0.8) + railties (= 7.0.8.4) rails-dom-testing (2.2.0) activesupport (>= 5.0.0) minitest @@ -224,40 +224,41 @@ 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) + railties (7.0.8.4) + actionpack (= 7.0.8.4) + activesupport (= 7.0.8.4) method_source rake (>= 12.2) thor (~> 1.0) zeitwerk (~> 2.5) rainbow (3.1.1) - rake (13.1.0) + rake (13.2.1) rb-fsevent (0.11.2) - rb-inotify (0.10.1) + rb-inotify (0.11.1) ffi (~> 1.0) - regexp_parser (2.9.0) - rexml (3.2.6) - rspec-core (3.12.2) - rspec-support (~> 3.12.0) - rspec-expectations (3.12.3) + regexp_parser (2.9.2) + rexml (3.3.1) + strscan + rspec-core (3.13.0) + rspec-support (~> 3.13.0) + rspec-expectations (3.13.1) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.12.0) - rspec-mocks (3.12.6) + rspec-support (~> 3.13.0) + rspec-mocks (3.13.1) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.12.0) - rspec-rails (6.1.0) + rspec-support (~> 3.13.0) + rspec-rails (6.1.3) actionpack (>= 6.1) activesupport (>= 6.1) railties (>= 6.1) - rspec-core (~> 3.12) - rspec-expectations (~> 3.12) - rspec-mocks (~> 3.12) - rspec-support (~> 3.12) - rspec-support (3.12.1) + rspec-core (~> 3.13) + rspec-expectations (~> 3.13) + rspec-mocks (~> 3.13) + rspec-support (~> 3.13) + rspec-support (3.13.1) rspec_junit_formatter (0.6.0) rspec-core (>= 2, < 4, != 2.12.0) - rubocop (1.60.0) + rubocop (1.64.1) json (~> 2.3) language_server-protocol (>= 3.17.0) parallel (~> 1.10) @@ -265,27 +266,21 @@ GEM rainbow (>= 2.2.2, < 4.0) regexp_parser (>= 1.8, < 3.0) rexml (>= 3.2.5, < 4.0) - rubocop-ast (>= 1.30.0, < 2.0) + rubocop-ast (>= 1.31.1, < 2.0) ruby-progressbar (~> 1.7) unicode-display_width (>= 2.4.0, < 3.0) - rubocop-ast (1.30.0) - parser (>= 3.2.1.0) - rubocop-capybara (2.20.0) - rubocop (~> 1.41) - rubocop-factory_bot (2.25.1) - rubocop (~> 1.41) - rubocop-performance (1.20.2) + rubocop-ast (1.31.3) + parser (>= 3.3.1.0) + rubocop-performance (1.21.1) rubocop (>= 1.48.1, < 2.0) - rubocop-ast (>= 1.30.0, < 2.0) - rubocop-rails (2.23.1) + rubocop-ast (>= 1.31.1, < 2.0) + rubocop-rails (2.25.1) activesupport (>= 4.2.0) rack (>= 1.1) rubocop (>= 1.33.0, < 2.0) - rubocop-ast (>= 1.30.0, < 2.0) - rubocop-rspec (2.26.1) - rubocop (~> 1.40) - rubocop-capybara (~> 2.17) - rubocop-factory_bot (~> 2.22) + rubocop-ast (>= 1.31.1, < 2.0) + rubocop-rspec (3.0.1) + rubocop (~> 1.61) ruby-progressbar (1.13.0) ruby2_keywords (0.0.5) simplecov (0.22.0) @@ -294,12 +289,13 @@ GEM simplecov_json_formatter (~> 0.1) simplecov-html (0.12.3) simplecov_json_formatter (0.1.4) + strscan (3.1.0) swd (2.0.3) activesupport (>= 3) attr_required (>= 0.0.5) faraday (~> 2.0) faraday-follow_redirects - thor (1.3.0) + thor (1.3.1) timeout (0.4.1) tzinfo (2.0.6) concurrent-ruby (~> 1.0) @@ -316,13 +312,13 @@ GEM websocket-extensions (0.1.5) xpath (3.2.0) nokogiri (~> 1.8) - zeitwerk (2.6.12) + zeitwerk (2.6.16) PLATFORMS ruby DEPENDENCIES - capybara (~> 3.39.0) + capybara listen pry-byebug puma diff --git a/gemfiles/rails_7.1.gemfile.lock b/gemfiles/rails_7.1.gemfile.lock index 7137863..94f47ae 100644 --- a/gemfiles/rails_7.1.gemfile.lock +++ b/gemfiles/rails_7.1.gemfile.lock @@ -9,35 +9,35 @@ PATH GEM remote: https://rubygems.org/ specs: - actioncable (7.1.2) - actionpack (= 7.1.2) - activesupport (= 7.1.2) + actioncable (7.1.3.4) + actionpack (= 7.1.3.4) + activesupport (= 7.1.3.4) nio4r (~> 2.0) websocket-driver (>= 0.6.1) zeitwerk (~> 2.6) - actionmailbox (7.1.2) - actionpack (= 7.1.2) - activejob (= 7.1.2) - activerecord (= 7.1.2) - activestorage (= 7.1.2) - activesupport (= 7.1.2) + actionmailbox (7.1.3.4) + actionpack (= 7.1.3.4) + activejob (= 7.1.3.4) + activerecord (= 7.1.3.4) + activestorage (= 7.1.3.4) + activesupport (= 7.1.3.4) mail (>= 2.7.1) net-imap net-pop net-smtp - actionmailer (7.1.2) - actionpack (= 7.1.2) - actionview (= 7.1.2) - activejob (= 7.1.2) - activesupport (= 7.1.2) + actionmailer (7.1.3.4) + actionpack (= 7.1.3.4) + actionview (= 7.1.3.4) + activejob (= 7.1.3.4) + activesupport (= 7.1.3.4) mail (~> 2.5, >= 2.5.4) net-imap net-pop net-smtp rails-dom-testing (~> 2.2) - actionpack (7.1.2) - actionview (= 7.1.2) - activesupport (= 7.1.2) + actionpack (7.1.3.4) + actionview (= 7.1.3.4) + activesupport (= 7.1.3.4) nokogiri (>= 1.8.5) racc rack (>= 2.2.4) @@ -45,35 +45,35 @@ GEM rack-test (>= 0.6.3) rails-dom-testing (~> 2.2) rails-html-sanitizer (~> 1.6) - actiontext (7.1.2) - actionpack (= 7.1.2) - activerecord (= 7.1.2) - activestorage (= 7.1.2) - activesupport (= 7.1.2) + actiontext (7.1.3.4) + actionpack (= 7.1.3.4) + activerecord (= 7.1.3.4) + activestorage (= 7.1.3.4) + activesupport (= 7.1.3.4) globalid (>= 0.6.0) nokogiri (>= 1.8.5) - actionview (7.1.2) - activesupport (= 7.1.2) + actionview (7.1.3.4) + activesupport (= 7.1.3.4) builder (~> 3.1) erubi (~> 1.11) rails-dom-testing (~> 2.2) rails-html-sanitizer (~> 1.6) - activejob (7.1.2) - activesupport (= 7.1.2) + activejob (7.1.3.4) + activesupport (= 7.1.3.4) globalid (>= 0.3.6) - activemodel (7.1.2) - activesupport (= 7.1.2) - activerecord (7.1.2) - activemodel (= 7.1.2) - activesupport (= 7.1.2) + activemodel (7.1.3.4) + activesupport (= 7.1.3.4) + activerecord (7.1.3.4) + activemodel (= 7.1.3.4) + activesupport (= 7.1.3.4) timeout (>= 0.4.0) - activestorage (7.1.2) - actionpack (= 7.1.2) - activejob (= 7.1.2) - activerecord (= 7.1.2) - activesupport (= 7.1.2) + activestorage (7.1.3.4) + actionpack (= 7.1.3.4) + activejob (= 7.1.3.4) + activerecord (= 7.1.3.4) + activesupport (= 7.1.3.4) marcel (~> 1.0) - activesupport (7.1.2) + activesupport (7.1.3.4) base64 bigdecimal concurrent-ruby (~> 1.0, >= 1.0.2) @@ -89,9 +89,9 @@ GEM ast (2.4.2) attr_required (1.0.2) base64 (0.2.0) - bigdecimal (3.1.5) + bigdecimal (3.1.8) bindata (2.5.0) - builder (3.2.4) + builder (3.3.0) byebug (11.1.3) capybara (3.39.2) addressable @@ -103,34 +103,34 @@ GEM regexp_parser (>= 1.5, < 3.0) xpath (~> 3.2) coderay (1.1.3) - concurrent-ruby (1.2.3) + concurrent-ruby (1.3.3) connection_pool (2.4.1) crass (1.0.6) date (3.3.4) - diff-lcs (1.5.0) + diff-lcs (1.5.1) docile (1.4.0) - drb (2.2.0) - ruby2_keywords + drb (2.2.1) email_validator (2.2.4) activemodel - erubi (1.12.0) - faraday (2.9.2) - faraday-net_http (>= 2.0, < 3.2) + erubi (1.13.0) + faraday (2.8.1) + base64 + faraday-net_http (>= 2.0, < 3.1) + ruby2_keywords (>= 0.0.4) faraday-follow_redirects (0.3.0) faraday (>= 1, < 3) - faraday-net_http (3.1.0) - net-http - ffi (1.16.3) + faraday-net_http (3.0.2) + ffi (1.17.0) globalid (1.2.1) activesupport (>= 6.1) hashie (5.0.0) - i18n (1.14.1) + i18n (1.14.5) concurrent-ruby (~> 1.0) - io-console (0.7.1) - irb (1.11.1) - rdoc + io-console (0.7.2) + irb (1.13.2) + rdoc (>= 4.0.0) reline (>= 0.4.2) - json (2.7.1) + json (2.7.2) json-jwt (1.16.6) activesupport (>= 4.2) aes_key_wrap @@ -139,7 +139,7 @@ GEM faraday (~> 2.0) faraday-follow_redirects language_server-protocol (3.17.0.3) - listen (3.8.0) + listen (3.9.0) rb-fsevent (~> 0.10, >= 0.10.3) rb-inotify (~> 0.9, >= 0.9.10) loofah (2.22.0) @@ -150,26 +150,24 @@ GEM net-imap net-pop net-smtp - marcel (1.0.2) + marcel (1.0.4) matrix (0.4.2) - method_source (1.0.0) + method_source (1.1.0) mini_mime (1.1.5) - mini_portile2 (2.8.5) - minitest (5.21.1) + mini_portile2 (2.8.7) + minitest (5.24.1) mutex_m (0.2.0) - net-http (0.4.1) - uri - net-imap (0.4.9.1) + net-imap (0.4.14) date net-protocol net-pop (0.1.2) net-protocol net-protocol (0.2.2) timeout - net-smtp (0.4.0.1) + net-smtp (0.5.0) net-protocol - nio4r (2.7.0) - nokogiri (1.15.5) + nio4r (2.7.3) + nokogiri (1.15.6) mini_portile2 (~> 2.8.2) racc (~> 1.4) omniauth (2.1.2) @@ -195,8 +193,8 @@ GEM tzinfo validate_url webfinger (~> 2.0) - parallel (1.24.0) - parser (3.3.0.4) + parallel (1.25.1) + parser (3.3.3.0) ast (~> 2.4.1) racc pry (0.14.2) @@ -207,11 +205,11 @@ GEM pry (>= 0.13, < 0.15) psych (5.1.2) stringio - public_suffix (6.0.0) + public_suffix (5.1.1) puma (6.4.2) nio4r (~> 2.0) - racc (1.7.3) - rack (3.0.8) + racc (1.8.0) + rack (3.1.6) rack-oauth2 (2.2.1) activesupport attr_required @@ -229,20 +227,20 @@ GEM rackup (2.1.0) rack (>= 3) webrick (~> 1.8) - rails (7.1.2) - actioncable (= 7.1.2) - actionmailbox (= 7.1.2) - actionmailer (= 7.1.2) - actionpack (= 7.1.2) - actiontext (= 7.1.2) - actionview (= 7.1.2) - activejob (= 7.1.2) - activemodel (= 7.1.2) - activerecord (= 7.1.2) - activestorage (= 7.1.2) - activesupport (= 7.1.2) + rails (7.1.3.4) + actioncable (= 7.1.3.4) + actionmailbox (= 7.1.3.4) + actionmailer (= 7.1.3.4) + actionpack (= 7.1.3.4) + actiontext (= 7.1.3.4) + actionview (= 7.1.3.4) + activejob (= 7.1.3.4) + activemodel (= 7.1.3.4) + activerecord (= 7.1.3.4) + activestorage (= 7.1.3.4) + activesupport (= 7.1.3.4) bundler (>= 1.15.0) - railties (= 7.1.2) + railties (= 7.1.3.4) rails-dom-testing (2.2.0) activesupport (>= 5.0.0) minitest @@ -250,45 +248,46 @@ GEM rails-html-sanitizer (1.6.0) loofah (~> 2.21) nokogiri (~> 1.14) - railties (7.1.2) - actionpack (= 7.1.2) - activesupport (= 7.1.2) + railties (7.1.3.4) + actionpack (= 7.1.3.4) + activesupport (= 7.1.3.4) irb rackup (>= 1.0.0) rake (>= 12.2) thor (~> 1.0, >= 1.2.2) zeitwerk (~> 2.6) rainbow (3.1.1) - rake (13.1.0) + rake (13.2.1) rb-fsevent (0.11.2) - rb-inotify (0.10.1) + rb-inotify (0.11.1) ffi (~> 1.0) - rdoc (6.6.2) + rdoc (6.7.0) psych (>= 4.0.0) - regexp_parser (2.9.0) - reline (0.4.2) + regexp_parser (2.9.2) + reline (0.5.9) io-console (~> 0.5) - rexml (3.2.6) - rspec-core (3.12.2) - rspec-support (~> 3.12.0) - rspec-expectations (3.12.3) + rexml (3.3.1) + strscan + rspec-core (3.13.0) + rspec-support (~> 3.13.0) + rspec-expectations (3.13.1) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.12.0) - rspec-mocks (3.12.6) + rspec-support (~> 3.13.0) + rspec-mocks (3.13.1) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.12.0) - rspec-rails (6.1.0) + rspec-support (~> 3.13.0) + rspec-rails (6.1.3) actionpack (>= 6.1) activesupport (>= 6.1) railties (>= 6.1) - rspec-core (~> 3.12) - rspec-expectations (~> 3.12) - rspec-mocks (~> 3.12) - rspec-support (~> 3.12) - rspec-support (3.12.1) + rspec-core (~> 3.13) + rspec-expectations (~> 3.13) + rspec-mocks (~> 3.13) + rspec-support (~> 3.13) + rspec-support (3.13.1) rspec_junit_formatter (0.6.0) rspec-core (>= 2, < 4, != 2.12.0) - rubocop (1.60.0) + rubocop (1.64.1) json (~> 2.3) language_server-protocol (>= 3.17.0) parallel (~> 1.10) @@ -296,27 +295,21 @@ GEM rainbow (>= 2.2.2, < 4.0) regexp_parser (>= 1.8, < 3.0) rexml (>= 3.2.5, < 4.0) - rubocop-ast (>= 1.30.0, < 2.0) + rubocop-ast (>= 1.31.1, < 2.0) ruby-progressbar (~> 1.7) unicode-display_width (>= 2.4.0, < 3.0) - rubocop-ast (1.30.0) - parser (>= 3.2.1.0) - rubocop-capybara (2.20.0) - rubocop (~> 1.41) - rubocop-factory_bot (2.25.1) - rubocop (~> 1.41) - rubocop-performance (1.20.2) + rubocop-ast (1.31.3) + parser (>= 3.3.1.0) + rubocop-performance (1.21.1) rubocop (>= 1.48.1, < 2.0) - rubocop-ast (>= 1.30.0, < 2.0) - rubocop-rails (2.23.1) + rubocop-ast (>= 1.31.1, < 2.0) + rubocop-rails (2.25.1) activesupport (>= 4.2.0) rack (>= 1.1) rubocop (>= 1.33.0, < 2.0) - rubocop-ast (>= 1.30.0, < 2.0) - rubocop-rspec (2.26.1) - rubocop (~> 1.40) - rubocop-capybara (~> 2.17) - rubocop-factory_bot (~> 2.22) + rubocop-ast (>= 1.31.1, < 2.0) + rubocop-rspec (3.0.1) + rubocop (~> 1.61) ruby-progressbar (1.13.0) ruby2_keywords (0.0.5) simplecov (0.22.0) @@ -325,18 +318,18 @@ GEM simplecov_json_formatter (~> 0.1) simplecov-html (0.12.3) simplecov_json_formatter (0.1.4) - stringio (3.1.0) + stringio (3.1.1) + strscan (3.1.0) swd (2.0.3) activesupport (>= 3) attr_required (>= 0.0.5) faraday (~> 2.0) faraday-follow_redirects - thor (1.3.0) + thor (1.3.1) timeout (0.4.1) tzinfo (2.0.6) concurrent-ruby (~> 1.0) unicode-display_width (2.5.0) - uri (0.13.0) validate_url (1.0.15) activemodel (>= 3.0.0) public_suffix @@ -350,13 +343,13 @@ GEM websocket-extensions (0.1.5) xpath (3.2.0) nokogiri (~> 1.8) - zeitwerk (2.6.12) + zeitwerk (2.6.16) PLATFORMS ruby DEPENDENCIES - capybara (~> 3.39.0) + capybara listen pry-byebug puma diff --git a/rpi_auth.gemspec b/rpi_auth.gemspec index f5892e7..4b68211 100644 --- a/rpi_auth.gemspec +++ b/rpi_auth.gemspec @@ -25,8 +25,7 @@ Gem::Specification.new do |spec| spec.add_dependency 'omniauth-rails_csrf_protection', '~> 1.0.0' spec.add_dependency 'rails', '>= 6.1.4' - # Capybara 3.40 drops ruby 2.7 support - spec.add_development_dependency 'capybara', '~> 3.39.0' + spec.add_development_dependency 'capybara' spec.add_development_dependency 'listen' spec.add_development_dependency 'pry-byebug' spec.add_development_dependency 'puma' From 10015ea90653c0e69ddad857016d0044e067ccf6 Mon Sep 17 00:00:00 2001 From: Patrick Cherry Date: Tue, 2 Jul 2024 20:42:34 +0100 Subject: [PATCH 09/13] Remove extra redirect --- lib/rpi_auth/spec_helpers.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/rpi_auth/spec_helpers.rb b/lib/rpi_auth/spec_helpers.rb index d36f233..76f4c49 100644 --- a/lib/rpi_auth/spec_helpers.rb +++ b/lib/rpi_auth/spec_helpers.rb @@ -33,7 +33,6 @@ def sign_in(user:) else post '/auth/rpi' follow_redirect! - follow_redirect! end end end From c7ac4513187873e65dc0eac3099a4e2c9a61a79c Mon Sep 17 00:00:00 2001 From: Patrick Cherry Date: Tue, 2 Jul 2024 20:52:17 +0100 Subject: [PATCH 10/13] Add docs --- .rubocop.yml | 3 ++ .rubocop_todo.yml | 45 +++++++++++++------ README.md | 2 +- lib/rpi_auth/spec_helpers.rb | 12 ++--- spec/dummy/spec/requests/auth_request_spec.rb | 8 ++-- spec/dummy/spec/requests/home_request_spec.rb | 2 +- .../requests/rpi_auth_test_request_spec.rb | 2 +- spec/dummy/spec/system/login_flow_spec.rb | 2 +- spec/spec_helper.rb | 4 +- 9 files changed, 52 insertions(+), 28 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index e708246..a6b42bc 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -10,10 +10,13 @@ inherit_mode: - Exclude AllCops: + NewCops: enable TargetRubyVersion: 2.7 Exclude: - 'spec/dummy/config/**/*' - 'spec/dummy/app/**/*' - 'spec/dummy/bin/**/*' - 'vendor/**/*' + - 'gemfiles/vendor/**/*' - 'bin/rails' + diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 90c8b41..701fff0 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,27 +1,46 @@ # This configuration was generated by # `rubocop --auto-gen-config` -# on 2021-09-14 13:25:06 UTC using RuboCop version 1.20.0. +# on 2024-07-02 19:48:59 UTC using RuboCop version 1.64.1. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new # versions of RuboCop, may require this file to be generated again. -# Offense count: 6 -# Configuration parameters: CountAsOne. -RSpec/ExampleLength: - Max: 8 +# Offense count: 11 +# Configuration parameters: EnforcedStyle, AllowedGems, Include. +# SupportedStyles: Gemfile, gems.rb, gemspec +# Include: **/*.gemspec, **/Gemfile, **/gems.rb +Gemspec/DevelopmentDependencies: + Exclude: + - 'rpi_auth.gemspec' # Offense count: 1 -# Configuration parameters: Include, CustomTransform, IgnoreMethods, SpecSuffixOnly. -# Include: **/*_spec*rb*, **/spec/**/* -RSpec/FilePath: - Exclude: - - 'spec/rpi_auth/models/authenticatable_spec.rb' +# Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes. +Metrics/AbcSize: + Max: 23 # Offense count: 7 -RSpec/MultipleExpectations: +# Configuration parameters: CountAsOne. +RSpec/ExampleLength: Max: 8 -# Offense count: 1 -RSpec/NestedGroups: +# Offense count: 20 +RSpec/MultipleExpectations: Max: 4 + +# Offense count: 8 +# Configuration parameters: AllowSubject. +RSpec/MultipleMemoizedHelpers: + Max: 6 + +# Offense count: 10 +# Configuration parameters: AllowedGroups. +RSpec/NestedGroups: + Max: 5 + +# Offense count: 1 +# Configuration parameters: Include, CustomTransform, IgnoreMethods, IgnoreMetadata. +# Include: **/*_spec.rb +RSpec/SpecFilePathFormat: + Exclude: + - 'spec/rpi_auth/models/authenticatable_spec.rb' diff --git a/README.md b/README.md index 1154cc4..9948947 100644 --- a/README.md +++ b/README.md @@ -194,7 +194,7 @@ There are some standardised test helpers in `RpiAuth::SpecHelpers` that can be u * `stub_auth_for(user:)` enables the Omniauth test mode, and makes sure any auth requests succeed, returning this user. * `log_in(user:)` goes through the log-in process for that user, either using Capybara-style `click_on` methods, or POST'ing directly to the auth endpoint. -There is also a page at `/rpi_auth/test` that has log-in and sign-up buttons. +There is also a page at `/rpi_auth/test` that has log-in and sign-up buttons which can be navigated to as part of the test suite to avoid having to render pages, or navigate into the shadow roots. ## Troubleshooting diff --git a/lib/rpi_auth/spec_helpers.rb b/lib/rpi_auth/spec_helpers.rb index 76f4c49..f371d26 100644 --- a/lib/rpi_auth/spec_helpers.rb +++ b/lib/rpi_auth/spec_helpers.rb @@ -2,13 +2,15 @@ module RpiAuth module SpecHelpers - def stub_auth_for(user:, id_param: :user_id) - OmniAuth.config.test_mode = true - + # This sets up the OmniAuth mock for the given user. It assumes the User + # model has an `:user_id` method which returns the users ID, but this can + # be changed by setting the `id_param` option. + def stub_auth_for(user:, id_param: :user_id) # rubocop:disable Metrics/AbcSize expires_in = user.respond_to?(:expires_at) ? user.expires_at.to_i - Time.zone.now.to_i : 3600 token = user.respond_to?(:access_token) ? user.access_token : SecureRandom.hex(16) refresh_token = user.respond_to?(:refresh_token) ? user.refresh_token : SecureRandom.hex(16) + OmniAuth.config.test_mode = true OmniAuth.config.add_mock(:rpi, uid: user.send(id_param), credentials: { @@ -21,10 +23,10 @@ def stub_auth_for(user:, id_param: :user_id) # need to have visited the page with the "Log in" link before calling this. # In request specs, we just post directly to `/auth/rpi`, so this can be # called without any prep. - def sign_in(user:) + def log_in(user:) stub_auth_for(user: user) - # This is a bit grotty, but see if we can call `find_link` (from Capybara, + # This is a bit grotty, but see if we can call `click_on` (from Capybara, # i.e. system specs) first, and then if that fails fall back to using # `post` which is available in request specs. if respond_to?(:click_on) diff --git a/spec/dummy/spec/requests/auth_request_spec.rb b/spec/dummy/spec/requests/auth_request_spec.rb index 0fd4c4a..1eafd3b 100644 --- a/spec/dummy/spec/requests/auth_request_spec.rb +++ b/spec/dummy/spec/requests/auth_request_spec.rb @@ -36,7 +36,7 @@ describe 'GET /rpi_auth/logout' do it 'clears the current session and redirects to profile' do - sign_in(user: user) + log_in(user: user) expect(session['current_user']).not_to be_nil previous_id = session.id @@ -51,7 +51,7 @@ let(:return_to) { '/next/page' } it 'redirects to the correct URL' do - sign_in(user: user) + log_in(user: user) get '/rpi_auth/logout', params: { returnTo: return_to } @@ -62,7 +62,7 @@ let(:return_to) { 'https://a.bad.actor.com/bad/page' } it 'redirects to the correct URL' do - sign_in(user: user) + log_in(user: user) get '/rpi_auth/logout', params: { returnTo: return_to } @@ -92,7 +92,7 @@ let(:return_to) { '/next/page' } it 'redirects to the correct URL' do - sign_in(user: user) + log_in(user: user) get '/rpi_auth/logout', params: { returnTo: return_to } diff --git a/spec/dummy/spec/requests/home_request_spec.rb b/spec/dummy/spec/requests/home_request_spec.rb index 24c6588..7763adb 100644 --- a/spec/dummy/spec/requests/home_request_spec.rb +++ b/spec/dummy/spec/requests/home_request_spec.rb @@ -22,7 +22,7 @@ context 'when logged in' do before do - sign_in(user: user) + log_in(user: user) end it 'displays the user ID' do diff --git a/spec/dummy/spec/requests/rpi_auth_test_request_spec.rb b/spec/dummy/spec/requests/rpi_auth_test_request_spec.rb index aacde98..d81f6ec 100644 --- a/spec/dummy/spec/requests/rpi_auth_test_request_spec.rb +++ b/spec/dummy/spec/requests/rpi_auth_test_request_spec.rb @@ -22,7 +22,7 @@ context 'when logged in' do before do - sign_in(user: user) + log_in(user: user) end it 'displays the user ID' do diff --git a/spec/dummy/spec/system/login_flow_spec.rb b/spec/dummy/spec/system/login_flow_spec.rb index 341ff7f..e286230 100644 --- a/spec/dummy/spec/system/login_flow_spec.rb +++ b/spec/dummy/spec/system/login_flow_spec.rb @@ -49,7 +49,7 @@ describe 'Logging out' do before do - sign_in(user: user) + log_in(user: user) end it do diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 730bd4d..df435e4 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -8,8 +8,8 @@ require 'pry-byebug' -require_relative './support/omniauth' -require_relative './support/request_helpers' +require_relative 'support/omniauth' +require_relative 'support/request_helpers' require 'rpi_auth/spec_helpers' ENV['RAILS_ENV'] = 'test' From 1b3b7383a2d2cc64b0a52b67f926d502b59fbab0 Mon Sep 17 00:00:00 2001 From: Patrick Cherry Date: Tue, 2 Jul 2024 20:56:09 +0100 Subject: [PATCH 11/13] Set rubygems version --- .github/workflows/test.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 8035759..f1b7861 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -25,6 +25,7 @@ jobs: uses: ruby/setup-ruby@v1 with: ruby-version: ${{ matrix.ruby-version }} + rubygems: 3.4.10 bundler-cache: true # runs 'bundle install' and caches installed gems automatically - name: Run tests run: bundle exec rspec From 29e80210695edc01d8475f4802953f8f462cae76 Mon Sep 17 00:00:00 2001 From: Patrick Cherry Date: Tue, 2 Jul 2024 21:04:06 +0100 Subject: [PATCH 12/13] Update README --- README.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/README.md b/README.md index 9948947..f94804b 100644 --- a/README.md +++ b/README.md @@ -196,6 +196,13 @@ There are some standardised test helpers in `RpiAuth::SpecHelpers` that can be u There is also a page at `/rpi_auth/test` that has log-in and sign-up buttons which can be navigated to as part of the test suite to avoid having to render pages, or navigate into the shadow roots. +To user these helpers you should add this to your `spec/rails_helper.rb`, inside the `RSpec.configure do |config|` block. + +```ruby + config.include RpiAuth::SpecHelpers, type: :request + config.include RpiAuth::SpecHelpers, type: :system +``` + ## Troubleshooting Diagnosing issues with OpenID Connect can be tricky, so here are some things to try. From 62f4783a2692a70fae1023012067bd17dae12555 Mon Sep 17 00:00:00 2001 From: Patrick Cherry Date: Thu, 4 Jul 2024 09:08:00 +0100 Subject: [PATCH 13/13] Update changelog --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index d0f50f1..4a427d7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Added +- Test controller/view to allow apps to log in without having to interact with the RPF Global Nav component. (#70) + ## [v3.5.0] ### Added