Skip to content

Commit

Permalink
Enable fake auth for new staging app
Browse files Browse the repository at this point in the history
Why these changes are being introduced:

We have a temporary staging app, `thesis-submit-staging-new`,
that we will use to test the new S3 bucket and SQS queues in the
AWS org. It doesn't make sense to set up this second staging
app with Touchstone, so it's best to use fake auth for testing
purposes.

Relevant ticket(s):

N/A.

How this addresses that need:

This allows the new staging app to use fake auth.

Side effects of this change:

We'll want to remove this feature once we're done testing. An inline
comment reiterates this. Longer term, it may make sense to log an
exception and crash the application if fake auth is attempted in prod.
(This is the situation that the `app_name_pattern_match?` method is
trying to prevent.)
  • Loading branch information
jazairi committed Aug 11, 2023
1 parent 233cc16 commit a22ae2b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
4 changes: 4 additions & 0 deletions app/models/concerns/fake_auth_config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ def self.fake_auth_status
private_class_method def self.app_name_pattern_match?
return true if Rails.env.development?

# TODO: remove this line once we have confirmed the S3 and SQS migration to the new AWS org. We created a temporary
# second review app to test that migration.
return true if ENV.fetch('HEROKU_APP_NAME', nil) == 'thesis-submit-staging-new'

review_app_pattern = /^thesis-(submit|dropbox)-pr-\d+$/
review_app_pattern.match(ENV.fetch('HEROKU_APP_NAME', nil)).present?
end
Expand Down
7 changes: 7 additions & 0 deletions test/models/fake_auth_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,11 @@ class FakeAuthTest < ActiveSupport::TestCase
assert_equal(false, FakeAuthConfig.fake_auth_status)
end
end

test 'fakeauth enabled temp staging app name' do
ClimateControl.modify FAKE_AUTH_ENABLED: 'true',
HEROKU_APP_NAME: 'thesis-submit-staging-new' do
assert_equal true, FakeAuthConfig.fake_auth_status
end
end
end

0 comments on commit a22ae2b

Please sign in to comment.