diff --git a/Gemfile b/Gemfile index 6101fd9a298..56705a35af2 100644 --- a/Gemfile +++ b/Gemfile @@ -255,7 +255,8 @@ group :test do gem 'capybara', '~> 3.39.0' gem 'capybara-screenshot', '~> 1.0.17' gem 'cuprite', '~> 0.15.0' - gem 'selenium-webdriver', '~> 4.15.0' + gem 'selenium-devtools' + gem 'selenium-webdriver', '~> 4.15' gem 'capybara_accessible_selectors', git: 'https://github.com/citizensadvice/capybara_accessible_selectors', branch: 'main' gem 'fuubar', '~> 2.5.0' diff --git a/Gemfile.lock b/Gemfile.lock index e4faa80b837..11f3da4c2e4 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -938,7 +938,9 @@ GEM crass (~> 1.0.2) nokogiri (>= 1.12.0) secure_headers (6.5.0) - selenium-webdriver (4.15.0) + selenium-devtools (0.120.0) + selenium-webdriver (~> 4.2) + selenium-webdriver (4.16.0) rexml (~> 3.2, >= 3.2.5) rubyzip (>= 1.2.2, < 3.0) websocket (~> 1.0) @@ -1210,7 +1212,8 @@ DEPENDENCIES rubytree (~> 2.0.0) sanitize (~> 6.1.0) secure_headers (~> 6.5.0) - selenium-webdriver (~> 4.15.0) + selenium-devtools + selenium-webdriver (~> 4.15) semantic (~> 1.6.1) shoulda-context (~> 2.0) shoulda-matchers (~> 5.0) diff --git a/modules/bim/spec/features/bcf/api_authorization_spec.rb b/modules/bim/spec/features/bcf/api_authorization_spec.rb index 8561414d50c..3d2650e6caf 100644 --- a/modules/bim/spec/features/bcf/api_authorization_spec.rb +++ b/modules/bim/spec/features/bcf/api_authorization_spec.rb @@ -128,8 +128,13 @@ RSpec.describe 'authorization for BCF api', :js, with_config: { edition: 'bim' } logout + # A basic auth alert is displayed asking to enter name and password + # Register some basic auth credentials + # A non-matching url is used so that capybara will issue a CancelAuth instead of trying to authenticate + page.driver.browser.register(username: 'foo', password: 'bar', uri: /does_not_match/) # While not being logged in and without a token, the api cannot be accessed visit("/api/bcf/2.1/projects/#{project.id}") + # Cancel button of basic auth should have been chosen now expect(page) .to have_content(JSON.dump({ message: "You need to be authenticated to access this resource." }))