-
Notifications
You must be signed in to change notification settings - Fork 166
Adds attempts:enable_for_sinatra and fix minor breakage #7179
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -46,6 +46,9 @@ namespace :attempts do | |
| desc 'Confirm your dev setup is configured properly' | ||
| task check_enabled: :environment do | ||
| failed = false | ||
| auth_token = IdentityConfig.store.irs_attempt_api_auth_tokens.sample | ||
| puts 'There are no configured irs_attempt_api_auth_tokens' if auth_token.nil? | ||
| private_key_path = 'keys/attempts_api_private_key.key' | ||
|
|
||
| if IdentityConfig.store.irs_attempt_api_enabled | ||
| puts 'β Feature flag is enabled' | ||
|
|
@@ -59,7 +62,7 @@ namespace :attempts do | |
| puts 'β Sinatra app SP has irs_attempts_api_enabled=true' | ||
| else | ||
| failed = true | ||
| puts "β FAILED: Set irs_attempts_api_enabled=true on ServiceProvider.find #{sp.id}" | ||
| puts 'β FAILED: Run rake attempts:enable_for_sinatra' | ||
| end | ||
|
|
||
| if IdentityConfig.store.irs_attempt_api_auth_tokens.include?(auth_token) | ||
|
|
@@ -78,6 +81,12 @@ namespace :attempts do | |
| puts 'Remember to restart Rails after updating application.yml.default!' if failed | ||
| end | ||
|
|
||
| desc 'Enable irs_attempts_api_enabled for Sinatra SP' | ||
| task enable_for_sinatra: :environment do | ||
| sp = ServiceProvider.find_by(friendly_name: 'Example Sinatra App') | ||
| sp.update(irs_attempts_api_enabled: true) | ||
| end | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since we're already checking this and telling you if it's wrong, let's just offer to fix it here, rather than making the user go off to the rails console. I briefly debated adding a check so this would refuse to run in prod, but (1) you shouldn't run random rake tasks in prod, (2) there probably isn't an actual SP named "Example Sinatra App" in prod, and (3) if there is, someone running this probably actually intends to enable it? π€· Happy to add a check if people believe it's warranted. Going in the other direction, we could make
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd consider maybe making the friendly name (or even issuer?) an argument so we ca call
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That'd be easy enough to implement, but the intent here was just for localhost use with the default Sinatra app. I think if people are going to go edit other providers they're probably better off using the Rails console. |
||
|
|
||
| desc 'Clear all events from Redis' | ||
| task purge_events: :environment do | ||
| IrsAttemptsApi::RedisClient.clear_attempts! | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was set at the class level earlier but Zach (rightly) pulled some of it out since it was spamming rake output in prod: e82e728
We expected
auth_tokenandprivate_key_pathto be defined here. I'm duplicating them, and keeping the puts rather than adding a separate check. I don't think we need to worry about DRYing this up further.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
whoops great catch, thanks