diff options
Diffstat (limited to 'spec/lib/error_tracking')
-rw-r--r-- | spec/lib/error_tracking/collector/sentry_auth_parser_spec.rb | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/spec/lib/error_tracking/collector/sentry_auth_parser_spec.rb b/spec/lib/error_tracking/collector/sentry_auth_parser_spec.rb new file mode 100644 index 00000000000..4f00b1ec654 --- /dev/null +++ b/spec/lib/error_tracking/collector/sentry_auth_parser_spec.rb @@ -0,0 +1,32 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe ErrorTracking::Collector::SentryAuthParser do + describe '.parse' do + let(:headers) { { 'X-Sentry-Auth' => "Sentry sentry_key=glet_1fedb514e17f4b958435093deb02048c" } } + let(:request) { double('request', headers: headers) } + + subject { described_class.parse(request) } + + context 'empty headers' do + let(:headers) { {} } + + it 'fails with exception' do + expect { subject }.to raise_error(StandardError) + end + end + + context 'missing sentry_key' do + let(:headers) { { 'X-Sentry-Auth' => "Sentry foo=bar" } } + + it 'returns empty value for public_key' do + expect(subject[:public_key]).to be_nil + end + end + + it 'returns correct value for public_key' do + expect(subject[:public_key]).to eq('glet_1fedb514e17f4b958435093deb02048c') + end + end +end |