Skip to content

Commit

Permalink
Add mock_user strategy for development
Browse files Browse the repository at this point in the history
  • Loading branch information
Tom Iles committed Nov 15, 2023
1 parent 83b8604 commit 1b88166
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
15 changes: 15 additions & 0 deletions config/initializers/warden/strategies/mock_user.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
Warden::Strategies.add(:mock_user) do
def authenticate!
logger.warn("Authenticating with mock_gds_sso strategy")

test_user ||= User.first

if test_user
success!(test_user)
elsif Rails.env.test? && ENV["GDS_SSO_MOCK_INVALID"].present?
fail!(:invalid)
else
raise "Mock_user running in mock mode and no test user found. Normally we'd load the first user in the database. Create a user in the database."
end
end
end
2 changes: 1 addition & 1 deletion config/settings/development.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ forms_api:
auth_key: changeme

# Use mock authentication
auth_provider: mock_gds_sso
auth_provider: mock_user

0 comments on commit 1b88166

Please sign in to comment.