diff --git a/app/controllers/api/irs_attempts_api_controller.rb b/app/controllers/api/irs_attempts_api_controller.rb index 126649615a0..068759865e7 100644 --- a/app/controllers/api/irs_attempts_api_controller.rb +++ b/app/controllers/api/irs_attempts_api_controller.rb @@ -81,7 +81,9 @@ def timestamp timestamp_param = params.permit(:timestamp)[:timestamp] return nil if timestamp_param.nil? - Time.strptime(timestamp_param, '%Y-%m-%dT%H:%M:%S%z') + date_fmt = timestamp_param.include?('.') ? '%Y-%m-%dT%H:%M:%S.%N%z' : '%Y-%m-%dT%H:%M:%S%z' + + Time.strptime(timestamp_param, date_fmt) rescue ArgumentError nil end diff --git a/app/services/irs_attempts_api/envelope_encryptor.rb b/app/services/irs_attempts_api/envelope_encryptor.rb index 2373605101a..815298c4760 100644 --- a/app/services/irs_attempts_api/envelope_encryptor.rb +++ b/app/services/irs_attempts_api/envelope_encryptor.rb @@ -18,7 +18,7 @@ def self.encrypt(data:, timestamp:, public_key:) formatted_time = formatted_timestamp(timestamp) filename = - "FCI-#{IdentityConfig.store.irs_attempt_api_csp_id}_#{formatted_time}_#{digest}.dat.gz.hex" + "FCI-Logingov_#{formatted_time}_#{digest}.dat.gz.hex" Result.new( filename: filename, diff --git a/spec/controllers/api/irs_attempts_api_controller_spec.rb b/spec/controllers/api/irs_attempts_api_controller_spec.rb index 177f9ffa9ed..6e1a5d4cb3f 100644 --- a/spec/controllers/api/irs_attempts_api_controller_spec.rb +++ b/spec/controllers/api/irs_attempts_api_controller_spec.rb @@ -57,6 +57,15 @@ end end + context 'with a timestamp including a fractional second' do + let(:timestamp) { '2022-11-08T18:00:00.000Z' } + + it 'accepts the timestamp as valid' do + post :create, params: { timestamp: timestamp } + expect(response.status).to eq(200) + end + end + it 'renders a 404 if disabled' do allow(IdentityConfig.store).to receive(:irs_attempt_api_enabled).and_return(false)