Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions app/jobs/data_warehouse/daily_sensitive_column_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ class DailySensitiveColumnJob < BaseJob

def perform(timestamp)
data = fetch_columns
upload_to_s3(data, timestamp)

if IdentityConfig.store.s3_idp_dw_tasks.present?
upload_to_s3(data, timestamp)
end
end

def fetch_columns
Expand Down Expand Up @@ -53,14 +56,12 @@ def bucket_name
def upload_to_s3(body, timestamp)
_latest, path = generate_s3_paths(REPORT_NAME, 'json', now: timestamp)

if bucket_name.present?
upload_file_to_s3_bucket(
path: path,
body: body,
content_type: 'application/json',
bucket: bucket_name,
)
end
upload_file_to_s3_bucket(
path: path,
body: body,
content_type: 'application/json',
bucket: bucket_name,
)
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

let(:timestamp) { Date.new(2024, 10, 15).in_time_zone('UTC') }
let(:job) { described_class.new }
let(:expected_bucket) { 'login-gov-ipd-dw-tasks-test-1234-us-west-2' }
let(:expected_bucket) { "#{IdentityConfig.store.s3_idp_dw_tasks}-test-1234-us-west-2" }
let(:tables) { ['auth_app_configurations'] }
let(:s3_idp_dw_tasks) { 'login-gov-idp-dw-tasks' }

Expand Down Expand Up @@ -81,7 +81,20 @@
allow(ActiveRecord::Base.connection).to receive(:tables).and_return(tables)
end

context 'when uploading to S3' do
context 'when bucket name is blank' do
before do
allow(IdentityConfig.store).to(
receive(:s3_idp_dw_tasks),
).and_return('')
end

it 'skips trying to upload to S3' do
expect(job).to_not receive(:upload_file_to_s3_bucket)
job.perform(timestamp)
end
end

context 'when bucket name is present' do
it 'uploads a file to S3 based on the report date' do
expect(job).to receive(:upload_file_to_s3_bucket).with(
path: 'daily-sensitive-column-job/2024/2024-10-15_daily-sensitive-column-job.json',
Expand Down