Skip to content

Commit a7c840c

Browse files
committed
Merge branch 'stages/rc-2025-02-04' into 'stages/prod'
Deploy RC 87 to Prod See merge request lg/identity-pki!67
2 parents 3ceea8d + eb60f72 commit a7c840c

File tree

3 files changed

+47
-8
lines changed

3 files changed

+47
-8
lines changed

.rubocop.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ AllCops:
1919
- "lib/deploy/*"
2020
- "node_modules/**/*"
2121
- "vendor/**/*"
22-
TargetRubyVersion: 3.0
22+
TargetRubyVersion: 3.3
2323
TargetRailsVersion: 6.1
2424
UseCache: true
2525
DisabledByDefault: true

app/services/issuing_ca_service.rb

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,23 @@ def self.fetch_certificates(issuer_uri)
6767
if response.kind_of?(Net::HTTPSuccess)
6868
OpenSSL::PKCS7.new(response.body).certificates || []
6969
else
70-
NewRelic::Agent.notice_error(UnexpectedPKCS7Response.new(response.body))
70+
NewRelic::Agent.notice_error(
71+
UnexpectedPKCS7Response.new(response.body),
72+
custom_params: { issuer_uri: issuer_uri.to_s },
73+
)
74+
7175
[]
7276
end
73-
rescue OpenSSL::PKCS7::PKCS7Error, ArgumentError, Errno::ECONNREFUSED, Net::ReadTimeout, Net::OpenTimeout => e
74-
NewRelic::Agent.notice_error(e)
77+
rescue OpenSSL::PKCS7::PKCS7Error,
78+
ArgumentError,
79+
Errno::ECONNREFUSED,
80+
Net::ReadTimeout,
81+
Net::OpenTimeout => error
82+
NewRelic::Agent.notice_error(
83+
error,
84+
custom_params: { issuer_uri: issuer_uri.to_s, response_body: response&.body },
85+
)
86+
7587
[]
7688
end
7789

spec/services/issuing_ca_service_spec.rb

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,32 @@
5656

5757
context 'when there is an HTTP error fetching the certificate' do
5858
it 'returns nil and logs the error' do
59-
stub_request(:get, 'http://example.com').to_return(status: [500, 'Internal Server Error'])
59+
stub_request(:get, 'http://example.com/').to_return(
60+
status: [500, 'Internal Server Error'],
61+
body: 'Internal Server Error',
62+
)
6063

6164
certificate = certificates_in_collection(certificate_set, :type, :leaf).first
6265
expect(NewRelic::Agent).to receive(:notice_error).with(
63-
IssuingCaService::UnexpectedPKCS7Response
66+
IssuingCaService::UnexpectedPKCS7Response.new('Internal Server Error'),
67+
custom_params: { issuer_uri: 'http://example.com/' },
68+
)
69+
fetched_cert = described_class.fetch_signing_key_for_cert(certificate)
70+
expect(fetched_cert).to eq nil
71+
end
72+
end
73+
74+
context 'when there is an HTTP timeout fetching the certificate' do
75+
it 'returns nil and logs the error' do
76+
stub_request(:get, 'http://example.com/').to_timeout
77+
78+
certificate = certificates_in_collection(certificate_set, :type, :leaf).first
79+
expect(NewRelic::Agent).to receive(:notice_error).with(
80+
Net::OpenTimeout,
81+
custom_params: {
82+
issuer_uri: 'http://example.com/',
83+
response_body: nil,
84+
},
6485
)
6586
fetched_cert = described_class.fetch_signing_key_for_cert(certificate)
6687
expect(fetched_cert).to eq nil
@@ -69,10 +90,16 @@
6990

7091
context 'when the PKCS7 response is invalid' do
7192
it 'returns nil and logs the error' do
72-
stub_request(:get, 'http://example.com').to_return(body: 'bad pkcs7 response')
93+
stub_request(:get, 'http://example.com/').to_return(body: 'bad pkcs7 response')
7394

7495
certificate = certificates_in_collection(certificate_set, :type, :leaf).first
75-
expect(NewRelic::Agent).to receive(:notice_error).with(ArgumentError)
96+
expect(NewRelic::Agent).to receive(:notice_error).with(
97+
ArgumentError,
98+
custom_params: {
99+
issuer_uri: 'http://example.com/',
100+
response_body: 'bad pkcs7 response',
101+
},
102+
)
76103
fetched_cert = described_class.fetch_signing_key_for_cert(certificate)
77104
expect(fetched_cert).to eq nil
78105
end

0 commit comments

Comments
 (0)