-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add mock_user strategy for development
- Loading branch information
Tom Iles
committed
Nov 15, 2023
1 parent
83b8604
commit 1b88166
Showing
2 changed files
with
16 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,4 +9,4 @@ forms_api: | |
auth_key: changeme | ||
|
||
# Use mock authentication | ||
auth_provider: mock_gds_sso | ||
auth_provider: mock_user |