Adds attempts:enable_for_sinatra and fix minor breakage#7179
Conversation
[skip changelog]
| 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' |
There was a problem hiding this comment.
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_token and private_key_path to 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.
whoops great catch, thanks
| task enable_for_sinatra: :environment do | ||
| sp = ServiceProvider.find_by(friendly_name: 'Example Sinatra App') | ||
| sp.update(irs_attempts_api_enabled: true) | ||
| end |
There was a problem hiding this comment.
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 check_enabled just fix this for you immediately, but none of the others can be done that way so it seems best to stay consistent.
There was a problem hiding this comment.
I'd consider maybe making the friendly name (or even issuer?) an argument so we ca call rake enable_attempts_api ISSUER=ABCDEF
There was a problem hiding this comment.
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.
Rwolfe-Nava
left a comment
There was a problem hiding this comment.
Thank you for doing this!
🎫 Ticket
None. This is whim.
🛠 Summary of changes
rake attempts:check_enabledrake attempts:enable_for_sinatratask, to make life easier📜 Testing Plan
🚀 Notes for Deployment
N/A - This should not be used in prod.